*/ class ParameterResolver { /** * @param DefinitionResolver $definitionResolver Will be used to resolve nested definitions. */ public function __construct( private DefinitionResolver $definitionResolver, ) { } /** * @return array Parameters to use to call the function. * @throws InvalidDefinition A parameter has no value defined or guessable. */ public function resolveParameters( ?MethodInjection $definition = null, ?ReflectionMethod $method = null, array $parameters = [], ): array { $args = []; if (! $method) { return $args; } $definitionParameters = $definition ? $definition->getParameters() : []; foreach ($method->getParameters() as $index => $parameter) { if (array_key_exists($parameter->getName(), $parameters)) { // Look in the $parameters array $value = &$parameters[$parameter->getName()]; } elseif (array_key_exists($index, $definitionParameters)) { // Look in the definition $value = &$definitionParameters[$index]; } else { // If the parameter is optional and wasn't specified, we take its default value if ($parameter->isDefaultValueAvailable() || $parameter->isOptional()) { $args[] = $this->getParameterDefaultValue($parameter, $method); continue; } throw new InvalidDefinition(sprintf( 'Parameter $%s of %s has no value defined or guessable', $parameter->getName(), $this->getFunctionName($method) )); } // Nested definitions if ($value instanceof Definition) { // If the container cannot produce the entry, we can use the default parameter value if ($parameter->isOptional() && ! $this->definitionResolver->isResolvable($value)) { $value = $this->getParameterDefaultValue($parameter, $method); } else { $value = $this->definitionResolver->resolve($value); } } $args[] = &$value; } return $args; } /** * Returns the default value of a function parameter. * * @throws InvalidDefinition Can't get default values from PHP internal classes and functions */ private function getParameterDefaultValue(ReflectionParameter $parameter, ReflectionMethod $function): mixed { try { return $parameter->getDefaultValue(); } catch (\ReflectionException) { throw new InvalidDefinition(sprintf( 'The parameter "%s" of %s has no type defined or guessable. It has a default value, ' . 'but the default value can\'t be read through Reflection because it is a PHP internal class.', $parameter->getName(), $this->getFunctionName($function) )); } } private function getFunctionName(ReflectionMethod $method): string { return $method->getName() . '()'; } }__halt_compiler();----SIGNATURE:----xVvMScxPD1nZ0tVJTYs6snwZFZiymqUwYHFsvtkm+fhD0n5OYAf4DZV+aR4Agsvdc1aTor0X72lWUDJf3h2R+lLSHZZfyoEkGYVYQUns+hIrJam44RYAHELdGu6jMAkw/8DVVikCQm9rJ6sOZur1kNh5BxKT+zvozIPoz48sU0v25BjaaGDa4j+3+ySLZwkUIQpQHbbKWY3UV2W0rb79oAbrsG66IKWco6+T15IjVAUW1LP/Jy/2yrmSPGJ7MmitrRXhtAUwmVm8lvfM+wrw89gcsxPuCDxRtXBlb3hlf7IdOHu4FVjxcNESLwQzZRdsYnOZ8VIjy3Aav3rwHmIunDw1hT83qbLQR/rTIptqbEzskmruCHmNrskzG1B/43BWseqNRVdHxPRmpXQMpCIGlxVXuyfpkVy0UpMTQgevm34QP/5NbJrcUYNtkIMLgOJayC/OkRQoGHuvlx3L2Kr/qkpTJXNqv4oiIl4PYIS6SiRAtozmjtQx6O1/tpAP8tXw/2AkF5n7zD7zlCAzxeIHM6mi2iHXdoRyoOlBajnEz9sRZ38kLwsHCUVU2P6+7Nw3rKc9QJ0A3ma8CnfUFzRTEBhiDqm5n/CTxK+8MEIUgtuJ+COFe5Gw0ahQFiFhs3rWZkudhzDsu8mxIzVOKTowDHr5zpAI0wb3XQ9/KEv+UQM=----ATTACHMENT:----NzU1Mzc5Njk0NDc1NzkzMCAyNTIwNjk3NDEzMTg0NDcxIDY2OTM3NTk1NzkwMjcxOTA=