diff --git a/src/Configuration.php b/src/Configuration.php index 35cc8627..a573dea3 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -1023,7 +1023,12 @@ public function useUnicode(): bool */ public function setErrorLoggingLevel($errorLoggingLevel) { - $this->errorLoggingLevel = (\E_ALL | \E_STRICT) & $errorLoggingLevel; + if (PHP_VERSION_ID < 80400) { + $this->errorLoggingLevel = (\E_ALL | \E_STRICT) & $errorLoggingLevel; + } + else { + $this->errorLoggingLevel = \E_ALL & $errorLoggingLevel; + } } /** diff --git a/src/Exception/ErrorException.php b/src/Exception/ErrorException.php index ef3f3570..2600735d 100644 --- a/src/Exception/ErrorException.php +++ b/src/Exception/ErrorException.php @@ -37,10 +37,6 @@ public function __construct($message = '', $code = 0, $severity = 1, $filename = } switch ($severity) { - case \E_STRICT: - $type = 'Strict error'; - break; - case \E_NOTICE: case \E_USER_NOTICE: $type = 'Notice'; @@ -63,6 +59,10 @@ public function __construct($message = '', $code = 0, $severity = 1, $filename = break; default: + if (\PHP_VERSION_ID < 80400 && $severity === \E_STRICT) { + $type = 'Strict error'; + break; + } $type = 'Error'; break; } diff --git a/src/Shell.php b/src/Shell.php index 3cc89c70..8ebec639 100644 --- a/src/Shell.php +++ b/src/Shell.php @@ -1302,10 +1302,12 @@ protected function getSeverity(\ErrorException $e): string case \E_USER_NOTICE: case \E_USER_DEPRECATED: case \E_DEPRECATED: - case \E_STRICT: return 'warning'; default: + if ((\PHP_VERSION_ID < 80400) && $severity === \E_STRICT) { + return 'warning'; + } return 'error'; } } else { diff --git a/test/Exception/ErrorExceptionTest.php b/test/Exception/ErrorExceptionTest.php index 97ac7e6a..30cbbdaf 100644 --- a/test/Exception/ErrorExceptionTest.php +++ b/test/Exception/ErrorExceptionTest.php @@ -59,17 +59,19 @@ public function testThrowException($level, $type) public function getLevels() { - return [ - [\E_WARNING, 'Warning'], - [\E_CORE_WARNING, 'Warning'], - [\E_COMPILE_WARNING, 'Warning'], - [\E_USER_WARNING, 'Warning'], - [\E_STRICT, 'Strict error'], - [\E_DEPRECATED, 'Deprecated'], - [\E_USER_DEPRECATED, 'Deprecated'], - [\E_RECOVERABLE_ERROR, 'Recoverable fatal error'], - [0, 'Error'], - ]; + yield [\E_WARNING, 'Warning']; + yield [\E_CORE_WARNING, 'Warning']; + yield [\E_COMPILE_WARNING, 'Warning']; + yield [\E_USER_WARNING, 'Warning']; + + if (PHP_VERSION_ID < 80400) { + yield [\E_STRICT, 'Strict error']; + } + + yield [\E_DEPRECATED, 'Deprecated']; + yield [\E_USER_DEPRECATED, 'Deprecated']; + yield [\E_RECOVERABLE_ERROR, 'Recoverable fatal error']; + yield [0, 'Error']; } /**