phpstan-phpunit icon indicating copy to clipboard operation
phpstan-phpunit copied to clipboard

Allow defining a target PHPUnit version

Open mondrake opened this issue 1 year ago • 3 comments

For large codebases (I'm looking into Drupal), it would be good to be able to define a target PHPUnit version, so that checks for later versions could be anticipated while still running previous PHPUnit versions. This would allow to do the prep work in batches - you baseline whatever is expected to be changed for the new version and break down the cleanup in multiple steps.

Example: https://github.com/phpstan/phpstan-phpunit/commit/cd9c6938f8bbfcb6da3ed5a3c7ea60873825d088 will report non-static data providers only when PHPUnit 10 is running. But we might want to have the rule enabled while the test codebase is still running PHPUnit 9.

mondrake avatar Apr 16 '23 13:04 mondrake

I can see benefit in this (for both Drupal and other projects).

It would make it possible to "be ahead of the game" instead of making a big rush when changing PHPUnit versions on a project.

Boegie avatar Apr 16 '23 13:04 Boegie

You can add a CI job (with failure allowed) that upgrades PHPUnit and then runs PHPStan, to let you see “into the future”.

ondrejmirtes avatar Apr 16 '23 13:04 ondrejmirtes

And for those using https://github.com/Yoast/PHPUnit-Polyfills it gets trickier.

fredericgboutin-yapla avatar May 15 '24 22:05 fredericgboutin-yapla