diff --git a/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Fixture/do_not_replace_variable_assign.php.inc b/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Fixture/do_not_replace_variable_assign.php.inc new file mode 100644 index 00000000..b9d72708 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector/Fixture/do_not_replace_variable_assign.php.inc @@ -0,0 +1,38 @@ +modify($logger); + } +} + +?> +----- +modify($this->logger); + } +} + +?> \ No newline at end of file diff --git a/rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php b/rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php index 2b42824b..0e7b6bd9 100644 --- a/rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php +++ b/rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php @@ -14,6 +14,7 @@ use PhpParser\Node\Stmt\ClassMethod; use Rector\Doctrine\NodeAnalyzer\AttributeFinder; use Rector\NodeManipulator\ClassDependencyManipulator; +use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PhpParser\Node\Value\ValueResolver; use Rector\PostRector\ValueObject\PropertyMetadata; use Rector\Rector\AbstractRector; @@ -190,7 +191,10 @@ public function refactor(Node $node): ?Node if (! $this->isNames($node, $paramNamesToReplace)) { return null; + } + if ($node->getAttribute(AttributeKey::IS_BEING_ASSIGNED) === true) { + return null; } $propertyName = $this->getName($node);