diff --git a/ChangeLog-10.5.md b/ChangeLog-10.5.md index 05851fd05f..81540aabd8 100644 --- a/ChangeLog-10.5.md +++ b/ChangeLog-10.5.md @@ -4,6 +4,10 @@ All notable changes of the PHPUnit 10.5 release series are documented in this fi ## [10.5.35] - 2024-MM-DD +### Changed + +* [#5956](https://github.com/sebastianbergmann/phpunit/issues/5956): Deprecation of the `E_STRICT` constant in PHP 8.4 + ### Fixed * [#5950](https://github.com/sebastianbergmann/phpunit/pull/5950): TestDox text should not be `trim()`med when it contains `$` character diff --git a/src/Runner/ErrorHandler.php b/src/Runner/ErrorHandler.php index 24487ed3e1..f3357f3d85 100644 --- a/src/Runner/ErrorHandler.php +++ b/src/Runner/ErrorHandler.php @@ -24,6 +24,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; @@ -63,6 +64,15 @@ 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; + } + $test = Event\Code\TestMethodBuilder::fromCallStack(); $ignoredByBaseline = $this->ignoredByBaseline($errorFile, $errorLine, $errorString); @@ -70,7 +80,6 @@ public function __invoke(int $errorNumber, string $errorString, string $errorFil switch ($errorNumber) { case E_NOTICE: - case E_STRICT: Event\Facade::emitter()->testTriggeredPhpNotice( $test, $errorString,