diff --git a/src/Rector/Property/InjectAnnotationClassRector.php b/src/Rector/Property/InjectAnnotationClassRector.php index fccd06c72aed..04f80439bc29 100644 --- a/src/Rector/Property/InjectAnnotationClassRector.php +++ b/src/Rector/Property/InjectAnnotationClassRector.php @@ -195,9 +195,6 @@ private function refactorPropertyWithAnnotation(Property $property, string $anno $this->docBlockManipulator->removeTagFromNode($property, $annotationClass); - // set to private - $property->flags = Class_::MODIFIER_PRIVATE; - $classNode = $property->getAttribute(AttributeKey::CLASS_NODE); if (! $classNode instanceof Class_) { throw new ShouldNotHappenException(); diff --git a/tests/Rector/Property/InjectAnnotationClassRector/Fixture/fixture4.php.inc b/tests/Rector/Property/InjectAnnotationClassRector/Fixture/fixture4.php.inc index e9d99c787a8c..346f23119224 100644 --- a/tests/Rector/Property/InjectAnnotationClassRector/Fixture/fixture4.php.inc +++ b/tests/Rector/Property/InjectAnnotationClassRector/Fixture/fixture4.php.inc @@ -25,7 +25,7 @@ class ClassWithPublicInjects /** * @var \Rector\Symfony\Tests\Rector\FrameworkBundle\AbstractToConstructorInjectionRectorSource\SomeTranslatorInterface */ - private $translator; + public $translator; public function __construct(\Rector\Symfony\Tests\Rector\FrameworkBundle\AbstractToConstructorInjectionRectorSource\SomeTranslatorInterface $translator) { $this->translator = $translator; diff --git a/tests/Rector/Property/InjectAnnotationClassRector/Fixture/inject_from_var2.php.inc b/tests/Rector/Property/InjectAnnotationClassRector/Fixture/inject_from_var2.php.inc new file mode 100644 index 000000000000..a114d2487f79 --- /dev/null +++ b/tests/Rector/Property/InjectAnnotationClassRector/Fixture/inject_from_var2.php.inc @@ -0,0 +1,32 @@ + +----- +someDependency = $someDependency; + } +} + +?> diff --git a/tests/Rector/Property/InjectAnnotationClassRector/InjectAnnotationClassRectorTest.php b/tests/Rector/Property/InjectAnnotationClassRector/InjectAnnotationClassRectorTest.php index 8a1f979c8216..80f9e2b89e50 100644 --- a/tests/Rector/Property/InjectAnnotationClassRector/InjectAnnotationClassRectorTest.php +++ b/tests/Rector/Property/InjectAnnotationClassRector/InjectAnnotationClassRectorTest.php @@ -28,6 +28,7 @@ public function test(): void __DIR__ . '/Fixture/fixture4.php.inc', __DIR__ . '/Fixture/fixture5.php.inc', __DIR__ . '/Fixture/inject_from_var.php.inc', + __DIR__ . '/Fixture/inject_from_var2.php.inc', ]); }