You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type is not resolvable via match and instanceof check #10843
Now it is clear that if $date is instance of HellowWorld the $a is int, otherwise it is bool. But phpstan doesn't understand that and treats $a always as int|false type.
@@ @@
No errors
-PHP 7.2 – 7.4 (1 error)+PHP 7.2 – 7.4 (2 errors)
==========
-5: Method HelloWorld::sayHello() uses native union types but they're supported only on PHP 8.0 and later.+5: Method HelloWorld::sayHello() uses native union types but they're supported only on PHP 8.0 and later.+5: Parameter $date of method HelloWorld::sayHello() has invalid type null.
Full report
PHP 8.0 – 8.3
No errors
PHP 7.2 – 7.4 (2 errors)
Line
Error
5
Method HelloWorld::sayHello() uses native union types but they're supported only on PHP 8.0 and later.
5
Parameter $date of method HelloWorld::sayHello() has invalid type null.
@@ @@
No errors
-PHP 7.2 – 7.4 (1 error)+PHP 7.2 – 7.4 (3 errors)
==========
- 5: Method HelloWorld::sayHello() uses native union types but they're supported only on PHP 8.0 and later.+ 5: Method HelloWorld::sayHello() uses native union types but they're supported only on PHP 8.0 and later.+ 5: Parameter $date of method HelloWorld::sayHello() has invalid type null.+14: Method HelloWorld::sayHello() should return int but returns int|false.
Full report
PHP 8.0 – 8.3
No errors
PHP 7.2 – 7.4 (3 errors)
Line
Error
5
Method HelloWorld::sayHello() uses native union types but they're supported only on PHP 8.0 and later.
5
Parameter $date of method HelloWorld::sayHello() has invalid type null.
14
`Method HelloWorld::sayHello() should return int but returns int
Activity
staabm commentedon Apr 6, 2024
Dumping the types reveals the PHPStan internal types and makes the bug obvious
https://phpstan.org/r/a42ff812-3bbc-40ba-b687-b7433c9002c8
phpstan-bot commentedon Sep 4, 2024
@sampsasaarela After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.0 – 8.3
No errors
PHP 7.2 – 7.4 (2 errors)
Method HelloWorld::sayHello() uses native union types but they're supported only on PHP 8.0 and later.Parameter $date of method HelloWorld::sayHello() has invalid type null.Add regression tests for related dependent type narrowing issues
phpstan-bot commentedon Apr 1, 2026
@sampsasaarela After the latest push in 2.2.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.0 – 8.3
No errors
PHP 7.2 – 7.4 (3 errors)
Method HelloWorld::sayHello() uses native union types but they're supported only on PHP 8.0 and later.Parameter $date of method HelloWorld::sayHello() has invalid type null.Updated PHPStan to commit c83300dc2b06329d1aeff2db13729c697fedae56
github-actions commentedon Jul 7, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.