summaryrefslogtreecommitdiff
path: root/lib/prado/framework/PradoBase.php
diff options
context:
space:
mode:
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