protected function getFunctionArgs(\stdClass $route, \ReflectionFunctionAbstract $refl)
    {
        $args = [];
        $params = $refl->getParameters();

        foreach ($params as $param) {
            $key = $param->name;

            if (property_exists($route, $key)) {
                $value = $route->$key;
            } else {
                if (!$param->isOptional()) {
                    $fn = $refl instanceof \ReflectionMethod ? $refl->class . '::' . $refl->name : $refl->name;
                    throw new \RuntimeException("Missing argument '$key' for {$fn}()");
                }
                
                $value = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null;
            }

            $args[$key] = $value;
        }
        
        return $args;
    }
protected function getFunctionArgs(\stdClass $route, \ReflectionFunctionAbstract $refl)
    {
        $args = [];
        $params = $refl->getParameters();

        foreach ($params as $param) {
            $key = $param->name;

            if (property_exists($route, $key)) {
                $value = $route->$key;
            } else {
                if (!$param->isOptional()) {
                    $fn = $refl instanceof \ReflectionMethod ? $refl->class . '::' . $refl->name : $refl->name;
                    throw new \RuntimeException("Missing argument '$key' for {$fn}()");
                }
                
                $value = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null;
            }

            $args[$key] = $value;
        }
        
        return $args;
    }
protected function getFunctionArgs ( \ stdClass $ route , \ ReflectionFunctionAbstract $ refl ) { $ args = [ ] ; $ params = $ refl -> getParameters ( ) ; foreach ( $ params as $ param ) { $ key = $ param -> name ; if ( property_exists ( $ route , $ key ) ) { $ value = $ route -> $ key ; } else { if ( ! $ param -> isOptional ( ) ) { $ fn = $ refl instanceof \ ReflectionMethod ? $ refl -> class . '::' . $ refl -> name : $ refl -> name ; throw new \ RuntimeException ( "Missing argument '$key' for {$fn}()" ) ; } $ value = $ param -> isDefaultValueAvailable ( ) ? $ param -> getDefaultValue ( ) : null ; } $ args [ $ key ] = $ value ; } return $ args ; }
Get the arguments for a function from a route using reflection

@param \stdClass                   $route
@param \ReflectionFunctionAbstract $refl
@return array
Get the arguments for a function from a route using reflection