{"record":{"id":"92df54b7aa3cdc60","repo":"rectorphp/rector","slug":"s-is-deprecated-as-risky-change-that-does-not-h","errorCode":null,"errorMessage":"\"%s\" is deprecated as risky change that does not handle enum usage across the whole context. Handle it via IDE with full context, manually, or a custom rule instead","messagePattern":"\"(.+?)\" is deprecated as risky change that does not handle enum usage across the whole context\\. Handle it via IDE with full context, manually, or a custom rule instead","errorType":"exception","errorClass":"ShouldNotHappenException","httpStatus":null,"severity":"error","filePath":"rules/CodingStyle/Rector/Enum_/EnumCaseToPascalCaseRector.php","lineNumber":50,"sourceCode":"{\n    case Pending;\n    case Published;\n    case InReview;\n    case WaitingForApproval;\n}\nCODE_SAMPLE\n)]);\n    }\n    public function getNodeTypes(): array\n    {\n        return [Enum_::class, ClassConstFetch::class];\n    }\n    /**\n     * @param Enum_|ClassConstFetch $node\n     */\n    public function refactor(Node $node): ?Node\n    {\n        throw new ShouldNotHappenException(sprintf('\"%s\" is deprecated as risky change that does not handle enum usage across the whole context. Handle it via IDE with full context, manually, or a custom rule instead', self::class));\n    }\n}\n","sourceCodeStart":32,"sourceCodeEnd":53,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/rules/CodingStyle/Rector/Enum_/EnumCaseToPascalCaseRector.php#L32-L53","documentation":"EnumCaseToPascalCaseRector used to rename enum cases and their usages to PascalCase. It is deprecated because the rename is risky when done by a rule that sees one file at a time — enum cases are referenced via Case-sensitive ::class-style fetches across the whole project, and Rector's file-local view cannot guarantee a complete, consistent rename. refactor() now throws ShouldNotHappenException on Enum_ and ClassConstFetch nodes; the rule does nothing but abort.","triggerScenarios":"Registering rules/CodingStyle/Rector/Enum_/EnumCaseToPascalCaseRector.php and running rector over any file containing an enum declaration or a ClassConstFetch (any Foo::BAR constant/case access — extremely common). The throw fires at rules/CodingStyle/Rector/Enum_/EnumCaseToPascalCaseRector.php:50.","commonSituations":"Projects with snake_case enum cases (e.g. status enums like case in_progress) registered this rule to normalise naming, then upgraded rector/rector-prefixed and hit the guard. Because ClassConstFetch matches constant access everywhere, the crash triggers on nearly the first file analysed.","solutions":["Remove EnumCaseToPascalCaseRector::class from rector.php / imported sets and re-run vendor/bin/rector dry-run","Rename enum cases in your IDE with full-project rename (Refactor -> Rename Symbol), which updates every usage safely","If automation is required, write a custom rule that loads references project-wide, or run the rename in a dedicated commit verified by tests","Audit shared set bundles for the deprecated rule name"],"exampleFix":"// before (rector.php)\n->withRules([\n    \\Rector\\CodingStyle\\Rector\\Enum_\\EnumCaseToPascalCaseRector::class,\n]);\n// code:\nenum Status {\n    case in_progress;\n}\n\n// after (rector.php)\n// rule removed; renamed via IDE full-project rename:\nenum Status {\n    case InProgress;\n}\n// all Status::in_progress references updated to Status::InProgress by the IDE","handlingStrategy":"validation","validationCode":"$deprecated = ['EnumCaseToPascalCaseRector'];\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":["Rename symbols with IDE project-wide refactor, never a file-local rule","Decide enum case naming (PascalCase vs snake_case) before the first enum lands, in a coding standard","Run tests after any enum rename to catch missed case references","Remove deprecated rules from config on every Rector upgrade"],"tags":["rector","php","deprecated-rule","enum","rename","ide-refactor"],"backgroundTag":"rector-deprecated-rule","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}