Skip to content

Commit 1572c5b

Browse files
committed
[PHPUnitBridge] Fix PHPUnit 10.1 compatibility
1 parent 28d8a15 commit 1572c5b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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)