{"record":{"id":"34be8be9d164cf9b","repo":"rectorphp/rector","slug":"s-is-deprecated-as-risky-change-with-little-val","errorCode":null,"errorMessage":"\"%s\" is deprecated as risky change with little value. Use manually or custom rule where needed instead","messagePattern":"\"(.+?)\" is deprecated as risky change with little value\\. Use manually or custom rule where needed instead","errorType":"exception","errorClass":"ShouldNotHappenException","httpStatus":null,"severity":"error","filePath":"rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php","lineNumber":72,"sourceCode":"        return (new Something)->doWork();\n    }\n}\nCODE_SAMPLE\n)]);\n    }\n    /**\n     * @return array<class-string<Node>>\n     */\n    public function getNodeTypes(): array\n    {\n        return [StaticCall::class];\n    }\n    /**\n     * @param StaticCall $node\n     */\n    public function refactor(Node $node): ?Node\n    {\n        throw new ShouldNotHappenException(sprintf('\"%s\" is deprecated as risky change with little value. Use manually or custom rule where needed instead', self::class));\n    }\n}\n","sourceCodeStart":54,"sourceCodeEnd":75,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php#L54-L75","documentation":"This ShouldNotHappenException is thrown when the deprecated StaticCallOnNonStaticToInstanceCallRector actually runs. The rule used to rewrite `ClassName::nonStaticMethod()` calls into instance calls, but that was deemed a risky change with little value; the class remains (implementing DeprecatedInterface) only so stale configs fail loudly. Its refactor() throws unconditionally on the first StaticCall node visited.","triggerScenarios":"Running `rector process` with a config that still registers `\\Rector\\Php70\\Rector\\StaticCall\\StaticCallOnNonStaticToInstanceCallRector::class` (or an old Php70 rule list that included it). getNodeTypes() returns [StaticCall::class], so the exception fires as soon as Rector visits any static call in the analyzed code — no particular PHP version of the target code matters beyond the rule being loaded.","commonSituations":"Upgrading rector/rector across major versions while keeping an enumerated rule list from the PHP 5.6-to-7 migration era; inheriting a config that itemized Php70 rules; CI breaking after a routine `composer update` because the rule now throws instead of refactoring.","solutions":["Remove the `StaticCallOnNonStaticToInstanceCallRector::class` registration from rector.php/rector.yml and re-run.","Audit the config for other deprecated rules (EarlyReturn rules, other removed Php70 rules) and remove them in the same pass.","If you need that rewrite, do it manually or in a project-local custom rule — as the exception message itself advises.","Short-term stopgap: pin the last Rector version where this rule still performed the transformation."],"exampleFix":"// before - rector.php\n$rectorConfig->rule(\\Rector\\Php70\\Rector\\StaticCall\\StaticCallOnNonStaticToInstanceCallRector::class);\n\n// after - registration removed; convert static-call-on-instance manually\n// $obj = new ClassName(); $obj->method();","handlingStrategy":"validation","validationCode":"$config = file_get_contents('rector.php');\nif (strpos($config, 'StaticCallOnNonStaticToInstanceCallRector') !== false) {\n    exit(\"Remove deprecated StaticCallOnNonStaticToInstanceCallRector from rector.php before running rector.\\n\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer version level sets over individually registered Php70 rules so deprecated rules disappear on upgrade.","On every rector major upgrade, grep rector.php for rule classes flagged DeprecatedInterface in the changelog and delete them.","Keep a smoke-test directory and run rector against it right after upgrading, so stale registrations fail in seconds, not mid-CI."],"tags":["rector","php","deprecated-rule","static-call","config"],"backgroundTag":"deprecated-api-invoked","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}