1313 */
1414class ClassAttributeCollector
1515{
16- private ParameterAttributeCollector $ parameterAttributeCollector ;
17-
1816 public function __construct (
1917 private Logger $ log ,
2018 ) {
21- $ this ->parameterAttributeCollector = new ParameterAttributeCollector ($ this ->log );
2219 }
2320
2421 /**
@@ -126,8 +123,6 @@ private static function isAttributeIgnored(ReflectionAttribute $attribute): bool
126123 /**
127124 * @param array<TransientTargetMethod> $methodAttributes
128125 * @param array<TransientTargetParameter> $parameterAttributes
129- *
130- * @return void
131126 */
132127 private function collectMethodAndParameterAttributes (
133128 string $ class ,
@@ -153,7 +148,41 @@ private function collectMethodAndParameterAttributes(
153148
154149 $ parameterAttributes = array_merge (
155150 $ parameterAttributes ,
156- $ this ->parameterAttributeCollector -> collectAttributes ($ methodReflection ),
151+ $ this ->collectParameterAttributes ($ methodReflection ),
157152 );
158153 }
154+
155+ /**
156+ * @return array<TransientTargetParameter>
157+ */
158+ private function collectParameterAttributes (\ReflectionMethod $ reflectionFunctionAbstract ): array
159+ {
160+ $ targets = [];
161+ $ class = $ reflectionFunctionAbstract ->class ;
162+ $ method = $ reflectionFunctionAbstract ->name ;
163+
164+ foreach ($ reflectionFunctionAbstract ->getParameters () as $ parameter ) {
165+ /** @var non-empty-string $name */
166+ $ name = $ parameter ->name ;
167+
168+ $ paramLabel = $ class . ':: ' . $ method . '( ' . $ name . ') ' ;
169+
170+ foreach ($ parameter ->getAttributes () as $ attribute ) {
171+ if (self ::isAttributeIgnored ($ attribute )) {
172+ continue ;
173+ }
174+
175+ $ this ->log ->debug ("Found attribute {$ attribute ->getName ()} on $ paramLabel " );
176+
177+ $ targets [] = new TransientTargetParameter (
178+ $ attribute ->getName (),
179+ $ attribute ->getArguments (),
180+ $ method ,
181+ $ name
182+ );
183+ }
184+ }
185+
186+ return $ targets ;
187+ }
159188}
0 commit comments