From 51e31e8dc3cff311fd482f089ed6c6efe57297ed Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Thu, 16 Jul 2015 12:41:34 +0200 Subject: [PATCH] Consolidate typehint decalarations around Exception. --- src/Console/ConsoleErrorHandler.php | 3 ++- src/Error/BaseErrorHandler.php | 7 ++++--- src/Error/ExceptionRenderer.php | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Console/ConsoleErrorHandler.php b/src/Console/ConsoleErrorHandler.php index e8f23d7f1fd..4ad689363f9 100644 --- a/src/Console/ConsoleErrorHandler.php +++ b/src/Console/ConsoleErrorHandler.php @@ -16,6 +16,7 @@ use Cake\Error\BaseErrorHandler; use Cake\Error\FatalErrorException; +use Exception; /** * Error Handler for Cake console. Does simple printing of the @@ -61,7 +62,7 @@ public function __construct($options = []) * @throws \Exception When renderer class not found * @see http://php.net/manual/en/function.set-exception-handler.php */ - public function handleException(\Exception $exception) + public function handleException(Exception $exception) { $this->_displayException($exception); $this->_logException($exception); diff --git a/src/Error/BaseErrorHandler.php b/src/Error/BaseErrorHandler.php index 4c445784700..c95d9381227 100644 --- a/src/Error/BaseErrorHandler.php +++ b/src/Error/BaseErrorHandler.php @@ -18,6 +18,7 @@ use Cake\Error\Debugger; use Cake\Log\Log; use Cake\Routing\Router; +use Exception; /** * Base error handler that provides logic common to the CLI + web @@ -150,7 +151,7 @@ public function handleError($code, $description, $file = null, $line = null, $co * @throws \Exception When renderer class not found * @see http://php.net/manual/en/function.set-exception-handler.php */ - public function handleException(\Exception $exception) + public function handleException(Exception $exception) { $this->_displayException($exception); $this->_logException($exception); @@ -228,7 +229,7 @@ protected function _logError($level, $data) * @param \Exception $exception Exception instance. * @return bool */ - protected function _logException(\Exception $exception) + protected function _logException(Exception $exception) { $config = $this->_options; if (empty($config['log'])) { @@ -251,7 +252,7 @@ protected function _logException(\Exception $exception) * @param \Exception $exception Exception instance * @return string Formatted message */ - protected function _getMessage(\Exception $exception) + protected function _getMessage(Exception $exception) { $config = $this->_options; $message = sprintf( diff --git a/src/Error/ExceptionRenderer.php b/src/Error/ExceptionRenderer.php index 7570543dfb4..18c2296e1dd 100644 --- a/src/Error/ExceptionRenderer.php +++ b/src/Error/ExceptionRenderer.php @@ -195,7 +195,7 @@ protected function _customMethod($method, $exception) * @param \Exception $exception Exception instance. * @return string */ - protected function _method(\Exception $exception) + protected function _method(Exception $exception) { list(, $baseClass) = namespaceSplit(get_class($exception)); @@ -214,7 +214,7 @@ protected function _method(\Exception $exception) * @param int $code Error code * @return string Error message */ - protected function _message(\Exception $exception, $code) + protected function _message(Exception $exception, $code) { $message = $this->error->getMessage(); @@ -239,7 +239,7 @@ protected function _message(\Exception $exception, $code) * @param int $code Error code * @return string Template name */ - protected function _template(\Exception $exception, $method, $code) + protected function _template(Exception $exception, $method, $code) { $isHttpException = $exception instanceof HttpException; @@ -274,7 +274,7 @@ protected function _template(\Exception $exception, $method, $code) * @param \Exception $exception Exception * @return int Error code value within range 400 to 506 */ - protected function _code(\Exception $exception) + protected function _code(Exception $exception) { $code = 500; $errorCode = $exception->getCode();