src/Middleware/MiddlewareBuilder.php
public function isAdmissibleMiddlewares($middleware)
    {
        $reflection = null;

        if ($middleware instanceof MiddlewareInterface) {
            return true;
        }

        if (is_array($middleware)) {
            $class = array_shift($middleware);
            $method = array_shift($middleware);
            $reflection = new \ReflectionMethod($class, $method);
        } elseif (is_string($middleware)) {
            if (!class_exists($middleware)) {
                return false;
            }

            $reflection = new ReflectionClass($middleware);

            if ($reflection->implementsInterface('Psr\\Http\\Server\\MiddlewareInterface')) {
                return true;
            }

            try {
                return  $reflection->getMethod('process') || $reflection->getMethod('__invoke');
            } catch (\Exception $exception) {
                return false;
            }
        } elseif ($middleware instanceof \Closure || false === is_object($middleware)) {
            $reflection = new \ReflectionFunction($middleware);
        } else {
            $reflection = new \ReflectionMethod($middleware, '__invoke');
        }

        return 2 === $reflection->getNumberOfParameters();
    }
public function isAdmissibleMiddlewares($middleware)
    {
        $reflection = null;

        if ($middleware instanceof MiddlewareInterface) {
            return true;
        }

        if (is_array($middleware)) {
            $class = array_shift($middleware);
            $method = array_shift($middleware);
            $reflection = new \ReflectionMethod($class, $method);
        } elseif (is_string($middleware)) {
            if (!class_exists($middleware)) {
                return false;
            }

            $reflection = new ReflectionClass($middleware);

            if ($reflection->implementsInterface('Psr\\Http\\Server\\MiddlewareInterface')) {
                return true;
            }

            try {
                return  $reflection->getMethod('process') || $reflection->getMethod('__invoke');
            } catch (\Exception $exception) {
                return false;
            }
        } elseif ($middleware instanceof \Closure || false === is_object($middleware)) {
            $reflection = new \ReflectionFunction($middleware);
        } else {
            $reflection = new \ReflectionMethod($middleware, '__invoke');
        }

        return 2 === $reflection->getNumberOfParameters();
    }
@param $middleware

@return bool