From a92e214b9ea0af95c0dc5d2a2b6efb53adefe949 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 31 Oct 2014 09:52:45 -0400 Subject: [PATCH] Fixes #5770: Added more PHP error names for `ErrorException` --- framework/CHANGELOG.md | 1 + framework/base/ErrorException.php | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 671fbd9..2d8ddc7 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -25,6 +25,7 @@ Yii Framework 2 Change Log - Enh #5613: Added `--overwrite` option to Gii console command to support overwriting all files (motin, qiangxue) - Enh #5646: Call `yii\base\ErrorHandler::unregister()` instead of `restore_*_handlers` directly (aivus) - Enh #5735: Added `yii\bootstrap\Tabs::renderTabContent` to support manually rendering tab contents (RomeroMsk) +- Enh #5770: Added more PHP error names for `ErrorException` (mongosoft) - Enh #5806: Allow `Html::encode()` to be used when the application is not started (qiangxue) - Enh: `Console::confirm()` now uses `Console::stdout()` instead of `echo` to be consistent with all other functions (cebe) - Chg #3630: `yii\db\Command::queryInternal()` is now protected (samdark) diff --git a/framework/base/ErrorException.php b/framework/base/ErrorException.php index 92fcc1b..580a828 100644 --- a/framework/base/ErrorException.php +++ b/framework/base/ErrorException.php @@ -73,22 +73,22 @@ class ErrorException extends \ErrorException */ public function getName() { - $names = [ - E_ERROR => 'PHP Fatal Error', - E_WARNING => 'PHP Warning', - E_PARSE => 'PHP Parse Error', - E_NOTICE => 'PHP Notice', - E_CORE_ERROR => 'PHP Core Error', - E_CORE_WARNING => 'PHP Core Warning', + static $names = [ E_COMPILE_ERROR => 'PHP Compile Error', E_COMPILE_WARNING => 'PHP Compile Warning', - E_USER_ERROR => 'PHP User Error', - E_USER_WARNING => 'PHP User Warning', - E_USER_NOTICE => 'PHP User Notice', - E_STRICT => 'PHP Strict Warning', - E_RECOVERABLE_ERROR => 'PHP Recoverable Error', + E_CORE_ERROR => 'PHP Core Error', + E_CORE_WARNING => 'PHP Core Warning', E_DEPRECATED => 'PHP Deprecated Warning', + E_ERROR => 'PHP Fatal Error', + E_NOTICE => 'PHP Notice', + E_PARSE => 'PHP Parse Error', + E_RECOVERABLE_ERROR => 'PHP Recoverable Error', + E_STRICT => 'PHP Strict Warning', E_USER_DEPRECATED => 'PHP User Deprecated Warning', + E_USER_ERROR => 'PHP User Error', + E_USER_NOTICE => 'PHP User Notice', + E_USER_WARNING => 'PHP User Warning', + E_WARNING => 'PHP Warning', ]; return isset($names[$this->getCode()]) ? $names[$this->getCode()] : 'Error';