@@ -52,18 +52,13 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed
52
52
}
53
53
}
54
54
55
- $ dummy = $ value ;
56
- while (null === $ dummy ->getClass () && $ dummy instanceof ChildDefinition) {
57
- $ dummy = $ this ->container ->findDefinition ($ dummy ->getParent ());
58
- }
59
-
60
55
$ methodCalls = $ value ->getMethodCalls ();
61
56
62
57
foreach ($ methodCalls as $ i => $ call ) {
63
58
[$ method , $ arguments ] = $ call ;
64
59
65
60
try {
66
- $ method = $ this ->getReflectionMethod ($ dummy , $ method );
61
+ $ method = $ this ->getReflectionMethod ($ value , $ method );
67
62
} catch (RuntimeException ) {
68
63
continue ;
69
64
}
@@ -89,19 +84,14 @@ private function registerAutowireInlineAttributes(\ReflectionFunctionAbstract $m
89
84
if ($ method ->isVariadic ()) {
90
85
array_pop ($ parameters );
91
86
}
92
- $ dummyContainer = new ContainerBuilder ($ this ->container ->getParameterBag ());
87
+ $ paramResolverContainer = new ContainerBuilder ($ this ->container ->getParameterBag ());
93
88
94
89
foreach ($ parameters as $ index => $ parameter ) {
95
90
if ($ isChildDefinition ) {
96
91
$ index = 'index_ ' .$ index ;
97
92
}
98
93
99
- $ name = '$ ' .$ parameter ->name ;
100
- if (\array_key_exists ($ name , $ arguments )) {
101
- $ arguments [$ index ] = $ arguments [$ name ];
102
- unset($ arguments [$ name ]);
103
- }
104
- if (\array_key_exists ($ index , $ arguments ) && '' !== $ arguments [$ index ]) {
94
+ if (\array_key_exists ('$ ' .$ parameter ->name , $ arguments ) || (\array_key_exists ($ index , $ arguments ) && '' !== $ arguments [$ index ])) {
105
95
continue ;
106
96
}
107
97
if (!$ attribute = $ parameter ->getAttributes (AutowireInline::class, \ReflectionAttribute::IS_INSTANCEOF )[0 ] ?? null ) {
@@ -117,13 +107,13 @@ private function registerAutowireInlineAttributes(\ReflectionFunctionAbstract $m
117
107
$ attribute = $ attribute ->newInstance ();
118
108
$ definition = $ attribute ->buildDefinition ($ attribute ->value , $ type , $ parameter );
119
109
120
- $ dummyContainer ->setDefinition ('.autowire_inline ' , $ definition );
121
- (new ResolveParameterPlaceHoldersPass (false , false ))->process ($ dummyContainer );
110
+ $ paramResolverContainer ->setDefinition ('.autowire_inline ' , $ definition );
111
+ (new ResolveParameterPlaceHoldersPass (false , false ))->process ($ paramResolverContainer );
122
112
123
113
$ id = '.autowire_inline. ' .ContainerBuilder::hash ([$ this ->currentId , $ method ->class ?? null , $ method ->name , (string ) $ parameter ]);
124
114
125
115
$ this ->container ->setDefinition ($ id , $ definition );
126
- $ arguments [$ index ] = new Reference ($ id );
116
+ $ arguments [$ isChildDefinition ? ' $ ' . $ parameter -> name : $ index ] = new Reference ($ id );
127
117
128
118
if ($ definition ->isAutowired ()) {
129
119
$ currentId = $ this ->currentId ;
0 commit comments