{"record":{"id":"656cedc63fbd528a","repo":"rectorphp/rector","slug":"s-rule-is-deprecated-as-the-param-type-guessed","errorCode":null,"errorMessage":"\"%s\" rule is deprecated, as the param type guessed from a single array_map() closure is vague and unreliable. Add the @param docblock manually instead","messagePattern":"\"(.+?)\" rule is deprecated, as the param type guessed from a single array_map\\(\\) closure is vague and unreliable\\. Add the @param docblock manually instead","errorType":"exception","errorClass":"ShouldNotHappenException","httpStatus":null,"severity":"error","filePath":"rules/TypeDeclarationDocblocks/Rector/ClassMethod/AddParamArrayDocblockBasedOnArrayMapRector.php","lineNumber":56,"sourceCode":"        $names = array_map(fn(string $name) => trim($name), $names);\n    }\n}\nCODE_SAMPLE\n)]);\n    }\n    /**\n     * @return array<class-string<Node>>\n     */\n    public function getNodeTypes(): array\n    {\n        return [ClassMethod::class, Function_::class];\n    }\n    /**\n     * @param ClassMethod|Function_ $node\n     */\n    public function refactor(Node $node): ?Node\n    {\n        throw new ShouldNotHappenException(sprintf('\"%s\" rule is deprecated, as the param type guessed from a single array_map() closure is vague and unreliable. Add the @param docblock manually instead', self::class));\n    }\n}\n","sourceCodeStart":38,"sourceCodeEnd":59,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/rules/TypeDeclarationDocblocks/Rector/ClassMethod/AddParamArrayDocblockBasedOnArrayMapRector.php#L38-L59","documentation":"Rector\\TypeDeclarationDocblocks\\Rector\\ClassMethod\\AddParamArrayDocblockBasedOnArrayMapRector is deprecated: refactor() throws Rector\\Exception\\ShouldNotHappenException on the first ClassMethod or Function_ node. The rule guessed a @param array<...> docblock for parameters consumed by a single array_map() closure, but a type inferred from one usage site is vague and unreliable as a contract for the whole parameter.","triggerScenarios":"The rule is still referenced in a TypeDeclarationDocblocks rule list and rector visits any method or function; refactor() throws on the first match.","commonSituations":"Enabling all TypeDeclarationDocblocks rules to raise PHPStan coverage; CI failing at the first method after a rector upgrade; leftover configs from experiments with docblock generation.","solutions":["Remove AddParamArrayDocblockBasedOnArrayMapRector from rector.php.","Write the @param docblock manually where the accepted shape is actually known (check the callers).","Prefer native param types plus explicit generics in one reviewed place over generated guesses."],"exampleFix":"// before (rector.php)\n->withRules([AddParamArrayDocblockBasedOnArrayMapRector::class])\n\n// after (rector.php) - removed; write by hand\n\n/**\n * @param array<int, string> $names\n */\npublic function upperAll(array $names): array","handlingStrategy":"validation","validationCode":"use Rector\\TypeDeclarationDocblocks\\Rector\\ClassMethod\\AddParamArrayDocblockBasedOnArrayMapRector;\n\n$rules = [/* your list */ AddParamArrayDocblockBasedOnArrayMapRector::class];\nif (in_array(AddParamArrayDocblockBasedOnArrayMapRector::class, $rules, true)) {\n    throw new InvalidArgumentException('Rule deprecated; write the @param docblock manually after checking callers');\n}","typeGuard":null,"tryCatchPattern":"try {\n    exit($rectorApplication->run());\n} catch (\\Rector\\Exception\\ShouldNotHappenException $e) {\n    if (str_contains($e->getMessage(), 'AddParamArrayDocblockBasedOnArrayMapRector')) {\n        fwrite(STDERR, 'Remove the rule; a type guessed from one usage site is not a contract.' . PHP_EOL);\n        exit(1);\n    }\n    throw $e;\n}","preventionTips":["Derive @param shapes from actual callers (PHPStan), not from one array_map usage.","Keep docblock rules to a reviewed subset; the docblock-generation family was largely deprecated.","Grep rector.php for 'TypeDeclarationDocblocks' after upgrades and diff against current docs."],"tags":["rector","php","docblock","param","array-map","deprecated-rule"],"backgroundTag":"deprecated-api-invoked","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}