|
28 | 28 | TypeIdentifier::BOOL->value => [ |
29 | 29 | TypeIdentifier::INT->value => Cast\Int_::class, |
30 | 30 | TypeIdentifier::STRING->value => Cast\String_::class, |
31 | | - TypeIdentifier::FLOAT->value => Cast\Double::class, |
| 31 | + TypeIdentifier::FLOAT->value => 'toFloat', |
32 | 32 | TypeIdentifier::ARRAY->value => 'toArray', |
33 | 33 | TypeIdentifier::ITERABLE->value => 'toArray', |
34 | 34 | ], |
35 | 35 | TypeIdentifier::MIXED->value => [ |
36 | 36 | TypeIdentifier::INT->value => Cast\Int_::class, |
37 | 37 | TypeIdentifier::STRING->value => Cast\String_::class, |
38 | | - TypeIdentifier::FLOAT->value => Cast\Double::class, |
| 38 | + TypeIdentifier::FLOAT->value => 'toFloat', |
39 | 39 | TypeIdentifier::ARRAY->value => 'toArray', |
40 | 40 | TypeIdentifier::ITERABLE->value => 'toArray', |
41 | 41 | ], |
|
47 | 47 | TypeIdentifier::ITERABLE->value => 'toArray', |
48 | 48 | ], |
49 | 49 | TypeIdentifier::INT->value => [ |
50 | | - TypeIdentifier::FLOAT->value => Cast\Double::class, |
| 50 | + TypeIdentifier::FLOAT->value => 'toFloat', |
51 | 51 | TypeIdentifier::STRING->value => Cast\String_::class, |
52 | 52 | TypeIdentifier::BOOL->value => Cast\Bool_::class, |
53 | 53 | TypeIdentifier::ARRAY->value => 'toArray', |
|
60 | 60 | TypeIdentifier::STRING->value => [ |
61 | 61 | TypeIdentifier::ARRAY->value => 'toArray', |
62 | 62 | TypeIdentifier::ITERABLE->value => 'toArray', |
63 | | - TypeIdentifier::FLOAT->value => Cast\Double::class, |
| 63 | + TypeIdentifier::FLOAT->value => 'toFloat', |
64 | 64 | TypeIdentifier::INT->value => Cast\Int_::class, |
65 | 65 | TypeIdentifier::BOOL->value => Cast\Bool_::class, |
66 | 66 | ], |
@@ -120,6 +120,10 @@ public function transform(Expr $input, Expr $target, PropertyMetadata $propertyM |
120 | 120 | return [$this->$castMethod($input), []]; |
121 | 121 | } |
122 | 122 |
|
| 123 | + if (!class_exists($castMethod)) { |
| 124 | + continue; |
| 125 | + } |
| 126 | + |
123 | 127 | /* |
124 | 128 | * Use the cast expression find in the cast matrix |
125 | 129 | * |
@@ -156,6 +160,11 @@ private function toArray(Expr $input): Expr |
156 | 160 | return new Expr\Array_([create_expr_array_item($input)]); |
157 | 161 | } |
158 | 162 |
|
| 163 | + private function toFloat(Expr $input): Expr |
| 164 | + { |
| 165 | + return new Cast\Double($input, ['kind' => Cast\Double::KIND_FLOAT]); |
| 166 | + } |
| 167 | + |
159 | 168 | private function fromIteratorToArray(Expr $input): Expr |
160 | 169 | { |
161 | 170 | return new Expr\FuncCall(new Name('iterator_to_array'), [ |
|
0 commit comments