8000 bug #50048 [PhpUnitBridge] Fix PHPUnit 10.1 compatibility (enumag) · magnusnordlander/symfony@6470cc4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6470cc4

Browse files
bug symfony#50048 [PhpUnitBridge] Fix PHPUnit 10.1 compatibility (enumag)
This PR was merged into the 5.4 branch. Discussion ---------- [PhpUnitBridge] Fix PHPUnit 10.1 compatibility | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | PHPUnit 10.1 moved the ErrorHandler class *again*. See sebastianbergmann/phpunit@9e60ead Commits ------- 8b2fe33 [PHPUnitBridge] Fix PHPUnit 10.1 compatibility
2 parents 6aacbd9 + 8b2fe33 commit 6470cc4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
namespace Symfony\Bridge\PhpUnit;
1313

1414
use PHPUnit\Framework\TestResult;
15+
use PHPUnit\Runner\ErrorHandler;
1516
use PHPUnit\Util\Error\Handler;
16-
use PHPUnit\Util\ErrorHandler;
17+
use PHPUnit\Util\ErrorHandler as UtilErrorHandler;
1718
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration;
1819
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
1920
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup;
@@ -75,7 +76,12 @@ public static function register($mode = 0)
7576
if (null !== $oldErrorHandler) {
7677
restore_error_handler();
7778

78-
if ($oldErrorHandler instanceof ErrorHandler || [ErrorHandler::class, 'handleError'] === $oldErrorHandler) {
79+
if (
80+
$oldErrorHandler instanceof UtilErrorHandler
81+
|| [UtilErrorHandler::class, 'handleError'] === $oldErrorHandler
82+
|| $oldErrorHandler instanceof ErrorHandler
83+
|| [ErrorHandler::class, 'handleError'] === $oldErrorHandler
84+
) {
7985
restore_error_handler();
8086
self::register($mode);
8187
}
@@ -351,6 +357,8 @@ private static function getPhpUnitErrorHandler()
351357
if (!$eh = self::$errorHandler) {
352358
if (class_exists(Handler::class)) {
353359
$eh = self::$errorHandler = Handler::class;
360+
} elseif (method_exists(UtilErrorHandler::class, '__invoke')) {
361+
$eh = self::$errorHandler = UtilErrorHandler::class;
354362
} elseif (method_exists(ErrorHandler::class, '__invoke')) {
355363
$eh = self::$errorHandler = ErrorHandler::class;
356364
} else {

0 commit comments

Comments
 (0)
0