private function getDependencyInjectionParameters(array $reflectionParameters, array $arguments = []): array
    {
        $parameters = [];

        // Treat arguments
        $argumentsClass = [];
        foreach ($arguments as $name => &$argument) {
            if (!is_null($this->getContainer())) {
                // Service recursively
                if (is_string($argument) && substr($argument, 0, 1) == '@') {
                    $subServiceName = substr($argument, 1);
                    $argument = $this->getContainer()->get($subServiceName);
                }
            }

            // Get all classes of argument if it's an object.
            // It's necessary to know if argument can match with an injection.
            if (is_object($argument) && !($argument instanceof \stdClass)) {
                foreach ($this->getClassIndex()->getAllClasses($argument) as $class) {
                    $argumentsClass[$class][] = $name;
                }
            }
        }

        // Try to get all parameters values
        foreach ($reflectionParameters as $reflectionParameter) {
            if ($reflectionParameter instanceof \ReflectionParameter) {
                $parameters[$reflectionParameter->getName()] =
                    $this->getDependencyInjectionParameter($reflectionParameter,
                                                           $arguments,
                                                           $argumentsClass);
            }
        }

        return $parameters;
    }
private function getDependencyInjectionParameters(array $reflectionParameters, array $arguments = []): array
    {
        $parameters = [];

        // Treat arguments
        $argumentsClass = [];
        foreach ($arguments as $name => &$argument) {
            if (!is_null($this->getContainer())) {
                // Service recursively
                if (is_string($argument) && substr($argument, 0, 1) == '@') {
                    $subServiceName = substr($argument, 1);
                    $argument = $this->getContainer()->get($subServiceName);
                }
            }

            // Get all classes of argument if it's an object.
            // It's necessary to know if argument can match with an injection.
            if (is_object($argument) && !($argument instanceof \stdClass)) {
                foreach ($this->getClassIndex()->getAllClasses($argument) as $class) {
                    $argumentsClass[$class][] = $name;
                }
            }
        }

        // Try to get all parameters values
        foreach ($reflectionParameters as $reflectionParameter) {
            if ($reflectionParameter instanceof \ReflectionParameter) {
                $parameters[$reflectionParameter->getName()] =
                    $this->getDependencyInjectionParameter($reflectionParameter,
                                                           $arguments,
                                                           $argumentsClass);
            }
        }

        return $parameters;
    }
private function getDependencyInjectionParameters ( array $ reflectionParameters , array $ arguments = [ ] ) : array { $ parameters = [ ] ; // Treat arguments $ argumentsClass = [ ] ; foreach ( $ arguments as $ name => & $ argument ) { if ( ! is_null ( $ this -> getContainer ( ) ) ) { // Service recursively if ( is_string ( $ argument ) && substr ( $ argument , 0 , 1 ) == '@' ) { $ subServiceName = substr ( $ argument , 1 ) ; $ argument = $ this -> getContainer ( ) -> get ( $ subServiceName ) ; } } // Get all classes of argument if it's an object. // It's necessary to know if argument can match with an injection. if ( is_object ( $ argument ) && ! ( $ argument instanceof \ stdClass ) ) { foreach ( $ this -> getClassIndex ( ) -> getAllClasses ( $ argument ) as $ class ) { $ argumentsClass [ $ class ] [ ] = $ name ; } } } // Try to get all parameters values foreach ( $ reflectionParameters as $ reflectionParameter ) { if ( $ reflectionParameter instanceof \ ReflectionParameter ) { $ parameters [ $ reflectionParameter -> getName ( ) ] = $ this -> getDependencyInjectionParameter ( $ reflectionParameter , $ arguments , $ argumentsClass ) ; } } return $ parameters ; }
Get parameters ordered to inject.

@param \ReflectionParameter[] $reflectionParameters
@param array                  $arguments

@return array Parameters (ordered)
@throws \Psr\Container\ContainerExceptionInterface
Get parameters ordered to inject .