MiddlewarePipeline
A minimal PSR-15 relay that composes a route's `middleware[]` in front of its resolved handler: `middleware[0]` wraps `middleware[1]` wraps … wraps the `$tip` handler, so the middlewares run in declaration order and the innermost call is the controller. Immutable and re-entrant by design: each step advances by handing the next middleware a NEW pipeline pinned one index deeper, rather than mutating a shared cursor — so a middleware that short-circuits (returns without calling `$handler->handle()`) simply never advances, and the same pipeline instance can be handled more than once without state bleeding between runs.
MiddlewarePipeline::__construct()
public function __construct(array $queue, Psr\Http\Server\RequestHandlerInterface $tip, int $index = 0):Parameters
| Name | Type | Description |
|---|---|---|
| $queue | list<MiddlewareInterface> | the route's middlewares, in declaration order |
| $tip | RequestHandlerInterface | the resolved route handler, run once the queue is exhausted |
| $index | int | the middleware this pipeline will invoke next |
MiddlewarePipeline::handle()
public function handle(Psr\Http\Message\ServerRequestInterface $request): Psr\Http\Message\ResponseInterfaceInvokes the middleware at the current index (advancing to the next), or the tip handler when the queue is spent.
Parameters
| Name | Type | Description |
|---|---|---|
| $request | Psr\Http\Message\ServerRequestInterface |