From e5d2a8a8414b3c6336d07cdf3a55fc5b3cf3df12 Mon Sep 17 00:00:00 2001 From: Marc Reichel Date: Thu, 19 Feb 2026 10:58:15 +0100 Subject: [PATCH] fix: Skip attribute decorated parameters in `RemoveParentDelegatingConstructorRector` - Closes rectorphp/rector#9658 --- .../skip_attribute_decorated_args.php.inc | 14 ++++++++++++++ ...RemoveParentDelegatingConstructorRector.php | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector/Fixture/skip_attribute_decorated_args.php.inc diff --git a/rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector/Fixture/skip_attribute_decorated_args.php.inc b/rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector/Fixture/skip_attribute_decorated_args.php.inc new file mode 100644 index 00000000000..4e192c6932c --- /dev/null +++ b/rules-tests/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector/Fixture/skip_attribute_decorated_args.php.inc @@ -0,0 +1,14 @@ +doAttributeDecoratedParametersExist($node)) { + return null; + } + return NodeVisitor::REMOVE_NODE; } @@ -291,4 +295,18 @@ private function isDifferentDefaultValue( return false; } + + private function doAttributeDecoratedParametersExist(ClassMethod $classMethod): bool + { + $constructorParams = $classMethod->getParams(); + foreach ($constructorParams as $constructorParam) { + foreach ($constructorParam->attrGroups as $attrGroup) { + if ($attrGroup->attrs !== []) { + return true; + } + } + } + + return false; + } }