src/fkooman/Rest/Route.php
private function findAvailableParameterValue(ReflectionParameter $p, array $availableParameters)
    {
        // determine the name, in case of a class this is the type hint, in
        // case of a non-class parameter it is the actual name
        $isClass = null !== $p->getClass();
        if ($isClass) {
            $parameterName = $p->getClass()->getName();
        } else {
            $parameterName = $p->getName();
        }

        if (array_key_exists($parameterName, $availableParameters)) {
            // we found the parameter!
            return $availableParameters[$parameterName];
        }
        if ($p->isDefaultValueAvailable()) {
            // we have a default value!
            return $p->getDefaultValue();
        }
        throw new BadFunctionCallException(
            sprintf(
                'parameter "%s" expected by callback not available',
                $parameterName
            )
        );
    }
private function findAvailableParameterValue(ReflectionParameter $p, array $availableParameters)
    {
        // determine the name, in case of a class this is the type hint, in
        // case of a non-class parameter it is the actual name
        $isClass = null !== $p->getClass();
        if ($isClass) {
            $parameterName = $p->getClass()->getName();
        } else {
            $parameterName = $p->getName();
        }

        if (array_key_exists($parameterName, $availableParameters)) {
            // we found the parameter!
            return $availableParameters[$parameterName];
        }
        if ($p->isDefaultValueAvailable()) {
            // we have a default value!
            return $p->getDefaultValue();
        }
        throw new BadFunctionCallException(
            sprintf(
                'parameter "%s" expected by callback not available',
                $parameterName
            )
        );
    }
private function findAvailableParameterValue ( ReflectionParameter $ p , array $ availableParameters ) { // determine the name, in case of a class this is the type hint, in // case of a non-class parameter it is the actual name $ isClass = null !== $ p -> getClass ( ) ; if ( $ isClass ) { $ parameterName = $ p -> getClass ( ) -> getName ( ) ; } else { $ parameterName = $ p -> getName ( ) ; } if ( array_key_exists ( $ parameterName , $ availableParameters ) ) { // we found the parameter! return $ availableParameters [ $ parameterName ] ; } if ( $ p -> isDefaultValueAvailable ( ) ) { // we have a default value! return $ p -> getDefaultValue ( ) ; } throw new BadFunctionCallException ( sprintf ( 'parameter "%s" expected by callback not available' , $ parameterName ) ) ; }
Find the parameter required by the callback.

@param ReflectionParameter $p                   a parameter belonging to the callback
@param array               $availableParameters contains a list of parameters available to the callback, where the
key contains either the type hinted name of the class, or the
name of the parameter if the parameter is no class, e.g.:
array('foo' => 5, 'stdClass' => new StdClass())

@return string the value of the parameter from $availableParameters, or an
(optional) provided default value by the callback
Find the parameter required by the callback .