{"record":{"id":"5dcf6f34a3876cf8","repo":"rectorphp/rector","slug":"s-is-deprecated-as-it-has-no-real-value","errorCode":null,"errorMessage":"\"%s\" is deprecated as it has no real value","messagePattern":"\"(.+?)\" is deprecated as it has no real value","errorType":"exception","errorClass":"ShouldNotHappenException","httpStatus":null,"severity":"error","filePath":"rules/DeadCode/Rector/ClassLike/RemoveTypedPropertyNonMockDocblockRector.php","lineNumber":52,"sourceCode":"use PHPUnit\\Framework\\MockObject\\MockObject;\n\nfinal class SomeTest extends TestCase\n{\n    private SomeClass $someProperty;\n}\nCODE_SAMPLE\n)]);\n    }\n    public function getNodeTypes(): array\n    {\n        return [Class_::class];\n    }\n    /**\n     * @param Class_ $node\n     */\n    public function refactor(Node $node): ?Node\n    {\n        throw new ShouldNotHappenException(sprintf('\"%s\" is deprecated as it has no real value', self::class));\n    }\n}\n","sourceCodeStart":34,"sourceCodeEnd":55,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/rules/DeadCode/Rector/ClassLike/RemoveTypedPropertyNonMockDocblockRector.php#L34-L55","documentation":"RemoveTypedPropertyNonMockDocblockRector used to remove docblocks like @var MockObject|MyClass duplicated on typed properties where the native type already carries the information. It is deprecated because the cleanup has no real value — modern tooling reads native types, and the rule's heuristic added churn without benefit. refactor() now throws ShouldNotHappenException on every Class_ node; the rule does no work.","triggerScenarios":"Registering rules/DeadCode/Rector/ClassLike/RemoveTypedPropertyNonMockDocblockRector.php and running process/dry-run over any file containing a class. The throw fires at rules/DeadCode/Rector/ClassLike/RemoveTypedPropertyNonMockDocblockRector.php:52 on the first class visited — effectively the first file.","commonSituations":"Test-suite-focused configs (this rule targeted PHPUnit mock docblocks) still list it after upgrading rector/rector-prefixed. Because Class_ matches virtually every PHP file, the guard exception appears immediately and gets misreported as a broken Rector install.","solutions":["Remove RemoveTypedPropertyNonMockDocblockRector::class from rector.php and all imported set files, then re-run vendor/bin/rector dry-run","Leave redundant @var docblocks alone, or delete them opportunistically while editing each file","If you want them gone now, run a scoped one-off script or IDE cleanup on the tests directory","Check shared set bundles for lingering references to the rule name"],"exampleFix":"// before (rector.php)\n->withRules([\n    \\Rector\\DeadCode\\Rector\\ClassLike\\RemoveTypedPropertyNonMockDocblockRector::class,\n])\n// code:\nclass UserServiceTest extends TestCase {\n    /** @var UserService&MockObject */\n    private UserService $service;\n}\n\n// after (rector.php)\n// rule removed; docblock left in place (it still aids IDE/PHPStan with union info)","handlingStrategy":"validation","validationCode":"$deprecated = ['RemoveTypedPropertyNonMockDocblockRector'];\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 informative @var MockObject unions — they aid IDE and PHPStan","Remove deprecated rules from rector.php before upgrading Rector","Prefer letting docbook rot be cleaned opportunistically during code edits","Gate a dry-run in CI so tombstone registrations fail fast"],"tags":["rector","php","deprecated-rule","docblock","mock","dead-code"],"backgroundTag":"rector-deprecated-rule","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}