fix E_STRICT deprecation notices on php 8.4 and 8.5 - #8
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7
What was wrong
E_STRICTwas referenced in two places on the error handling path:ErrorListenerIntegration::severityToLevel()(notice class bitmask)ErrorSerializer::errorLevelToString()(dedicated match arm)matcharms 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 extraConstant E_STRICT is deprecatedlines, 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=Onthat means raw text injected into responses.Why removing it is safe
The
E_STRICTlevel was removed in php 8.0 and nothing has raised it since. This package requiresphp: ^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:
phpunit.xmlhadfailOnRiskyandfailOnWarningbut notfailOnDeprecation, and the matrix stopped at 8.4.Changes
ErrorSerializer.php: drop theE_STRICTarm, unknown levels already fall through toE_UNKNOWNErrorListenerIntegration.php: dropE_STRICTfrom the notice class bitmaskErrorSerializerTest.php: replace theE_STRICTassertion with coverage forE_USER_DEPRECATED,E_RECOVERABLE_ERRORand theE_UNKNOWNfallbackScopeTest.php: dropReflectionProperty::setAccessible(), deprecated in 8.5 and a no-op since 8.1phpunit.xml: addfailOnDeprecation="true"ci.yml: add8.5to the test matrixVerification
On php 8.5.0 locally:
Zero deprecations, exit code 0. PHPStan level 8 clean, phpcs clean.