{"record":{"id":"28c648215e42110e","repo":"rectorphp/rector","slug":"s-rule-is-deprecated-as-it-is-a-coding-standar-28c648","errorCode":null,"errorMessage":"\"%s\" rule is deprecated, as it is a coding standard preference with no real value","messagePattern":"\"(.+?)\" rule is deprecated, as it is a coding standard preference with no real value","errorType":"exception","errorClass":"ShouldNotHappenException","httpStatus":null,"severity":"error","filePath":"rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php","lineNumber":44,"sourceCode":"$array === [];\n$array !== [];\n$array === [];\nCODE_SAMPLE\n)]);\n    }\n    /**\n     * @return array<class-string<Node>>\n     */\n    public function getNodeTypes(): array\n    {\n        return [Identical::class];\n    }\n    /**\n     * @param Identical $node\n     */\n    public function refactor(Node $node): ?Node\n    {\n        throw new ShouldNotHappenException(sprintf('\"%s\" rule is deprecated, as it is a coding standard preference with no real value', self::class));\n    }\n}\n","sourceCodeStart":26,"sourceCodeEnd":47,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php#L26-L47","documentation":"CountArrayToEmptyArrayComparisonRector used to rewrite count($items) === 0 into $items === [] (and count($items) > 0 into $items !== []). It is deprecated because this is a coding-standard preference with no real value, and the rewritten form can be subtler about type strictness. refactor() now throws ShouldNotHappenException on every Identical (===) node; the rule no longer performs any transformation.","triggerScenarios":"Registering rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php and running rector over any file containing a === comparison. The throw fires at rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php:44 on the first identical comparison — i.e. almost immediately.","commonSituations":"Style-driven rector.php files or shared set bundles that standardised on the [] === form still list this rule after a Rector upgrade. Because === comparisons are pervasive, the first analysed file crashes, giving the false impression of an installation problem.","solutions":["Remove CountArrayToEmptyArrayComparisonRector::class from rector.php / imported sets and re-run vendor/bin/rector dry-run","Keep count($items) === 0 — it is explicit and universally understood","Rewrite individual sites by hand if your team prefers the [] comparison","grep -r CountArrayToEmptyArrayComparisonRector across configs to catch indirect imports"],"exampleFix":"// before (rector.php)\n->withRules([\n    \\Rector\\CodingStyle\\Rector\\FuncCall\\CountArrayToEmptyArrayComparisonRector::class,\n])\n// code:\nif (count($items) === 0) {\n    return;\n}\n\n// after (rector.php)\n// rule removed; manual rewrite only if preferred:\nif ($items === []) {\n    return;\n}","handlingStrategy":"validation","validationCode":"$deprecated = ['CountArrayToEmptyArrayComparisonRector'];\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":["Keep count($x) === 0 as the default idiom; treat [] === as optional taste","Move pure style preferences to PHP-CS-Fixer configuration","Delete rules upstream deprecates during each upgrade","Run rector dry-run in CI to catch stale rule registrations"],"tags":["rector","php","deprecated-rule","count","empty-check","code-style"],"backgroundTag":"rector-deprecated-rule","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}