@@ -28,6 +28,8 @@ class ResolveAutowireInlineAttributesPass extends AbstractRecursivePass
2828{
2929 protected bool $ skipScalars = true ;
3030
31+ private int $ counter ;
32+
3133 protected function processValue (mixed $ value , bool $ isRoot = false ): mixed
3234 {
3335 $ value = parent ::processValue ($ value , $ isRoot );
@@ -36,6 +38,10 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed
3638 return $ value ;
3739 }
3840
41+ if ($ isRoot ) {
42+ $ this ->counter = 0 ;
43+ }
44+
3945 $ isChildDefinition = $ value instanceof ChildDefinition;
4046
4147 try {
@@ -92,10 +98,14 @@ private function registerAutowireInlineAttributes(\ReflectionFunctionAbstract $m
9298 }
9399
94100 if (\array_key_exists ('$ ' .$ parameter ->name , $ arguments ) || (\array_key_exists ($ index , $ arguments ) && '' !== $ arguments [$ index ])) {
101+ $ attribute = \array_key_exists ('$ ' .$ parameter ->name , $ arguments ) ? $ arguments ['$ ' .$ parameter ->name ] : $ arguments [$ index ];
102+ if (!$ attribute instanceof AutowireInline) {
103+ continue ;
104+ }
105+ } elseif (!$ attribute = $ parameter ->getAttributes (AutowireInline::class, \ReflectionAttribute::IS_INSTANCEOF )[0 ] ?? null ) {
95106 continue ;
96- }
97- if (!$ attribute = $ parameter ->getAttributes (AutowireInline::class, \ReflectionAttribute::IS_INSTANCEOF )[0 ] ?? null ) {
98- continue ;
107+ } else {
108+ $ attribute = $ attribute ->newInstance ();
99109 }
100110
101111 $ type = ProxyHelper::exportType ($ parameter , true );
@@ -104,25 +114,18 @@ private function registerAutowireInlineAttributes(\ReflectionFunctionAbstract $m
104114 continue ;
105115 }
106116
107- $ attribute = $ attribute ->newInstance ();
108117 $ definition = $ attribute ->buildDefinition ($ attribute ->value , $ type , $ parameter );
109118
110119 $ paramResolverContainer ->setDefinition ('.autowire_inline ' , $ definition );
111120 (new ResolveParameterPlaceHoldersPass (false , false ))->process ($ paramResolverContainer );
112121
113- $ id = '.autowire_inline. ' .ContainerBuilder:: hash ([ $ this ->currentId , $ method -> class ?? null , $ method -> name , ( string ) $ parameter ]) ;
122+ $ id = '.autowire_inline. ' .$ this ->currentId . ' . ' .++ $ this -> counter ;
114123
115124 $ this ->container ->setDefinition ($ id , $ definition );
116125 $ arguments [$ isChildDefinition ? '$ ' .$ parameter ->name : $ index ] = new Reference ($ id );
117126
118127 if ($ definition ->isAutowired ()) {
119- $ currentId = $ this ->currentId ;
120- try {
121- $ this ->currentId = $ id ;
122- $ this ->processValue ($ definition , true );
123- } finally {
124- $ this ->currentId = $ currentId ;
125- }
128+ $ this ->processValue ($ definition );
126129 }
127130 }
128131
0 commit comments