Possibility to separate PHP 8 problems from others #5265
-
|
Fantastic job with PHPStan! The Drupal community is using it so much including people with site builds detecting outdated code for themselves. We are now looking at expanding our use for PHP 8 incompatibility detection on PHP 7 based on capabilities PHPStan introduced in https://github.com/phpstan/phpstan/releases/tag/0.12.33 Our issue at https://www.drupal.org/project/upgrade_status/issues/3218290 is part of a bigger system, but all that is relevant from the complexity of that IMHO for here is that we have this test code that we attempt to get PHP 8 incompatibility issues found from: All three lines of this function should produce some PHP 8 incompatibility error. We found that running on
We are not getting a problem for define() even though defining as case insensitive is not supported in PHP 8. Also the error reported for array_key_exists() is not correct. PHP 8 migration guide at https://www.php.net/manual/en/migration80.incompatible.php says "The ability to use array_key_exists() with objects has been removed.". So its not that it will return false. We are also getting unrelated reports, like
Yeah the code does not do anything useful, we could make it more realistic, but as a general principle, we are trying to find PHP 8 incompatibility issues, not general code quality issues. Is there a way to be able to identify these ones from the result set or based on some internal list that we can build off of? I am completely fine to build some augmentation to phpstan to do it myself, not that you would need to do it :) Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Hi, the Otherwise you could find some success in running PHPStan with |
Beta Was this translation helpful? Give feedback.
Hi, the
define()call does not get picked up by PHPStan because no one has implemented a rule that would detect this. Feel free to contribute it :)Otherwise you could find some success in running PHPStan with
phpVersion: 70400, generating the baseline and re-running PHPStan withphpVersion: 80000. Only new problems stemming from the changed PHP version would be reported, achieving the result you want.