{"record":{"id":"73e43cb7be463e4b","repo":"rectorphp/rector","slug":"s-is-deprecated-as-data-provider-docblock-typi-73e43c","errorCode":null,"errorMessage":"\"%s\" is deprecated, as data provider docblock typing is not relevant to code quality","messagePattern":"\"(.+?)\" is deprecated, as data provider docblock typing is not relevant to code quality","errorType":"exception","errorClass":"ShouldNotHappenException","httpStatus":null,"severity":"error","filePath":"rules/TypeDeclarationDocblocks/Rector/Class_/AddReturnArrayDocblockFromDataProviderParamRector.php","lineNumber":70,"sourceCode":"     */\n    public function provideNames(): array\n    {\n        return ['John', 'Jane'];\n    }\n}\nCODE_SAMPLE\n)]);\n    }\n    public function getNodeTypes(): array\n    {\n        return [Class_::class];\n    }\n    /**\n     * @param Class_ $node\n     */\n    public function refactor(Node $node): ?Node\n    {\n        throw new ShouldNotHappenException(sprintf('\"%s\" is deprecated, as data provider docblock typing is not relevant to code quality', self::class));\n    }\n}\n","sourceCodeStart":52,"sourceCodeEnd":73,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/rules/TypeDeclarationDocblocks/Rector/Class_/AddReturnArrayDocblockFromDataProviderParamRector.php#L52-L73","documentation":"Rector\\TypeDeclarationDocblocks\\Rector\\Class_\\AddReturnArrayDocblockFromDataProviderParamRector is deprecated: refactor() throws Rector\\Exception\\ShouldNotHappenException on the first Class_ node. The rule generated @return array<...> docblocks for PHPUnit data-provider methods based on the test method parameters, but data-provider typing has no bearing on production code quality, so the automation was dropped.","triggerScenarios":"The rule remains in a TypeDeclarationDocblocks rule list and rector visits any class; refactor() throws on the first Class_ node, typically the first test case scanned.","commonSituations":"'Type everything' rector configs that also covered tests; CI failing on the first test class after a rector upgrade; monorepo configs reusing an old rule list across packages.","solutions":["Remove AddReturnArrayDocblockFromDataProviderParamRector from rector.php.","Optionally document a provider's yielded shape manually where it aids reading the test.","Enforce provider conventions in test style guides, not via code generation."],"exampleFix":"// before (rector.php)\n->withRules([AddReturnArrayDocblockFromDataProviderParamRector::class])\n\n// after (rector.php) - rule removed; no replacement needed","handlingStrategy":"validation","validationCode":"use Rector\\TypeDeclarationDocblocks\\Rector\\Class_\\AddReturnArrayDocblockFromDataProviderParamRector;\n\n$rules = [/* your list */ AddReturnArrayDocblockFromDataProviderParamRector::class];\nif (in_array(AddReturnArrayDocblockFromDataProviderParamRector::class, $rules, true)) {\n    throw new InvalidArgumentException('Rule deprecated; data-provider typing is not a code-quality concern');\n}","typeGuard":null,"tryCatchPattern":"try {\n    exit($rectorApplication->run());\n} catch (\\Rector\\Exception\\ShouldNotHappenException $e) {\n    if (str_contains($e->getMessage(), 'AddReturnArrayDocblockFromDataProviderParamRector')) {\n        fwrite(STDERR, 'Remove the rule; provider return typing added churn without quality gain.' . PHP_EOL);\n        exit(1);\n    }\n    throw $e;\n}","preventionTips":["Keep test-related rector rules to structural ones (renames, dead-code), not docbook typing.","Note this rule matches Class_ nodes - it fails on the first scanned class, usually a test case.","Sweep configs for 'FromDataProvider' rule names after rector upgrades; the whole family is deprecated."],"tags":["rector","php","phpunit","data-provider","docblock","deprecated-rule"],"backgroundTag":"deprecated-api-invoked","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}