phpstan / phpstan-phpunit

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

Detect invalid phpunit `@dataProvider` #211

Open staabm opened 1 month ago

staabm commented 1 month ago

Feature request

we should error about dataProvider annotations without a corresponding method

https://phpstan.org/r/9870d218-28c5-4636-88e9-85f73ce78bc9

Did PHPStan help you today? Did it make you happy in any way?

No response

ruudk commented 1 month ago

Why doesn't PHPUnit warn / error about this?

staabm commented 1 month ago

it does:

➜  phpstan-phpunit git:(2.0.x) ✗ vendor/bin/phpunit test.php
PHPUnit 9.6.16 by Sebastian Bergmann and contributors.

Warning:       No code coverage driver available

E                                                                   1 / 1 (100%)

Time: 00:00.002, Memory: 6.00 MB

There was 1 error:

1) Error
The data provider specified for test::testTrim is invalid.
PHPUnit\Util\Exception: Method test::wrongDataProvider() does not exist

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.