diff --git a/exception/ErrorHandler.php b/exception/ErrorHandler.php index eec155e..954f8dc 100644 --- a/exception/ErrorHandler.php +++ b/exception/ErrorHandler.php @@ -23,7 +23,10 @@ class ErrorHandler if (!empty($ob_handlers)) { ob_end_clean(); } - throw new ErrorException($errstr, 0, $errno, $errfile, $errline); + if (error_reporting() !== 0) { + throw new ErrorException($errstr, 0, $errno, $errfile, $errline); + } + return true; } static protected function getSource($file, $hiline) diff --git a/tests/exception/ErrorHandlerTest.php b/tests/exception/ErrorHandlerTest.php index acbed11..4789eaf 100644 --- a/tests/exception/ErrorHandlerTest.php +++ b/tests/exception/ErrorHandlerTest.php @@ -39,6 +39,19 @@ class ErrorHandlerTest extends PHPUnit_Framework_TestCase trigger_error("test error", E_USER_ERROR); } + public function testHandleAt() + { + $my_eh = array('ErrorHandler', 'error_handler'); + ErrorHandler::init(); + set_error_handler($my_eh); + $var = ''; + $ok = @$var['some']; + $this->assertSame('', $var); + ob_start(); + $this->setExpectedException('ErrorException'); + $ex = $var['some']; + } + /** * @TODO: ErrorHandler->wrapTrace() not used */