Skip to content

Commit

Permalink
[PHPUnitBridge] Fix PHPUnit 10.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
enumag committed Apr 18, 2023
1 parent 28d8a15 commit 1572c5b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
namespace Symfony\Bridge\PhpUnit;

use PHPUnit\Framework\TestResult;
use PHPUnit\Runner\ErrorHandler;
use PHPUnit\Util\Error\Handler;
use PHPUnit\Util\ErrorHandler;
use PHPUnit\Util\ErrorHandler as UtilErrorHandler;
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration;
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup;
Expand Down Expand Up @@ -75,7 +76,12 @@ public static function register($mode = 0)
if (null !== $oldErrorHandler) {
restore_error_handler();

if ($oldErrorHandler instanceof ErrorHandler || [ErrorHandler::class, 'handleError'] === $oldErrorHandler) {
if (
$oldErrorHandler instanceof UtilErrorHandler
|| [UtilErrorHandler::class, 'handleError'] === $oldErrorHandler
|| $oldErrorHandler instanceof ErrorHandler
|| [ErrorHandler::class, 'handleError'] === $oldErrorHandler
) {
restore_error_handler();
self::register($mode);
}
Expand Down Expand Up @@ -351,6 +357,8 @@ private static function getPhpUnitErrorHandler()
if (!$eh = self::$errorHandler) {
if (class_exists(Handler::class)) {
$eh = self::$errorHandler = Handler::class;
} elseif (method_exists(UtilErrorHandler::class, '__invoke')) {
$eh = self::$errorHandler = UtilErrorHandler::class;
} elseif (method_exists(ErrorHandler::class, '__invoke')) {
$eh = self::$errorHandler = ErrorHandler::class;
} else {
Expand Down

0 comments on commit 1572c5b

Please sign in to comment.