Non-static data providers are deprecated since PHPUnit 10.0. To assist T332865: PHPUnit data providers should be simple static functions that return plain data the CodeSniffer could detect non-static data providers in PHPUnit tests and auto-fix simple cases and possible report not so simple cases.
- PHPUnit files are detected by PHPUnitTestTrait::isTestFile already in CodeSniffer.
- Data providers are detect already by CodeSniffer with the naming /^provide|Provider$/.
This functions should be required to be static to increase the performance of PHPUnit on collecting all test cases. This is helpful when using --filter option.
Simple cases for auto-fix means in this case:
- The provider only creates array(s) and is using strings or scalar in it.
- Keep use of constant also as simple.
- Only static calls in the provider (the StaticClosureSniff has some detection of a "static context", maybe it can be reused)
- static closures or anon classes are okay
- ...