getParameters() as $parameter) { $service = ltrim((string) $parameter->getType(), '?'); foreach ($parameter->getAttributes(Autowire::class) as $attribute) { $service = (string) $attribute->newInstance()->value; } if (!$container->has($service)) { throw new AutowiringFailedException($service, sprintf('Cannot autowire service "%s": argument "$%s" of method "%s::_construct()", you should configure its value explicitly.', $service, $parameter->getName(), static::class)); } $args[] = $container->get($service); } } return new static(...$args); } }