Skip to content

Commit

Permalink
Merge pull request #246 from delboy1978uk/hotfix/209
Browse files Browse the repository at this point in the history
Hotfix/209
  • Loading branch information
philipobenito committed Jun 30, 2019
2 parents 773bb4e + 0f86c33 commit 68685b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 0 additions & 5 deletions src/Dispatcher.php
Expand Up @@ -7,7 +7,6 @@
use League\Route\Http\Exception\{MethodNotAllowedException, NotFoundException};
use League\Route\Middleware\{MiddlewareAwareInterface, MiddlewareAwareTrait};
use League\Route\Strategy\{StrategyAwareInterface, StrategyAwareTrait};
use OutOfBoundsException;
use Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
use Psr\Http\Server\RequestHandlerInterface;

Expand Down Expand Up @@ -54,10 +53,6 @@ public function handle(ServerRequestInterface $request) : ResponseInterface
{
$middleware = $this->shiftMiddleware();

if (is_null($middleware)) {
throw new OutOfBoundsException('Reached end of middleware stack. Does your controller return a response?');
}

return $middleware->process($request, $this);
}

Expand Down
9 changes: 8 additions & 1 deletion src/Middleware/MiddlewareAwareTrait.php
Expand Up @@ -2,6 +2,7 @@

namespace League\Route\Middleware;

use OutOfBoundsException;
use Psr\Http\Server\MiddlewareInterface;

trait MiddlewareAwareTrait
Expand Down Expand Up @@ -48,7 +49,13 @@ public function prependMiddleware(MiddlewareInterface $middleware) : MiddlewareA
*/
public function shiftMiddleware() : MiddlewareInterface
{
return array_shift($this->middleware);
$middleware = array_shift($this->middleware);

if (is_null($middleware)) {
throw new OutOfBoundsException('Reached end of middleware stack. Does your controller return a response?');
}

return $middleware;
}

/**
Expand Down

0 comments on commit 68685b6

Please sign in to comment.