Usage of assertFileDoesNotExist
#10234
-
I'm in a project where we use phpstan version 1.10.46 as our static analysis tool along with PHP 8.1. I'm working to bump phpunit from version 9 to 10.4, and it seems like phpstan is trying to overwrite a final method as the error says:
And I'm just wondering if this is something that needs a fix or if I am suposed to only use phpunit ^9 for my custom rules (or if I am doing something wrong). I searched if this is an issue that is already addressed, but I found nothing. I have no snnipets to provide as example because actually in our tests we don't use this method 🤔 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
PHPStan supports PHPUnit 10 for testing. The reason why you have this error (and why no one reported this problem even when PHPUnit 10 has been released a long time ago) is because LevelsTestCase class is internal to PHPStan and you're not supposed to use it. This is described in Backward Compatibility Promise: https://phpstan.org/developing-extensions/backward-compatibility-promise This is how custom rules are supposed to be tested: https://phpstan.org/developing-extensions/testing When you analyse the impacted file by PHPStan, it should warn you that you're extending an unsupported class. Can you confirm your code uses LevelsTestCase but should not? Thanks. |
Beta Was this translation helpful? Give feedback.
Oh, my bad, I just realized that LevelsTestCase is covered by BC promise and should be fixed, sorry for the misinformation 😊
But please be aware that testing through RuleTestCase results in much faster tests, so please consider that. Thank you.