Skip to content

fix E_STRICT deprecation notices on php 8.4 and 8.5 - #8

Merged
Polliog merged 1 commit into
mainfrom
hotfix/e-strict-deprecation
Aug 21, 2026
Merged

fix E_STRICT deprecation notices on php 8.4 and 8.5#8
Polliog merged 1 commit into
mainfrom
hotfix/e-strict-deprecation

Conversation

@Polliog

@Polliog Polliog commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #7

What was wrong

E_STRICT was referenced in two places on the error handling path:

  • ErrorListenerIntegration::severityToLevel() (notice class bitmask)
  • ErrorSerializer::errorLevelToString() (dedicated match arm)

match arms are evaluated lazily and in order, so the constant was only touched when the severity was notice or deprecation class. That is why every single notice raised by the host app produced exactly two extra Constant E_STRICT is deprecated lines, one per file.

Worse, the deprecation is raised from inside the error handler, and php does not re-enter the user handler while it is already running. So the message falls through to the default handler and gets printed to the output or the php log, and is never captured by LogTide. With display_errors=On that means raw text injected into responses.

Why removing it is safe

The E_STRICT level was removed in php 8.0 and nothing has raised it since. This package requires php: ^8.1, so both arms were unreachable dead code. Behaviour is identical on 8.1 through 8.5.

It is also not just cosmetic: in php 9.0 the constant is removed entirely, which would throw Error: Undefined constant "E_STRICT" from inside the error handler.

Why CI missed it

CI was already reporting the deprecation on the 8.4 job and passing anyway:

1 test triggered 2 PHP deprecations:
1) packages/logtide/src/Serializer/ErrorSerializer.php:72
   Constant E_STRICT is deprecated since 8.4, the error level was removed
OK, but there were issues!

phpunit.xml had failOnRisky and failOnWarning but not failOnDeprecation, and the matrix stopped at 8.4.

Changes

  • ErrorSerializer.php: drop the E_STRICT arm, unknown levels already fall through to E_UNKNOWN
  • ErrorListenerIntegration.php: drop E_STRICT from the notice class bitmask
  • ErrorSerializerTest.php: replace the E_STRICT assertion with coverage for E_USER_DEPRECATED, E_RECOVERABLE_ERROR and the E_UNKNOWN fallback
  • ScopeTest.php: drop ReflectionProperty::setAccessible(), deprecated in 8.5 and a no-op since 8.1
  • phpunit.xml: add failOnDeprecation="true"
  • ci.yml: add 8.5 to the test matrix

Verification

On php 8.5.0 locally:

OK (276 tests, 592 assertions)

Zero deprecations, exit code 0. PHPStan level 8 clean, phpcs clean.

E_STRICT was referenced in two spots on the error handling path:
ErrorListenerIntegration::severityToLevel() and
ErrorSerializer::errorLevelToString(). Both match arms are evaluated
lazily, so the constant was only touched for notice and deprecation
level diagnostics, which is why every app notice produced two extra
'Constant E_STRICT is deprecated' lines. Those lines were printed by
php itself instead of being captured, since php does not re-enter the
user error handler while it is already running.

The level was removed back in php 8.0 and this package requires ^8.1,
so both arms were dead code already. In php 9.0 the constant is gone
entirely, which would have thrown Undefined constant inside the error
handler.

Also drops a ReflectionProperty::setAccessible() call deprecated in 8.5,
adds failOnDeprecation to phpunit.xml so this class of issue breaks the
build instead of passing silently, and adds 8.5 to the CI matrix.

Fixes #7
@Polliog
Polliog merged commit c29bea9 into main Aug 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

There are deprecation notices logged when using in php 8.5

1 participant