src/Router.php
private function arrangeParameters(
        ReflectionFunctionAbstract $reflection,
        array $parameters,
        ServerRequestInterface $request
    ) {
        return array_map(
            function (ReflectionParameter $parameter) use ($parameters, $request) {
                if (isset($parameters[$parameter->getName()])) {
                    return $parameters[$parameter->getName()];
                }

                if (
                    ($parameter->getType() && $parameter->getType()->getName() == ServerRequestInterface::class) ||
                    ($parameter->getType() && $parameter->getType()->getName() == ServerRequest::class) ||
                    ($parameter->getName() == 'request')
                ) {
                    return $request;
                }

                if (
                    ($parameter->getType() && $parameter->getType()->getName() == Router::class) ||
                    ($parameter->getName() == 'router')
                ) {
                    return $this;
                }

                if ($parameter->isOptional()) {
                    return $parameter->getDefaultValue();
                }

                return null;
            },

            $reflection->getParameters()
        );
    }
private function arrangeParameters(
        ReflectionFunctionAbstract $reflection,
        array $parameters,
        ServerRequestInterface $request
    ) {
        return array_map(
            function (ReflectionParameter $parameter) use ($parameters, $request) {
                if (isset($parameters[$parameter->getName()])) {
                    return $parameters[$parameter->getName()];
                }

                if (
                    ($parameter->getType() && $parameter->getType()->getName() == ServerRequestInterface::class) ||
                    ($parameter->getType() && $parameter->getType()->getName() == ServerRequest::class) ||
                    ($parameter->getName() == 'request')
                ) {
                    return $request;
                }

                if (
                    ($parameter->getType() && $parameter->getType()->getName() == Router::class) ||
                    ($parameter->getName() == 'router')
                ) {
                    return $this;
                }

                if ($parameter->isOptional()) {
                    return $parameter->getDefaultValue();
                }

                return null;
            },

            $reflection->getParameters()
        );
    }
Arrange parameters for given method/function

@param ReflectionFunctionAbstract $reflection
@param array $parameters
@param ServerRequestInterface $request
@return array