|
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 | }
|
@@ -351,6 +357,8 @@ private static function getPhpUnitErrorHandler()
|
351 | 357 | if (!$eh = self::$errorHandler) {
|
352 | 358 | if (class_exists(Handler::class)) {
|
353 | 359 | $eh = self::$errorHandler = Handler::class;
|
| 360 | + } elseif (method_exists(UtilErrorHandler::class, '__invoke')) { |
| 361 | + $eh = self::$errorHandler = UtilErrorHandler::class; |
354 | 362 | } elseif (method_exists(ErrorHandler::class, '__invoke')) {
|
355 | 363 | $eh = self::$errorHandler = ErrorHandler::class;
|
356 | 364 | } else {
|
|
0 commit comments