Skip to content

Commit

Permalink
Implementing ADmad's code reviews as per comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
iliepandia committed Apr 22, 2018
1 parent 4a19d6f commit 61c4e1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
11 changes: 4 additions & 7 deletions src/Error/ExceptionRenderer.php
Expand Up @@ -83,9 +83,9 @@ class ExceptionRenderer implements ExceptionRendererInterface
* If set, this will be request used to create the controller that will render
* the error.
*
* @var ServerRequestInterface
* @var \Psr\Http\Message\ServerRequestInterface
*/
public $request = '';
protected $request = null;

/**
* Creates the controller to perform rendering on the error response.
Expand Down Expand Up @@ -125,11 +125,8 @@ protected function _unwrap($exception)
*/
protected function _getController()
{
$request = $this->request;
if (!$request) {
if (!$request = Router::getRequest(true)) {
$request = ServerRequestFactory::fromGlobals();
}
if (!$request = $this->request ?: Router::getRequest(true)) {
$request = ServerRequestFactory::fromGlobals();
}

$response = new Response();
Expand Down
8 changes: 2 additions & 6 deletions tests/test_app/TestApp/Error/TestAppsExceptionRenderer.php
Expand Up @@ -7,7 +7,6 @@
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\Routing\Router;
use Psr\Http\Message\ServerRequestInterface;
use TestApp\Controller\TestAppsErrorController;

class TestAppsExceptionRenderer extends ExceptionRenderer
Expand All @@ -18,11 +17,8 @@ class TestAppsExceptionRenderer extends ExceptionRenderer
*/
protected function _getController()
{
$request = $this->request;
if (!$request) {
if (!$request = Router::getRequest(true)) {
$request = new ServerRequest();
}
if (!$request = $this->request ?: Router::getRequest(true)) {
$request = new ServerRequest();
}
$response = new Response();
try {
Expand Down

0 comments on commit 61c4e1d

Please sign in to comment.