Skip to content

Commit 3bf7dd1

Browse files
committed
more precise floats
1 parent 4ca2d17 commit 3bf7dd1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Type/FloatType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function toArrayKey(): Type
146146
public function toCoercedArgumentType(bool $strictTypes): Type
147147
{
148148
if (!$strictTypes) {
149-
return TypeCombinator::union(new IntegerType(), new FloatType(), new StringType(), new BooleanType());
149+
return TypeCombinator::union($this->toInteger(), $this, $this->toString(), $this->toBoolean());
150150
}
151151

152152
return $this;

tests/PHPStan/Analyser/nsrt/bug-12393b.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ class FooFloatString
268268
public function doFoo(float $b): void
269269
{
270270
$this->foo = $b;
271-
assertType('string', $this->foo); // could be numeric-string
271+
assertType('numeric-string&uppercase-string', $this->foo);
272272
}
273273

274274
public function doBar(): void
275275
{
276276
$this->foo = 1.0;
277-
assertType('string', $this->foo); // could be numeric-string
277+
assertType("'1'", $this->foo);
278278
}
279279
}
280280

@@ -304,7 +304,7 @@ class FooNumericToString
304304
public function doFoo(float|int $b): void
305305
{
306306
$this->foo = $b;
307-
assertType('string', $this->foo); // could be numeric-string
307+
assertType('numeric-string&uppercase-string', $this->foo);
308308
}
309309

310310
}

0 commit comments

Comments
 (0)