diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 6a7ad1fa98828..550cbe375f7a1 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -112,7 +112,7 @@ public static function register($mode = 0) $trace = debug_backtrace(true); $group = 'other'; - $isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($file)); + $isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (self::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($file)); $i = count($trace); while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) { @@ -196,7 +196,7 @@ public static function register($mode = 0) $colorize = function ($str) { return $str; }; } if ($currErrorHandler !== $deprecationHandler) { - echo "\n", $colorize('THE ERROR HANDLER HAS CHANGED!', true), "\n"; + echo "\n", $colorize("THE ERROR HANDLER HAS CHANGED!\n".var_export(error_get_last(), true), true), "\n"; } $cmp = function ($a, $b) { diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/failure.phpt b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/failure.phpt new file mode 100644 index 0000000000000..2622b33e371e2 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/failure.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test DeprecationErrorHandler failure +--FILE-- + E_ERROR, + 'message' => 'failed to load flux capacitor', + 'file' => '/wherever/the/deprecation_handler_is', + 'line' => 42 + ); +} + +putenv('SYMFONY_DEPRECATIONS_HELPER'); +putenv('ANSICON'); +putenv('ConEmuANSI'); +putenv('TERM'); + +$vendor = __DIR__; +while (!file_exists($vendor.'/vendor')) { + $vendor = dirname($vendor); +} +define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php'); +require PHPUNIT_COMPOSER_INSTALL; +require_once __DIR__.'/../../bootstrap.php'; + +trigger_error('test failure', E_USER_DEPRECATED); +set_error_handler('var_dump'); + +--EXPECTF-- +THE ERROR HANDLER HAS CHANGED! +array ( + 'type' => 1, + 'message' => 'failed to load flux capacitor', + 'file' => '/wherever/the/deprecation_handler_is', + 'line' => 42, +) + +Other deprecation notices (1) + +test failure: 1x