Layton/Services/DependentService.php
public function call($subject, $inherentParams = [])
    {
        $reflectionFunction = new ReflectionFunction($subject);
        $reflectionParameters = $this->getReflectionParameters(
            $reflectionFunction,
            count($inherentParams)
        );

        $dependentInstances = [];
        foreach($reflectionParameters as $reflectionParameter) {
            $dependentInstances[] = $this->getDependentByParameter($reflectionParameter)
                ->getInstance();
        }
        $params = array_merge($dependentInstances, $inherentParams);
        $closure = $reflectionFunction->getClosure();
        return call_user_func_array($closure, $params);
    }
public function call($subject, $inherentParams = [])
    {
        $reflectionFunction = new ReflectionFunction($subject);
        $reflectionParameters = $this->getReflectionParameters(
            $reflectionFunction,
            count($inherentParams)
        );

        $dependentInstances = [];
        foreach($reflectionParameters as $reflectionParameter) {
            $dependentInstances[] = $this->getDependentByParameter($reflectionParameter)
                ->getInstance();
        }
        $params = array_merge($dependentInstances, $inherentParams);
        $closure = $reflectionFunction->getClosure();
        return call_user_func_array($closure, $params);
    }
public function call ( $ subject , $ inherentParams = [ ] ) { $ reflectionFunction = new ReflectionFunction ( $ subject ) ; $ reflectionParameters = $ this -> getReflectionParameters ( $ reflectionFunction , count ( $ inherentParams ) ) ; $ dependentInstances = [ ] ; foreach ( $ reflectionParameters as $ reflectionParameter ) { $ dependentInstances [ ] = $ this -> getDependentByParameter ( $ reflectionParameter ) -> getInstance ( ) ; } $ params = array_merge ( $ dependentInstances , $ inherentParams ) ; $ closure = $ reflectionFunction -> getClosure ( ) ; return call_user_func_array ( $ closure , $ params ) ; }
reverse a function and save singleton

@param callback $subject
@param array $inherentParams

@return mixed
reverse a function and save singleton