diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb21ad1..e712290 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.1', '8.2', '8.3', '8.4'] + php: ['8.1', '8.2', '8.3', '8.4', '8.5'] steps: - name: Checkout diff --git a/packages/logtide/src/Integration/ErrorListenerIntegration.php b/packages/logtide/src/Integration/ErrorListenerIntegration.php index 179f5d9..dd9541f 100644 --- a/packages/logtide/src/Integration/ErrorListenerIntegration.php +++ b/packages/logtide/src/Integration/ErrorListenerIntegration.php @@ -62,10 +62,13 @@ public function teardown(): void private static function severityToLevel(int $severity): LogLevel { + // E_STRICT is intentionally absent: the level was removed in PHP 8.0 and + // the constant itself is deprecated since 8.4, so referencing it here + // would emit a deprecation from inside the error handler. return match (true) { (bool) ($severity & (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR)) => LogLevel::CRITICAL, (bool) ($severity & (E_WARNING | E_CORE_WARNING | E_COMPILE_WARNING | E_USER_WARNING | E_RECOVERABLE_ERROR)) => LogLevel::WARN, - (bool) ($severity & (E_NOTICE | E_USER_NOTICE | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED)) => LogLevel::INFO, + (bool) ($severity & (E_NOTICE | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED)) => LogLevel::INFO, default => LogLevel::ERROR, }; } diff --git a/packages/logtide/src/Serializer/ErrorSerializer.php b/packages/logtide/src/Serializer/ErrorSerializer.php index 017df33..a9a9ed4 100644 --- a/packages/logtide/src/Serializer/ErrorSerializer.php +++ b/packages/logtide/src/Serializer/ErrorSerializer.php @@ -65,11 +65,13 @@ public static function serializePhpError(int $severity, string $message, string private static function errorLevelToString(int $level): string { + // E_STRICT is intentionally absent: the level was removed in PHP 8.0 and + // the constant itself is deprecated since 8.4, so referencing it here + // would emit a deprecation from inside the error handler. return match ($level) { E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR => 'E_ERROR', E_WARNING, E_CORE_WARNING, E_COMPILE_WARNING, E_USER_WARNING => 'E_WARNING', E_NOTICE, E_USER_NOTICE => 'E_NOTICE', - E_STRICT => 'E_STRICT', E_DEPRECATED, E_USER_DEPRECATED => 'E_DEPRECATED', E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', default => 'E_UNKNOWN', diff --git a/packages/logtide/tests/Unit/Serializer/ErrorSerializerTest.php b/packages/logtide/tests/Unit/Serializer/ErrorSerializerTest.php index c709b37..fa6d88b 100644 --- a/packages/logtide/tests/Unit/Serializer/ErrorSerializerTest.php +++ b/packages/logtide/tests/Unit/Serializer/ErrorSerializerTest.php @@ -82,6 +82,8 @@ public function testErrorLevelMapping(): void $this->assertSame('E_WARNING', ErrorSerializer::serializePhpError(E_WARNING, '', '', 0)['type']); $this->assertSame('E_NOTICE', ErrorSerializer::serializePhpError(E_NOTICE, '', '', 0)['type']); $this->assertSame('E_DEPRECATED', ErrorSerializer::serializePhpError(E_DEPRECATED, '', '', 0)['type']); - $this->assertSame('E_STRICT', ErrorSerializer::serializePhpError(E_STRICT, '', '', 0)['type']); + $this->assertSame('E_DEPRECATED', ErrorSerializer::serializePhpError(E_USER_DEPRECATED, '', '', 0)['type']); + $this->assertSame('E_RECOVERABLE_ERROR', ErrorSerializer::serializePhpError(E_RECOVERABLE_ERROR, '', '', 0)['type']); + $this->assertSame('E_UNKNOWN', ErrorSerializer::serializePhpError(0, '', '', 0)['type']); } } diff --git a/packages/logtide/tests/Unit/State/ScopeTest.php b/packages/logtide/tests/Unit/State/ScopeTest.php index 7d91191..477b8de 100644 --- a/packages/logtide/tests/Unit/State/ScopeTest.php +++ b/packages/logtide/tests/Unit/State/ScopeTest.php @@ -18,7 +18,6 @@ final class ScopeTest extends TestCase protected function tearDown(): void { $ref = new \ReflectionProperty(Scope::class, 'globalEventProcessors'); - $ref->setAccessible(true); $ref->setValue(null, []); } diff --git a/phpunit.xml b/phpunit.xml index 98d4626..2d9cefd 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -5,6 +5,7 @@ colors="true" failOnRisky="true" failOnWarning="true" + failOnDeprecation="true" displayDetailsOnTestsThatTriggerDeprecations="true">