diff --git a/framework/base/Application.php b/framework/base/Application.php index 9be1939..1e02c1d 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -87,9 +87,6 @@ class Application extends Module */ public $layout = 'main'; - // todo - public $localeDataPath = '@yii/i18n/data'; - private $_runtimePath; private $_ended = false; @@ -165,31 +162,6 @@ class Application extends Module if (ErrorException::isFatalErorr($error)) { unset($this->_memoryReserve); $exception = new ErrorException($error['message'], $error['type'], $error['type'], $error['file'], $error['line']); - - if (function_exists('xdebug_get_function_stack')) { - $trace = array_slice(array_reverse(xdebug_get_function_stack()), 4, -1); - foreach ($trace as &$frame) { - if (!isset($frame['function'])) { - $frame['function'] = 'unknown'; - } - - // XDebug < 2.1.1: http://bugs.xdebug.org/view.php?id=695 - if (!isset($frame['type'])) { - $frame['type'] = '::'; - } - - // XDebug has a different key name - $frame['args'] = array(); - if (isset($frame['params']) && !isset($frame['args'])) { - $frame['args'] = $frame['params']; - } - } - - $ref = new \ReflectionProperty('Exception', 'trace'); - $ref->setAccessible(true); - $ref->setValue($exception, $trace); - } - $this->logException($exception); if (($handler = $this->getErrorHandler()) !== null) { @@ -295,37 +267,6 @@ class Application extends Module date_default_timezone_set($value); } - // - // /** - // * Returns the locale instance. - // * @param string $localeID the locale ID (e.g. en_US). If null, the {@link getLanguage application language ID} will be used. - // * @return CLocale the locale instance - // */ - // public function getLocale($localeID = null) - // { - // return CLocale::getInstance($localeID === null ? $this->getLanguage() : $localeID); - // } - // - // /** - // * @return CNumberFormatter the locale-dependent number formatter. - // * The current {@link getLocale application locale} will be used. - // */ - // public function getNumberFormatter() - // { - // return $this->getLocale()->getNumberFormatter(); - // } - // - // /** - // * Returns the locale-dependent date formatter. - // * @return CDateFormatter the locale-dependent date formatter. - // * The current {@link getLocale application locale} will be used. - // */ - // public function getDateFormatter() - // { - // return $this->getLocale()->getDateFormatter(); - // } - // - /** * Returns the database connection component. * @return \yii\db\Connection the database connection diff --git a/framework/base/ErrorException.php b/framework/base/ErrorException.php index 465d839..740eea0 100644 --- a/framework/base/ErrorException.php +++ b/framework/base/ErrorException.php @@ -7,6 +7,8 @@ namespace yii\base; +use Yii; + /** * ErrorException represents a PHP error. * @@ -33,6 +35,30 @@ class ErrorException extends Exception $this->severity = $severity; $this->file = $filename; $this->line = $lineno; + + if (function_exists('xdebug_get_function_stack')) { + $trace = array_slice(array_reverse(xdebug_get_function_stack()), 3, -1); + foreach ($trace as &$frame) { + if (!isset($frame['function'])) { + $frame['function'] = 'unknown'; + } + + // XDebug < 2.1.1: http://bugs.xdebug.org/view.php?id=695 + if (!isset($frame['type'])) { + $frame['type'] = '::'; + } + + // XDebug has a different key name + $frame['args'] = array(); + if (isset($frame['params']) && !isset($frame['args'])) { + $frame['args'] = $frame['params']; + } + } + + $ref = new \ReflectionProperty('Exception', 'trace'); + $ref->setAccessible(true); + $ref->setValue($this, $trace); + } } /** @@ -62,20 +88,20 @@ class ErrorException extends Exception public function getName() { $names = array( - E_ERROR => \Yii::t('yii|Fatal Error'), - E_PARSE => \Yii::t('yii|Parse Error'), - E_CORE_ERROR => \Yii::t('yii|Core Error'), - E_COMPILE_ERROR => \Yii::t('yii|Compile Error'), - E_USER_ERROR => \Yii::t('yii|User Error'), - E_WARNING => \Yii::t('yii|Warning'), - E_CORE_WARNING => \Yii::t('yii|Core Warning'), - E_COMPILE_WARNING => \Yii::t('yii|Compile Warning'), - E_USER_WARNING => \Yii::t('yii|User Warning'), - E_STRICT => \Yii::t('yii|Strict'), - E_NOTICE => \Yii::t('yii|Notice'), - E_RECOVERABLE_ERROR => \Yii::t('yii|Recoverable Error'), - E_DEPRECATED => \Yii::t('yii|Deprecated'), + E_ERROR => Yii::t('yii|Fatal Error'), + E_PARSE => Yii::t('yii|Parse Error'), + E_CORE_ERROR => Yii::t('yii|Core Error'), + E_COMPILE_ERROR => Yii::t('yii|Compile Error'), + E_USER_ERROR => Yii::t('yii|User Error'), + E_WARNING => Yii::t('yii|Warning'), + E_CORE_WARNING => Yii::t('yii|Core Warning'), + E_COMPILE_WARNING => Yii::t('yii|Compile Warning'), + E_USER_WARNING => Yii::t('yii|User Warning'), + E_STRICT => Yii::t('yii|Strict'), + E_NOTICE => Yii::t('yii|Notice'), + E_RECOVERABLE_ERROR => Yii::t('yii|Recoverable Error'), + E_DEPRECATED => Yii::t('yii|Deprecated'), ); - return isset($names[$this->getCode()]) ? $names[$this->getCode()] : \Yii::t('yii|Error'); + return isset($names[$this->getCode()]) ? $names[$this->getCode()] : Yii::t('yii|Error'); } }