diff --git a/src/Error/Middleware/WhoopsHandlerMiddleware.php b/src/Error/Middleware/WhoopsHandlerMiddleware.php index 2d57243..341448e 100644 --- a/src/Error/Middleware/WhoopsHandlerMiddleware.php +++ b/src/Error/Middleware/WhoopsHandlerMiddleware.php @@ -2,9 +2,9 @@ namespace CakephpWhoops\Error\Middleware; -use CakephpWhoops\Error\WhoopsTrait; use Cake\Core\Configure; use Cake\Error\Middleware\ErrorHandlerMiddleware; +use CakephpWhoops\Error\WhoopsTrait; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Throwable; @@ -20,7 +20,7 @@ class WhoopsHandlerMiddleware extends ErrorHandlerMiddleware { use WhoopsTrait; - const PHP_SAPI_CLI = 'cli'; + public const PHP_SAPI_CLI = 'cli'; /** * @param \Throwable $exception The exception to handle. diff --git a/src/Error/WhoopsHandler.php b/src/Error/WhoopsHandler.php index 0531814..ce17095 100644 --- a/src/Error/WhoopsHandler.php +++ b/src/Error/WhoopsHandler.php @@ -21,6 +21,7 @@ class WhoopsHandler extends ErrorHandler { protected function _displayError(array $error, bool $debug): void { if (!$debug) { parent::_displayError($error, $debug); + return; } @@ -31,12 +32,13 @@ protected function _displayError(array $error, bool $debug): void { /** * @param \Throwable $exception The exception to display. - * @return void * @throws \Exception When the chosen exception renderer is invalid. + * @return void */ protected function _displayException(Throwable $exception): void { if (!Configure::read('debug')) { parent::_displayException($exception); + return; } diff --git a/src/Error/WhoopsTrait.php b/src/Error/WhoopsTrait.php index 43b8458..5d9226e 100644 --- a/src/Error/WhoopsTrait.php +++ b/src/Error/WhoopsTrait.php @@ -21,13 +21,14 @@ protected function getWhoopsInstance(): Run { if (empty($this->_whoops)) { $this->_whoops = new Run(); } + return $this->_whoops; } /** * @return \Whoops\Handler\PrettyPageHandler */ - protected function getHandler(): HandlerInterface { + protected function getHandler(): HandlerInterface { $handler = new PrettyPageHandler(); if (!Configure::read('Whoops.editor')) { return $handler; @@ -44,6 +45,7 @@ protected function getHandler(): HandlerInterface { if (!Configure::read('Whoops.asAjax', false)) { return $url; } + return [ 'url' => $url, 'ajax' => true, diff --git a/tests/TestCase/Error/Middleware/WhoopsHandlerMiddlewareTest.php b/tests/TestCase/Error/Middleware/WhoopsHandlerMiddlewareTest.php index a44efc4..f8db403 100644 --- a/tests/TestCase/Error/Middleware/WhoopsHandlerMiddlewareTest.php +++ b/tests/TestCase/Error/Middleware/WhoopsHandlerMiddlewareTest.php @@ -2,8 +2,8 @@ namespace CakephpWhoops\Test\TestCase\Error\Middleware; -use CakephpWhoops\Error\Middleware\WhoopsHandlerMiddleware; use Cake\TestSuite\TestCase; +use CakephpWhoops\Error\Middleware\WhoopsHandlerMiddleware; /** * Error handling middleware.