{"record":{"id":"533f1a73de67af43","repo":"rectorphp/rector","slug":"s-is-deprecated-as-it-produces-too-many-false-p","errorCode":null,"errorMessage":"\"%s\" is deprecated as it produces too many false positives. Add the type manually where needed instead","messagePattern":"\"(.+?)\" is deprecated as it produces too many false positives\\. Add the type manually where needed instead","errorType":"exception","errorClass":"ShouldNotHappenException","httpStatus":null,"severity":"error","filePath":"rules/TypeDeclaration/Rector/ClassMethod/StrictStringParamConcatRector.php","lineNumber":60,"sourceCode":")]);\n    }\n    /**\n     * @return array<class-string<Node>>\n     */\n    public function getNodeTypes(): array\n    {\n        return [ClassMethod::class, Function_::class, Closure::class];\n    }\n    public function provideMinPhpVersion(): int\n    {\n        return PhpVersionFeature::SCALAR_TYPES;\n    }\n    /**\n     * @param ClassMethod|Function_|Closure $node\n     */\n    public function refactor(Node $node): ?Node\n    {\n        throw new ShouldNotHappenException(sprintf('\"%s\" is deprecated as it produces too many false positives. Add the type manually where needed instead', self::class));\n    }\n}\n","sourceCodeStart":42,"sourceCodeEnd":63,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/rules/TypeDeclaration/Rector/ClassMethod/StrictStringParamConcatRector.php#L42-L63","documentation":"Rector\\TypeDeclaration\\Rector\\ClassMethod\\StrictStringParamConcatRector is deprecated: refactor() throws Rector\\Exception\\ShouldNotHappenException on the first ClassMethod, Function_ or Closure node. The rule added `string` parameter types to parameters that get concatenated with strings, but that heuristic produced too many false positives (non-string values concatenated via __toString, mixed input, casts). The rule targets PHP 7.0+ (PhpVersionFeature::SCALAR_TYPES).","triggerScenarios":"The rule is still present in rector.php and the analyzed code contains any closure, function or method; refactor() throws on the first visited node, before any type analysis happens.","commonSituations":"Old 'strict types' rector configs; CI failing immediately after a rector upgrade; codebases where the rule previously mis-typed parameters that receive int/float/Stringable values.","solutions":["Remove StrictStringParamConcatRector from rector.php.","Add `string` parameter types manually where the value really is always a string, verifying with PHPStan first.","Use phpstan level-driven type coverage reports instead of the concatenation heuristic."],"exampleFix":"// before (rector.php)\n->withRules([StrictStringParamConcatRector::class])\n\n// after (rector.php) - removed; add types by hand\n\n// before                          // after\nfunction greet($name, $suffix)     function greet(string $name, string $suffix)\n{\n    return $name . $suffix;\n}","handlingStrategy":"validation","validationCode":"use Rector\\TypeDeclaration\\Rector\\ClassMethod\\StrictStringParamConcatRector;\n\n$rules = [/* your list */ StrictStringParamConcatRector::class];\nif (in_array(StrictStringParamConcatRector::class, $rules, true)) {\n    throw new InvalidArgumentException('Rule deprecated due to false positives; add string types manually');\n}","typeGuard":null,"tryCatchPattern":"try {\n    exit($rectorApplication->run());\n} catch (\\Rector\\Exception\\ShouldNotHappenException $e) {\n    if (str_contains($e->getMessage(), 'StrictStringParamConcatRector')) {\n        fwrite(STDERR, 'Remove the rule; derive parameter types from PHPStan knowledge, not concatenation.' . PHP_EOL);\n        exit(1);\n    }\n    throw $e;\n}","preventionTips":["Add parameter types guided by PHPStan reports on call sites rather than by usage heuristics.","Watch for Stringable/int values in concatenating code before typing a param as string.","Prune deprecated TypeDeclaration rules from rector.php whenever rector is updated."],"tags":["rector","php","type-declaration","string","false-positives","deprecated-rule"],"backgroundTag":"deprecated-api-invoked","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}