diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 332802fe6f..cc698ee533 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -352,7 +352,7 @@ class ErrorHandler */ public function handleError($type, $message, $file, $line, array $context, array $backtrace = null) { - $level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR; + $level = error_reporting() | E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED; $log = $this->loggedErrors & $type; $throw = $this->thrownErrors & $type & $level; $type &= $level | $this->screamedErrors; diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 5d521a1434..c107c0c7cb 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -268,6 +268,28 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase } } + public function testHandleDeprecation() + { + $that = $this; + $logArgCheck = function ($level, $message, $context) use ($that) { + $that->assertEquals(LogLevel::INFO, $level); + $that->assertArrayHasKey('level', $context); + $that->assertEquals(E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED, $context['level']); + $that->assertArrayHasKey('stack', $context); + }; + + $logger = $this->getMock('Psr\Log\LoggerInterface'); + $logger + ->expects($this->once()) + ->method('log') + ->will($this->returnCallback($logArgCheck)) + ; + + $handler = new ErrorHandler(); + $handler->setDefaultLogger($logger); + @$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, array()); + } + public function testHandleException() { try {