|
12 | 12 | namespace Symfony\Bridge\PhpUnit; |
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestResult; |
| 15 | +use PHPUnit\Runner\ErrorHandler; |
15 | 16 | use PHPUnit\Util\Error\Handler; |
16 | | -use PHPUnit\Util\ErrorHandler; |
| 17 | +use PHPUnit\Util\ErrorHandler as UtilErrorHandler; |
17 | 18 | use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration; |
18 | 19 | use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation; |
19 | 20 | use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup; |
@@ -75,7 +76,12 @@ public static function register($mode = 0) |
75 | 76 | if (null !== $oldErrorHandler) { |
76 | 77 | restore_error_handler(); |
77 | 78 |
|
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 | + ) { |
79 | 85 | restore_error_handler(); |
80 | 86 | self::register($mode); |
81 | 87 | } |
@@ -359,6 +365,8 @@ private static function getPhpUnitErrorHandler(): callable |
359 | 365 | if (!$eh = self::$errorHandler) { |
360 | 366 | if (class_exists(Handler::class)) { |
361 | 367 | $eh = self::$errorHandler = Handler::class; |
| 368 | + } elseif (method_exists(UtilErrorHandler::class, '__invoke')) { |
| 369 | + $eh = self::$errorHandler = UtilErrorHandler::class; |
362 | 370 | } elseif (method_exists(ErrorHandler::class, '__invoke')) { |
363 | 371 | $eh = self::$errorHandler = ErrorHandler::class; |
364 | 372 | } else { |
|
0 commit comments