16
16
use Symfony \Component \DependencyInjection \Definition ;
17
17
use Symfony \Component \DependencyInjection \LazyProxy \ProxyHelper ;
18
18
use Symfony \Component \DependencyInjection \Reference ;
19
+ use Symfony \Component \DependencyInjection \TypedReference ;
19
20
20
21
/**
21
22
* Overwrites a service but keeps the overridden one.
@@
10000
-72,19 +73,17 @@ public function process(ContainerBuilder $container)
72
73
73
74
private function autowire (ContainerBuilder $ container , Definition $ definition , string $ renamedId ): void
74
75
{
75
- if (
76
- !$ definition ->isAutowired () ||
76
+ if (!$ definition ->isAutowired () ||
77
77
null === ($ innerClass = $ container ->findDefinition ($ renamedId )->getClass ()) ||
78
78
!($ reflectionClass = $ container ->getReflectionClass ($ definition ->getClass ())) ||
79
- !$ reflectionMethod = $ reflectionClass ->getConstructor ()
79
+ !$ constructor = $ reflectionClass ->getConstructor ()
80
80
) {
81
81
return ;
82
82
}
83
83
84
84
$ innerIndex = null ;
85
- foreach ($ reflectionMethod ->getParameters () as $ index => $ parameter ) {
86
- if (
87
- null === ($ type = ProxyHelper::getTypeHint ($ reflectionMethod , $ parameter , true )) ||
85
+ foreach ($ constructor ->getParameters () as $ index => $ parameter ) {
86
+ if (null === ($ type = ProxyHelper::getTypeHint ($ constructor , $ parameter , true )) ||
88
87
!is_a ($ innerClass , $ type , true )
89
88
) {
90
89
continue ;
@@ -99,7 +98,7 @@ private function autowire(ContainerBuilder $container, Definition $definition, s
99
98
}
100
99
101
100
if (null !== $ innerIndex ) {
102
- $ definition ->setArgument ($ innerIndex , new Reference ($ renamedId ));
101
+ $ definition ->setArgument ($ innerIndex , new TypedReference ($ renamedId, $ innerClass ));
103
102
}
104
103
}
105
104
}
0 commit comments