1111use CuyZ \Valinor \Mapper \Tree \Exception \UnresolvableShellType ;
1212use CuyZ \Valinor \Mapper \Tree \Message \Message ;
1313use CuyZ \Valinor \Type \Dumper \TypeDumper ;
14- use CuyZ \Valinor \Type \FloatType ;
1514use CuyZ \Valinor \Type \Type ;
1615use CuyZ \Valinor \Type \Types \UnionType ;
1716use CuyZ \Valinor \Type \Types \UnresolvableType ;
2221use function array_map ;
2322use function assert ;
2423use function implode ;
25- use function is_int ;
2624
2725/** @internal */
2826final class Shell
@@ -54,9 +52,7 @@ public function __construct(
5452 private array $ nameMap = [],
5553 /** @var array<string, null> */
5654 private array $ childrenWithScalarValueCasting = [],
57- ) {
58- $ this ->castFloatValue ();
59- }
55+ ) {}
6056
6157 public function build (): Node
6258 {
@@ -119,8 +115,6 @@ public function withType(Type $newType): self
119115 $ self = clone $ this ;
120116 $ self ->type = $ newType ;
121117
122- $ self ->castFloatValue ();
123-
124118 return $ self ;
125119 }
126120
@@ -131,8 +125,6 @@ public function withValue(mixed $newValue): self
131125 $ self ->value = $ newValue ;
132126 $ self ->hasValue = true ;
133127
134- $ self ->castFloatValue ();
135-
136128 return $ self ;
137129 }
138130
@@ -236,15 +228,4 @@ public function dumpValue(): string
236228 {
237229 return $ this ->hasValue ? ValueDumper::dump ($ this ->value ) : '*missing* ' ;
238230 }
239-
240- private function castFloatValue (): void
241- {
242- // When the value is an integer and the type is a float, the value is
243- // cast to float, to follow the rule of PHP regarding acceptance of an
244- // integer value in a float type. Note that PHPStan/Psalm analysis
245- // applies the same rule.
246- if ($ this ->type instanceof FloatType && is_int ($ this ->value )) {
247- $ this ->value = (float )$ this ->value ;
248- }
249- }
250231}
0 commit comments