@@ -377,33 +377,29 @@ private function makePublicInjectedServices(ReflectionClass $refClass, Annotatio
377377 */
378378 private function getListOfInjectedServices (ReflectionMethod $ method , ContainerBuilder $ container ): array
379379 {
380+ /** @var array<string, string> $services */
380381 $ services = [];
381382
382- /**
383- * @var Autowire[] $autowireAnnotations
384- */
385- $ autowireAnnotations = $ this ->getAnnotationReader ()->getMethodAnnotations ($ method , Autowire::class);
386-
387383 $ parametersByName = null ;
388384
389- foreach ($ autowireAnnotations as $ autowire ) {
390- $ target = $ autowire ->getTarget ();
391-
392- if ($ parametersByName === null ) {
393- $ parametersByName = self ::getParametersByName ($ method );
394- }
385+ $ annotations = $ this ->getAnnotationReader ()->getParameterAnnotationsPerParameter ($ method ->getParameters ());
386+ foreach ($ annotations as $ parameterName => $ parameterAnnotations ) {
387+ $ parameterAutowireAnnotation = $ parameterAnnotations ->getAnnotationsByType (Autowire::class);
388+ foreach ($ parameterAutowireAnnotation as $ autowire ) {
389+ $ id = $ autowire ->getIdentifier ();
390+ if ($ id !== null ) {
391+ $ services [$ id ] = $ id ;
392+ continue ;
393+ }
395394
396- if (!isset ($ parametersByName [$ target ])) {
397- throw new GraphQLException ('In method ' .$ method ->getDeclaringClass ()->getName ().':: ' .$ method ->getName ().', the @Autowire annotation refers to a non existing parameter named " ' .$ target .'" ' );
398- }
395+ $ parametersByName ??= self ::getParametersByName ($ method );
396+ if (!isset ($ parametersByName [$ parameterName ])) {
397+ throw new \LogicException ('Should not happen ' );
398+ }
399399
400- $ id = $ autowire ->getIdentifier ();
401- if ($ id !== null ) {
402- $ services [$ id ] = $ id ;
403- } else {
404- $ parameter = $ parametersByName [$ target ];
400+ $ parameter = $ parametersByName [$ parameterName ];
405401 $ type = $ parameter ->getType ();
406- if ($ type !== null && $ type instanceof ReflectionNamedType) {
402+ if ($ type instanceof ReflectionNamedType) {
407403 $ fqcn = $ type ->getName ();
408404 if ($ container ->has ($ fqcn )) {
409405 $ services [$ fqcn ] = $ fqcn ;
0 commit comments