From d7d8e73cfc78788ff6c77575e2e7657401282bf2 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 19 Sep 2024 12:22:05 +0200 Subject: [PATCH] Closes #5956 --- ChangeLog-8.5.md | 1 + src/Util/ErrorHandler.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog-8.5.md b/ChangeLog-8.5.md index 44e3d82c44c..ad71022ccbf 100644 --- a/ChangeLog-8.5.md +++ b/ChangeLog-8.5.md @@ -6,6 +6,7 @@ All notable changes of the PHPUnit 8.5 release series are documented in this fil ### Changed +* [#5956](https://github.com/sebastianbergmann/phpunit/issues/5956): Deprecation of the `E_STRICT` constant in PHP 8.4 * Removed `.phpstorm.meta.php` file as methods such as `TestCase::createStub()` use generics / template types for their return types and PhpStorm, for example, uses that information ## [8.5.39] - 2024-07-10 diff --git a/src/Util/ErrorHandler.php b/src/Util/ErrorHandler.php index f8566347e84..0a42327f15a 100644 --- a/src/Util/ErrorHandler.php +++ b/src/Util/ErrorHandler.php @@ -16,6 +16,7 @@ use const E_USER_NOTICE; use const E_USER_WARNING; use const E_WARNING; +use function defined; use function error_reporting; use function restore_error_handler; use function set_error_handler; @@ -93,10 +94,18 @@ public function __invoke(int $errorNumber, string $errorString, string $errorFil return false; } + /** + * E_STRICT is deprecated since PHP 8.4. + * + * @see https://github.com/sebastianbergmann/phpunit/issues/5956 + */ + if (defined('E_STRICT') && $errorNumber === @E_STRICT) { + $errorNumber = E_NOTICE; + } + switch ($errorNumber) { case E_NOTICE: case E_USER_NOTICE: - case E_STRICT: if (!$this->convertNoticesToExceptions) { return false; }