@@ -121,21 +121,6 @@ public function process(ContainerBuilder $container)
121121$ args = [];
122122foreach ($ parametersas $ p ) {
123123/** @var \ReflectionParameter $p */
124- if (class_exists (Autowire::class) &&$ attr =$ p ->getAttributes (Autowire::class)[0 ] ??null ) {
125- $ value =$ attr ->newInstance ()->value ;
126-
127- if ($ valueinstanceof Reference) {
128- $ args [$ p ->name ] =new Reference ($ value ,$ p ->allowsNull () ? ContainerInterface::NULL_ON_INVALID_REFERENCE : ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE );
129- }else {
130- $ args [$ p ->name ] =new Reference ('.value. ' .$ container ->hash ($ value ));
131- $ container ->register ((string )$ args [$ p ->name ],'mixed ' )
132- ->setFactory ('current ' )
133- ->addArgument ([$ value ]);
134- }
135-
136- continue ;
137- }
138-
139124$ type =ltrim ($ target = (string ) ProxyHelper::getTypeHint ($ r ,$ p ),'\\' );
140125$ invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE ;
141126
@@ -164,7 +149,7 @@ public function process(ContainerBuilder $container)
164149 }
165150
166151continue ;
167- }elseif (!$ type ||! $ autowire ||'\\' !==$ target [0 ]) {
152+ }elseif (!$ autowire ||(! $ p -> getAttributes (Autowire::class) && (! $ type ||'\\' !==$ target [0 ])) ) {
168153continue ;
169154 }elseif (is_subclass_of ($ type , \UnitEnum::class)) {
170155// do not attempt to register enum typed arguments if not already present in bindings
@@ -177,6 +162,21 @@ public function process(ContainerBuilder $container)
177162continue ;
178163 }
179164
165+ if (class_exists (Autowire::class) &&$ attr =$ p ->getAttributes (Autowire::class)[0 ] ??null ) {
166+ $ value =$ attr ->newInstance ()->value ;
167+
168+ if ($ valueinstanceof Reference) {
169+ $ args [$ p ->name ] =$ type ?new TypedReference ($ value ,$ type ,$ invalidBehavior ,$ p ->name ) :new Reference ($ value ,$ invalidBehavior );
170+ }else {
171+ $ args [$ p ->name ] =new Reference ('.value. ' .$ container ->hash ($ value ));
172+ $ container ->register ((string )$ args [$ p ->name ],'mixed ' )
173+ ->setFactory ('current ' )
174+ ->addArgument ([$ value ]);
175+ }
176+
177+ continue ;
178+ }
179+
180180if ($ type && !$ p ->isOptional () && !$ p ->allowsNull () && !class_exists ($ type ) && !interface_exists ($ type ,false )) {
181181$ message =sprintf ('Cannot determine controller argument for "%s::%s()": the $%s argument is type-hinted with the non-existent class or interface: "%s". ' ,$ class ,$ r ->name ,$ p ->name ,$ type );
182182