Skip to content

[TypeDeclarationDocblocks] Deprecate 3 data provider docblock rules - #8235

Merged
TomasVotruba merged 2 commits into
mainfrom
deprecate-data-provider-return-docblock
Jul 30, 2026
Merged

[TypeDeclarationDocblocks] Deprecate 3 data provider docblock rules#8235
TomasVotruba merged 2 commits into
mainfrom
deprecate-data-provider-return-docblock

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Jul 30, 2026

Copy link
Copy Markdown
Member

Data provider docblock typing is not relevant to code quality. It increases maintenance cost and decreases readability of the test class.

Deprecated rules:

  • AddReturnArrayDocblockFromDataProviderParamRector
  • AddReturnDocblockDataProviderRector
  • AddParamArrayDocblockFromDataProviderRector

All three now implement DeprecatedInterface, so registering them prints a deprecation warning; refactor() throws. Tests and fixtures are removed.

The last two were part of TypeDeclarationDocblocksLevel and are dropped from it. The first was in no set.

What the rules used to do:

 final class SomeTest extends TestCase
 {
+    /**
+     * @param string[] $names
+     */
     #[DataProvider('provideNames')]
     public function test(array $names)
     {
     }

+    /**
+     * @return array<array<string>>
+     */
     public static function provideNames(): array
     {
         return [[['John', 'Jane']]];
     }
 }

Native type rules on data providers stay untouched: ReturnIteratorInDataProviderRector and AddParamTypeBasedOnPHPUnitDataProviderRector.

…oviderParamRector

Data provider docblock typing is not relevant to code quality. It adds
maintenance cost and lowers readability of the test class.
…tor and AddParamArrayDocblockFromDataProviderRector

Same reasoning as the data provider return docblock rule: docblock typing of
data providers is not relevant to code quality, costs maintenance and lowers
readability. Both rules are removed from the TypeDeclarationDocblocks level.
@TomasVotruba TomasVotruba changed the title [TypeDeclarationDocblocks] Deprecate AddReturnArrayDocblockFromDataProviderParamRector [TypeDeclarationDocblocks] Deprecate 3 data provider docblock rules Jul 30, 2026
@TomasVotruba
TomasVotruba merged commit 8b14eaa into main Jul 30, 2026
65 checks passed
@TomasVotruba
TomasVotruba deleted the deprecate-data-provider-return-docblock branch July 30, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant