*/ 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:----lxE0Y9/UBENTLvrNJ4HUsL74k54XPVq/r2NTqCv3d75XKnMRf7xqxi2o1j8RRpn90+FEqQ20xqlF2WAnHqR5SqSeBO3gokiEf6b/RGYrEE6nDy+ks+VshZKKpumM0Y88LMTJ29tRUFmgburQQ9LdvhI46ypMZnrMkHF3qIN65rytcASzG4YflqJG1O39vjRWg2n7JWtW+9su+hjMUMUY4MgbliIslZ3+zRJi2Vo6EwNXIyKG/6n2FG4BEfBlnere73Ox2++Y3Gne0iWVNImN3RZpC2ODf0+dwkEdJLnHXHEYJU/xdY1dILopBOEZChlqWpHkeRVoEEcVB5KTjGBhIz3CvcILr6+PZGeJV6tqIBMfVmhhAgdOnI0MWLebHalT1H8ut7CereOVcdLXdmGUK3vquKqZ4hGWOUJXWz7GmblDcdw6BCCGMHhYVyCNTcMSxv1pLMHO9EKkzu1fomfOwK8kd2B2kPewavJM/s2IsMtx5UkgZV6Ox8DXQVmA7ZF7deBM1Obf5w6MQP3xa4gG3+Ix+mXHxt2ePISo3KcgUahyKNPPcAWOySd9vbHvEAH48nUWSAJ+l+ZVrAeVIaPeV75M6kTWTRKVXYC+DM56guj1BrF/RCd2Khdaxi/tob77V41Jg4CIRUliQDrp0ln86wOoTB1PJ5S3h1ewokmvCzA=----ATTACHMENT:----MTUwMTA5NzgwMDYwOTc1MCAzMzkwMzExMDkyMjIxMTQwIDk2MTQ3MTMyMTAyNjY2Nw==