diff --git a/ChangeLog-8.5.md b/ChangeLog-8.5.md index 44e3d82c44..ad71022ccb 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 f8566347e8..0a42327f15 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; }