|
| 1 | +diff --git a/src/Runner/ErrorHandler.php b/src/Runner/ErrorHandler.php |
| 2 | +index 54f35aa41..94a2bb600 100644 |
| 3 | +--- a/src/Runner/ErrorHandler.php |
| 4 | ++++ b/src/Runner/ErrorHandler.php |
| 5 | +@@ -59,6 +59,11 @@ final class ErrorHandler |
| 6 | + private ?int $originalErrorReportingLevel = null; |
| 7 | + private readonly Source $source; |
| 8 | + |
| 9 | ++ /** |
| 10 | ++ * @var list<array{int, string, string, int}> |
| 11 | ++ */ |
| 12 | ++ private array $globalDeprecations = []; |
| 13 | ++ |
| 14 | + /** |
| 15 | + * @var ?array{functions: list<non-empty-string>, methods: list<array{className: class-string, methodName: non-empty-string}>} |
| 16 | + */ |
| 17 | +@@ -197,6 +202,23 @@ public function __invoke(int $errorNumber, string $errorString, string $errorFil |
| 18 | + return false; |
| 19 | + } |
| 20 | + |
| 21 | ++ public function deprecationHandler(int $errorNumber, string $errorString, string $errorFile, int $errorLine): bool |
| 22 | ++ { |
| 23 | ++ $this->globalDeprecations[] = [$errorNumber, $errorString, $errorFile, $errorLine]; |
| 24 | ++ |
| 25 | ++ return true; |
| 26 | ++ } |
| 27 | ++ |
| 28 | ++ public function registerDeprecationHandler(): void |
| 29 | ++ { |
| 30 | ++ set_error_handler([self::$instance, 'deprecationHandler'], E_USER_DEPRECATED); |
| 31 | ++ } |
| 32 | ++ |
| 33 | ++ public function restoreDeprecationHandler(): void |
| 34 | ++ { |
| 35 | ++ restore_error_handler(); |
| 36 | ++ } |
| 37 | ++ |
| 38 | + public function enable(): void |
| 39 | + { |
| 40 | + if ($this->enabled) { |
| 41 | +@@ -213,6 +235,7 @@ public function enable(): void |
| 42 | + |
| 43 | + $this->enabled = true; |
| 44 | + $this->originalErrorReportingLevel = error_reporting(); |
| 45 | ++ $this->triggerGlobalDeprecations(); |
| 46 | + |
| 47 | + error_reporting($this->originalErrorReportingLevel & self::UNHANDLEABLE_LEVELS); |
| 48 | + } |
| 49 | +@@ -422,4 +445,11 @@ private function stackTrace(): string |
| 50 | + |
| 51 | + return $buffer; |
| 52 | + } |
| 53 | ++ |
| 54 | ++ private function triggerGlobalDeprecations(): void |
| 55 | ++ { |
| 56 | ++ foreach ($this->globalDeprecations ?? [] as $d) { |
| 57 | ++ $this->__invoke(...$d); |
| 58 | ++ } |
| 59 | ++ } |
| 60 | + } |
| 61 | +diff --git a/src/TextUI/Application.php b/src/TextUI/Application.php |
| 62 | +index ca6da7005..d8965d41b 100644 |
| 63 | +--- a/src/TextUI/Application.php |
| 64 | ++++ b/src/TextUI/Application.php |
| 65 | +@@ -178,8 +178,12 @@ public function run(array $argv): int |
| 66 | + |
| 67 | + EventFacade::instance()->seal(); |
| 68 | + |
| 69 | ++ ErrorHandler::instance()->registerDeprecationHandler(); |
| 70 | ++ |
| 71 | + $testSuite = $this->buildTestSuite($configuration); |
| 72 | + |
| 73 | ++ ErrorHandler::instance()->restoreDeprecationHandler(); |
| 74 | ++ |
| 75 | + $this->executeCommandsThatRequireTheTestSuite($configuration, $cliConfiguration, $testSuite); |
| 76 | + |
| 77 | + if ($testSuite->isEmpty() && !$configuration->hasCliArguments() && $configuration->testSuite()->isEmpty()) { |
0 commit comments