protected function mergeArguments(array $injections, array $arguments)
    {
        // Get total count of arguments
        $numberOfArguments = count($injections) + count($arguments);

        // Prepare an array with null values for given count
        $result = array_fill(0, $numberOfArguments, null);

        // Get count of injections for performance reasons outside loop
        $countInjections = count($injections);

        // Iterate the injections and position them in result
        for ($i = 0; $i < $countInjections; ++$i) {
            if (null !== $injections[$i]['position']) {
                $position = $injections[$i]['position'] - 1;
            } else {
                $position = $i;
            }

            $result[$position] = $injections[$i]['instance'];
        }

        // Iterate over remaining arguments and fill in the holes
        foreach ($result as $key => $value) {
            if ($result[$key] === null) {
                $result[$key] = array_shift($arguments);
            }
        }

        return $result;
    }
protected function mergeArguments(array $injections, array $arguments)
    {
        // Get total count of arguments
        $numberOfArguments = count($injections) + count($arguments);

        // Prepare an array with null values for given count
        $result = array_fill(0, $numberOfArguments, null);

        // Get count of injections for performance reasons outside loop
        $countInjections = count($injections);

        // Iterate the injections and position them in result
        for ($i = 0; $i < $countInjections; ++$i) {
            if (null !== $injections[$i]['position']) {
                $position = $injections[$i]['position'] - 1;
            } else {
                $position = $i;
            }

            $result[$position] = $injections[$i]['instance'];
        }

        // Iterate over remaining arguments and fill in the holes
        foreach ($result as $key => $value) {
            if ($result[$key] === null) {
                $result[$key] = array_shift($arguments);
            }
        }

        return $result;
    }
protected function mergeArguments ( array $ injections , array $ arguments ) { // Get total count of arguments $ numberOfArguments = count ( $ injections ) + count ( $ arguments ) ; // Prepare an array with null values for given count $ result = array_fill ( 0 , $ numberOfArguments , null ) ; // Get count of injections for performance reasons outside loop $ countInjections = count ( $ injections ) ; // Iterate the injections and position them in result for ( $ i = 0 ; $ i < $ countInjections ; ++ $ i ) { if ( null !== $ injections [ $ i ] [ 'position' ] ) { $ position = $ injections [ $ i ] [ 'position' ] - 1 ; } else { $ position = $ i ; } $ result [ $ position ] = $ injections [ $ i ] [ 'instance' ] ; } // Iterate over remaining arguments and fill in the holes foreach ( $ result as $ key => $ value ) { if ( $ result [ $ key ] === null ) { $ result [ $ key ] = array_shift ( $ arguments ) ; } } return $ result ; }
Merges given constructor injections and arguments for constructor.

@param array $injections Injection arguments to pass to constructor
@param array $arguments  Additional arguments to pass to constructor

@author Benjamin Carl <opensource@clickalicious.de>

@return array The merged result ready to pass to targets constructor
Merges given constructor injections and arguments for constructor .