Skip to content

Commit 1075c68

Browse files
committed
test null coerce to int
1 parent ef89f51 commit 1075c68

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,24 @@ public function doBar(): void
238238
}
239239
}
240240

241+
class FooNullableIntString
242+
{
243+
244+
public string $foo;
245+
246+
public function doFoo(?int $b): void
247+
{
248+
$this->foo = $b;
249+
assertType('string', $this->foo); // could be numeric-string
250+
}
251+
252+
public function doBar(): void
253+
{
254+
$this->foo = null;
255+
assertType('*NEVER*', $this->foo); // null cannot be coerced to string, see https://3v4l.org/5k1Dl
256+
}
257+
}
258+
241259
class FooFloatString
242260
{
243261

0 commit comments

Comments
 (0)