From bdc4e338078ccf0337d9bdb42358f23f461aca35 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 4 Sep 2026 18:25:11 +0200 Subject: [PATCH 1/2] [DeadCode] Skip any annotation docblock in RemoveParentDelegatingClassMethodRector Fixes #9887 Claude-Session: https://claude.ai/code/session_01S1dksw9XmHtE7egqy9Yx5J --- .../Fixture/skip_annotation_docblock.php.inc | 16 +++++++++++++++ ...emoveParentDelegatingClassMethodRector.php | 20 +++++++++---------- 2 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingClassMethodRector/Fixture/skip_annotation_docblock.php.inc diff --git a/rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingClassMethodRector/Fixture/skip_annotation_docblock.php.inc b/rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingClassMethodRector/Fixture/skip_annotation_docblock.php.inc new file mode 100644 index 00000000000..eaae5156a21 --- /dev/null +++ b/rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingClassMethodRector/Fixture/skip_annotation_docblock.php.inc @@ -0,0 +1,16 @@ +phpDocInfoFactory->createFromNodeOrEmpty($classMethod); - return $phpDocInfo->hasByNames( - [ - '@param', - '@phpstan-param', - '@psalm-param', - '@return', - '@phpstan-return', - '@psalm-return', - '@deprecated', - ] - ); + // any tag or annotation (e.g. @Route, @OA\Get, @param) may carry intent the parent lacks + foreach ($phpDocInfo->getPhpDocNode()->children as $childNode) { + if ($childNode instanceof PhpDocTagNode) { + return true; + } + } + + return false; } private function matchParentMethodReflection(ClassMethod $classMethod): ?ExtendedMethodReflection From 91f5dbbfad2835e5b4401381ee1300a53e306981 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 4 Sep 2026 16:26:43 +0000 Subject: [PATCH 2/2] [ci-review] Rector Rectify --- .../RemoveParentDelegatingClassMethodRector.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingClassMethodRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingClassMethodRector.php index 66ed6eb0ca8..50ad208a46a 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingClassMethodRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingClassMethodRector.php @@ -4,6 +4,7 @@ namespace Rector\DeadCode\Rector\ClassMethod; +use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode; use PhpParser\Node; use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Expr\Variable; @@ -116,15 +117,7 @@ public function refactor(Node $node): ?int private function hasRefiningDocblock(ClassMethod $classMethod): bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); - - // any tag or annotation (e.g. @Route, @OA\Get, @param) may carry intent the parent lacks - foreach ($phpDocInfo->getPhpDocNode()->children as $childNode) { - if ($childNode instanceof PhpDocTagNode) { - return true; - } - } - - return false; + return array_any($phpDocInfo->getPhpDocNode()->children, fn(PhpDocChildNode $phpDocChildNode): bool => $phpDocChildNode instanceof PhpDocTagNode); } private function matchParentMethodReflection(ClassMethod $classMethod): ?ExtendedMethodReflection