summaryrefslogtreecommitdiff
path: root/lib/prado/framework/PradoBase.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-04-07 16:09:16 +0200
committeremkael <emkael@tlen.pl>2016-04-07 16:09:16 +0200
commitd42b25cbf6d3f1e51cb2a3149f1ff54cc5474bc9 (patch)
tree96b734357392d6094cfc5f8284ad8f2578b96b7f /lib/prado/framework/PradoBase.php
parentac6c2b9c4f787dfdfa00547f764c77d80dad14c0 (diff)
* Prado upgrade (to 3.3.r6b8e6601752b21a8a96c385a5529bbec7bb2b408)
Diffstat (limited to 'lib/prado/framework/PradoBase.php')
-rw-r--r--lib/prado/framework/PradoBase.php29
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/prado/framework/PradoBase.php b/lib/prado/framework/PradoBase.php
index de8c465..7cd2618 100644
--- a/lib/prado/framework/PradoBase.php
+++ b/lib/prado/framework/PradoBase.php
@@ -7,7 +7,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link https://github.com/pradosoft/prado
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
+ * @copyright Copyright &copy; 2005-2016 The PRADO Group
* @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
* @package System
*/
@@ -84,9 +84,17 @@ class PradoBase
*/
set_error_handler(array('PradoBase','phpErrorHandler'));
/**
+ * Sets shutdown function to be Prado::phpFatalErrorHandler
+ */
+ register_shutdown_function(array('PradoBase','phpFatalErrorHandler'));
+ /**
* Sets exception handler to be Prado::exceptionHandler
*/
set_exception_handler(array('PradoBase','exceptionHandler'));
+ /**
+ * Disable php's builtin error reporting to avoid duplicated reports
+ */
+ ini_set('display_errors', 0);
}
/**
@@ -97,8 +105,6 @@ class PradoBase
public static function autoload($className)
{
include_once($className.self::CLASS_FILE_EXT);
- if(!class_exists($className,false) && !interface_exists($className,false))
- self::fatalError("Class file for '$className' cannot be found.");
}
/**
@@ -135,6 +141,23 @@ class PradoBase
}
/**
+ * PHP shutdown function used to catch fatal errors.
+ * This method should be registered as PHP error handler using
+ * {@link register_shutdown_function}. The method throws an exception that
+ * contains the error information.
+ */
+ public static function phpFatalErrorHandler()
+ {
+ $error = error_get_last();
+ if($error &&
+ TPhpErrorException::isFatalError($error) &&
+ error_reporting() & $error['type'])
+ {
+ self::exceptionHandler(new TPhpErrorException($error['type'],$error['message'],$error['file'],$error['line']));
+ }
+ }
+
+ /**
* Default exception handler.
* This method should be registered as default exception handler using
* {@link set_exception_handler}. The method tries to use the errorhandler