Zend\Stratigility\Next::__invoke PHP Метод

__invoke() публичный Метод

Next requires that a request and response are provided; these will be passed to any middleware invoked, including the $done callable, if invoked. If the $err value is not null, the invocation is considered to be an error invocation, and Next will search for the next error middleware to dispatch, passing it $err along with the request and response. Once dispatch is complete, if the result is a response instance, that value will be returned; otherwise, the currently registered response instance will be returned.
public __invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, null | mixed $err = null ) : Psr\Http\Message\ResponseInterface
$request Psr\Http\Message\ServerRequestInterface
$response Psr\Http\Message\ResponseInterface
$err null | mixed This argument is deprecated as of 1.3.0, and will be removed in 2.0.0.
Результат Psr\Http\Message\ResponseInterface
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $err = null)
    {
        if ($err !== null && $this->raiseThrowables) {
            $this->raiseThrowableFromError($err);
        }
        if (null !== $err) {
            $this->triggerErrorDeprecation();
        }
        if (!$this->responsePrototype) {
            $this->setResponsePrototype($response);
        }
        $dispatch = $this->dispatch;
        $done = $this->nextDelegate;
        $request = $this->resetPath($request);
        // No middleware remains; done
        if ($this->queue->isEmpty()) {
            return $this->dispatchNextDelegate($done, $request, $response, $err);
        }
        $layer = $this->queue->dequeue();
        $path = $request->getUri()->getPath() ?: '/';
        $route = $layer->path;
        $normalizedRoute = strlen($route) > 1 ? rtrim($route, '/') : $route;
        // Skip if layer path does not match current url
        if (substr(strtolower($path), 0, strlen($normalizedRoute)) !== strtolower($normalizedRoute)) {
            return $this($request, $response, $err);
        }
        // Skip if match is not at a border ('/', '.', or end)
        $border = $this->getBorder($path, $normalizedRoute);
        if ($border && '/' !== $border && '.' !== $border) {
            return $this($request, $response, $err);
        }
        // Trim off the part of the url that matches the layer route
        if (!empty($route) && $route !== '/') {
            $request = $this->stripRouteFromPath($request, $route);
        }
        $result = $dispatch($layer, $err, $request, $response, $this);
        return $result instanceof ResponseInterface ? $result : $response;
    }