Skip to content

[DependencyInjection] Cover adding dependency into existing constructor - #1061

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-add-promo-fixture
Aug 29, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-add-promo-fixture

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Adds a fixture for GetBySymfonyStringToConstructorInjectionRector covering the case where the class already has a constructor with a promoted param - the new dependency is appended to it instead of a fresh constructor being created.

This edge previously lived only in rector-src tests/Issues/AddClassDependency; moving it next to the rule where it belongs.

 final class StickWithConstructor extends Controller
 {
     public function __construct(
-        private readonly EventDispatcherInterface $eventDispatcher,
+        private readonly EventDispatcherInterface $eventDispatcher, private readonly \Symfony\Component\Validator\Validator\ValidatorInterface $validator,
     ) {
     }

     public function configure()
     {
-        $someType = $this->get('validator');
+        $someType = $this->validator;
     }
 }

@TomasVotruba
TomasVotruba merged commit 6ffbf70 into main Aug 29, 2026
7 checks passed
@TomasVotruba
TomasVotruba deleted the tv-add-promo-fixture branch August 29, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant