{"record":{"id":"844c3507382e0491","repo":"rectorphp/rector","slug":"s-is-deprecated-as-noisy-change-with-little-val","errorCode":null,"errorMessage":"\"%s\" is deprecated as noisy change with little value. Use manually or custom rule where needed instead","messagePattern":"\"(.+?)\" is deprecated as noisy change with little value\\. Use manually or custom rule where needed instead","errorType":"exception","errorClass":"ShouldNotHappenException","httpStatus":null,"severity":"error","filePath":"rules/CodingStyle/Rector/ArrowFunction/StaticArrowFunctionRector.php","lineNumber":40,"sourceCode":"CODE_SAMPLE\n, <<<'CODE_SAMPLE'\nstatic fn (): string => 'test';\nCODE_SAMPLE\n)]);\n    }\n    /**\n     * @return array<class-string<Node>>\n     */\n    public function getNodeTypes(): array\n    {\n        return [ArrowFunction::class];\n    }\n    /**\n     * @param ArrowFunction $node\n     */\n    public function refactor(Node $node): ?Node\n    {\n        throw new ShouldNotHappenException(sprintf('\"%s\" is deprecated as noisy change with little value. Use manually or custom rule where needed instead', self::class));\n    }\n}\n","sourceCodeStart":22,"sourceCodeEnd":43,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/rules/CodingStyle/Rector/ArrowFunction/StaticArrowFunctionRector.php#L22-L43","documentation":"StaticArrowFunctionRector used to prepend static to arrow functions (fn () => ... -> static fn () => ...) as a micro-optimisation preventing unwanted $this binding. It is deprecated as a noisy change with little value — it touches hundreds of call sites for a marginal, often irrelevant gain. refactor() now throws ShouldNotHappenException for every ArrowFunction node; the rule exists only to fail stale configs.","triggerScenarios":"Registering rules/CodingStyle/Rector/ArrowFunction/StaticArrowFunctionRector.php and running process/dry-run over any file containing a fn () => ... arrow function (PHP 7.4+ codebases). The throw fires at rules/CodingStyle/Rector/ArrowFunction/StaticArrowFunctionRector.php:40.","commonSituations":"Configs importing the CodingStyle set or listing this rule individually, carried into a newer Rector version where the rule was deprecated. Projects that adopted fn everywhere then upgraded rector/rector-prefixed crash on the first arrow function Rector visits.","solutions":["Remove StaticArrowFunctionRector::class from rector.php / imported sets and re-run dry-run","Add static to the few arrow functions that are actually hot paths or leak-prone (event listeners, callbacks stored long-term), manually","If you want blanket static closures, use PHP-CS-Fixer's static_lambda fixer instead of Rector","Check for the rule name in any shared set package your config pulls in"],"exampleFix":"// before (rector.php)\n->withRules([\n    \\Rector\\CodingStyle\\Rector\\ArrowFunction\\StaticArrowFunctionRector::class,\n])\n\n// after\n// rule removed; add static selectively by hand:\n$callback = static fn (int $n): int => $n * 2; // only where binding must be prevented","handlingStrategy":"validation","validationCode":"$deprecated = ['StaticArrowFunctionRector'];\nforeach (glob(__DIR__ . '/rector*.php') as $config) {\n    $src = file_get_contents($config);\n    foreach ($deprecated as $rule) {\n        if (str_contains($src, $rule)) {\n            fwrite(STDERR, \"Remove deprecated rule {$rule} from {$config}\\n\");\n            exit(1);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enforce blanket 'static' style with PHP-CS-Fixer static_lambda, not Rector","Add static manually only to closures/arrow functions that must not bind $this","Remove deprecated rules from config before upgrading rector/rector-prefixed","Run a dry-run fixture in CI to catch tombstone rules immediately"],"tags":["rector","php","deprecated-rule","arrow-function","static","micro-optimisation"],"backgroundTag":"rector-deprecated-rule","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}