diff --git a/src/Whoops/Run.php b/src/Whoops/Run.php index 63469d3..ff1e527 100644 --- a/src/Whoops/Run.php +++ b/src/Whoops/Run.php @@ -302,7 +302,8 @@ class Run * @param string $file * @param int $line * - * @return bool|null + * @return bool + * @throws ErrorException */ public function handleError($level, $message, $file = null, $line = null) { @@ -322,7 +323,13 @@ class Run } else { $this->handleException($exception); } + // Do not propagate errors which were already handled by Whoops. + return true; } + + // Propagate error to the next handler, allows error_get_last() to + // work on silenced errors. + return false; } /** diff --git a/tests/Whoops/RunTest.php b/tests/Whoops/RunTest.php index 053a539..2a4a276 100755 --- a/tests/Whoops/RunTest.php +++ b/tests/Whoops/RunTest.php @@ -346,6 +346,24 @@ class RunTest extends TestCase $this->assertTrue(true); } + /** + * @covers Whoops\Run::handleError + */ + public function testGetSilencedError() + { + $run = $this->getRunInstance(); + $run->register(); + + $handler = $this->getHandler(); + $run->pushHandler($handler); + + @strpos(); + + $error = error_get_last(); + + $this->assertTrue($error && strpos($error['message'], 'strpos()') !== false); + } + /** * @covers Whoops\Run::handleException * @covers Whoops\Run::writeToOutput