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
We used a mixed type declarations on a parameter which is only available since PHP 8.
Testing this code with the highest phpstan level and running on PHP 7.4 did not report this as error.
But it should IMO as PHP 7.4 treated the mixed type as a class name which does not exist in the current namespace.
This will be solved in PHPStan 2.0 being released at some point in 2024, thanks to upgrade to nikic/php-parser 5.0. From the upgrade guide:
Type hints are interpreted as a class Name or as a built-in Identifier depending on PHP version, for example int is treated as a class name on PHP 5.6 and as a built-in on PHP 7.0.
@@ @@-No errors+PHP 8.0+==========++No errors++PHP 7.1 – 7.4 (1 error)+==========++5: Parameter $param of method HelloWorld::test() has invalid type mixed.
@@ @@-No errors+PHP 8.0+==========++No errors++PHP 7.1 – 7.4 (3 errors)+==========++5: Method HelloWorld::test() has invalid return type mixed.+5: Parameter $param of method HelloWorld::test() has invalid type mixed.+7: Method HelloWorld::test() should return mixed but returns string.
Bug report
We used a
mixed
type declarations on a parameter which is only available since PHP 8.Testing this code with the highest phpstan level and running on PHP 7.4 did not report this as error.
But it should IMO as PHP 7.4 treated the mixed type as a class name which does not exist in the current namespace.
Code snippet that reproduces the problem
https://phpstan.org/r/6c15ac7b-d3c3-4d30-8df6-268c30ac4666
Expected output
Testing this with PHP 7.4 should show an error that mixed does not exist/is not available.
Did PHPStan help you today? Did it make you happy in any way?
Wasn't helpful today but certainly on other days ;)
The text was updated successfully, but these errors were encountered: