Skip to content

Commit

Permalink
Implemented the code review from ADmad.
Browse files Browse the repository at this point in the history
  • Loading branch information
iliepandia committed Apr 23, 2018
1 parent bbc6a54 commit 4b42abd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Error/ExceptionRenderer.php
Expand Up @@ -83,7 +83,7 @@ class ExceptionRenderer implements ExceptionRendererInterface
* If set, this will be request used to create the controller that will render
* the error.
*
* @var \Psr\Http\Message\ServerRequestInterface
* @var \Psr\Http\Message\ServerRequestInterface|null
*/
protected $request = null;

Expand All @@ -93,7 +93,7 @@ class ExceptionRenderer implements ExceptionRendererInterface
* code error depending on the code used to construct the error.
*
* @param \Exception $exception Exception.
* @param ServerRequestInterface $request The request - if this is set it will be used instead of creating a new one
* @param \Psr\Http\Message\ServerRequestInterface $request The request - if this is set it will be used instead of creating a new one
*/
public function __construct(Exception $exception, ServerRequestInterface $request = null)
{
Expand Down Expand Up @@ -125,7 +125,8 @@ protected function _unwrap($exception)
*/
protected function _getController()
{
if (!$request = $this->request ?: Router::getRequest(true)) {
$request = $this->request ?: Router::getRequest(true);
if ($request === null ) {
$request = ServerRequestFactory::fromGlobals();
}

Expand Down
3 changes: 2 additions & 1 deletion tests/test_app/TestApp/Error/TestAppsExceptionRenderer.php
Expand Up @@ -17,7 +17,8 @@ class TestAppsExceptionRenderer extends ExceptionRenderer
*/
protected function _getController()
{
if (!$request = $this->request ?: Router::getRequest(true)) {
$request = $this->request ?: Router::getRequest(true);
if ($request === null) {
$request = new ServerRequest();
}
$response = new Response();
Expand Down

0 comments on commit 4b42abd

Please sign in to comment.