Add type hints to Dispatch classes
This commit is contained in:
parent
e9fb474eb7
commit
ecc077a1be
|
|
@ -1,7 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="3"
|
||||
errorLevel="2"
|
||||
resolveFromConfigFile="true"
|
||||
allowStringToStandInForClass="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ use Psr\Http\Message\ServerRequestInterface;
|
|||
*/
|
||||
class DispatchStack implements DispatchStackInterface
|
||||
{
|
||||
/** @var mixed[] */
|
||||
private $stack;
|
||||
/** @var DispatcherInterface */
|
||||
private $dispatcher;
|
||||
|
||||
/**
|
||||
|
|
@ -66,7 +68,10 @@ class DispatchStack implements DispatchStackInterface
|
|||
|
||||
// The final middleware's $next returns $response unchanged and sets
|
||||
// the $stackCompleted flag to indicate the stack has completed.
|
||||
$chain = function ($request, $response) use (&$stackCompleted) {
|
||||
$chain = function (
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response
|
||||
) use (&$stackCompleted): ResponseInterface {
|
||||
$stackCompleted = true;
|
||||
return $response;
|
||||
};
|
||||
|
|
@ -77,8 +82,16 @@ class DispatchStack implements DispatchStackInterface
|
|||
// contain a dispatcher, the associated middleware, and a $next function
|
||||
// that serves as the link to the next middleware in the chain.
|
||||
foreach (array_reverse($this->stack) as $middleware) {
|
||||
$chain = function ($request, $response) use ($dispatcher, $middleware, $chain) {
|
||||
return $dispatcher->dispatch($middleware, $request, $response, $chain);
|
||||
$chain = function (
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response
|
||||
) use ($dispatcher, $middleware, $chain): ResponseInterface {
|
||||
return $dispatcher->dispatch(
|
||||
$middleware,
|
||||
$request,
|
||||
$response,
|
||||
$chain
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ class Dispatcher implements DispatcherInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $dispatchables
|
||||
* @return DispatchStack
|
||||
*/
|
||||
protected function getDispatchStack($dispatchables)
|
||||
{
|
||||
$stack = new DispatchStack($this);
|
||||
|
|
|
|||
Loading…
Reference in New Issue