From 0c1d5a2d37ab9c0fc1fa3d741b3819b380d1d6d9 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 24 Oct 2017 19:59:40 +0100 Subject: [PATCH 1/3] Fix PHP5 --- .../Bridge/PhpUnit/DeprecationErrorHandler.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 9397af1f22799..fbba7020f4133 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -251,15 +251,18 @@ public static function collectDeprecations($outputFile) $deprecations = array(); $previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, &$previousErrorHandler) { if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { - return $previousErrorHandler ? $previousErrorHandler($type, $msg, $file, $line, $context) : false; + // This can be registered before the PHPUnit error handler. + if (!$previousErrorHandler) { + $ErrorHandler = class_exists('PHPUnit_Util_ErrorHandler') ? 'PHPUnit_Util_ErrorHandler' : 'PHPUnit\Util\ErrorHandler'; + return $ErrorHandler::handleError($type, $msg, $file, $line, $context); + } + else { + return $previousErrorHandler($type, $msg, $file, $line, $context); + } + } $deprecations[] = array(error_reporting(), $msg); }); - // This can be registered before the PHPUnit error handler. - if (!$previousErrorHandler) { - $UtilPrefix = class_exists('PHPUnit_Util_ErrorHandler') ? 'PHPUnit_Util_' : 'PHPUnit\Util\\'; - $previousErrorHandler = $UtilPrefix.'ErrorHandler::handleError'; - } register_shutdown_function(function () use ($outputFile, &$deprecations) { file_put_contents($outputFile, serialize($deprecations)); From 8439029bba6852ced79e07ac7bd0e76939937108 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 24 Oct 2017 20:05:05 +0100 Subject: [PATCH 2/3] Fix coding standards --- src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index fbba7020f4133..cbddcdf7f8ed1 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -254,12 +254,11 @@ public static function collectDeprecations($outputFile) // This can be registered before the PHPUnit error handler. if (!$previousErrorHandler) { $ErrorHandler = class_exists('PHPUnit_Util_ErrorHandler') ? 'PHPUnit_Util_ErrorHandler' : 'PHPUnit\Util\ErrorHandler'; + return $ErrorHandler::handleError($type, $msg, $file, $line, $context); - } - else { + } else { return $previousErrorHandler($type, $msg, $file, $line, $context); } - } $deprecations[] = array(error_reporting(), $msg); }); From bc777a5bce0fe9c7792d2ab92b355d4b0744bd18 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 24 Oct 2017 20:52:09 +0100 Subject: [PATCH 3/3] Don't use autoloader in class_exists() check --- .../Bridge/PhpUnit/DeprecationErrorHandler.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index cbddcdf7f8ed1..53f27477d78cc 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -251,14 +251,13 @@ public static function collectDeprecations($outputFile) $deprecations = array(); $previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, &$previousErrorHandler) { if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { - // This can be registered before the PHPUnit error handler. - if (!$previousErrorHandler) { - $ErrorHandler = class_exists('PHPUnit_Util_ErrorHandler') ? 'PHPUnit_Util_ErrorHandler' : 'PHPUnit\Util\ErrorHandler'; - - return $ErrorHandler::handleError($type, $msg, $file, $line, $context); - } else { + if ($previousErrorHandler) { return $previousErrorHandler($type, $msg, $file, $line, $context); } + + $ErrorHandler = class_exists('PHPUnit_Util_ErrorHandler', false) ? 'PHPUnit_Util_ErrorHandler' : 'PHPUnit\Util\ErrorHandler'; + + return $ErrorHandler::handleError($type, $msg, $file, $line, $context); } $deprecations[] = array(error_reporting(), $msg); });