phpstan / phpstan-phpunit

PHPUnit extensions and rules for PHPStan
MIT License
468 stars 46 forks source link

Static dataProviders are detected as unused #188

Closed pascalheidmann closed 1 year ago

pascalheidmann commented 1 year ago

We are using phpunit 9.6 and are preparing for migrating to phpunit 10 which wants its dataProviders to be static. Gladly phpunit supports static dataProviders already in 9.6 (or even longer?). Sadly phpstan is now detecting those dataProviders as unused.

ondrejmirtes commented 1 year ago

Data provider can't be private.

pascalheidmann commented 1 year ago

@ondrejmirtes not sure about this. We are having several private dataProviders and tests are running fine. But also PHPUnit 9.6 so not sure about phpunit 10.

ondrejmirtes commented 1 year ago

See: https://github.com/sebastianbergmann/phpunit/issues/5115

PHPUnit documentation states (https://docs.phpunit.de/en/10.1/writing-tests-for-phpunit.html#data-providers) - even in older versions:

A data provider method must be public

github-actions[bot] commented 1 year ago

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.