Skip to content

Conversation

@marcing
Copy link
Collaborator

@marcing marcing commented Apr 11, 2025

PHP 8.4: E_STRICT constant deprecated
https://php.watch/versions/8.4/E_STRICT-deprecated

@marcing marcing requested review from falkenhawk and partikus April 11, 2025 09:43
Comment on lines 583 to 586
$errorLevels = E_ALL | E_STRICT;
if (PHP_VERSION_ID >= 70400) {
$errorLevels = E_ALL;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be safer to reverse the condition, and use E_STRICT only inside a condition block.

Copy link
Collaborator Author

@marcing marcing Apr 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@falkenhawk True, thank you!
Edit: done!


if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) {
if ($errno == E_NOTICE || $errno == E_USER_NOTICE
|| (PHP_VERSION_ID < 70400 && $errno == E_STRICT)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|| (PHP_VERSION_ID < 70400 && $errno == E_STRICT)) {
|| (PHP_VERSION_ID < 80400 && $errno == E_STRICT)) {

Shouldn't the deprecation start with 8.4? not 7.4?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glensc According to this, some functions already emit deprecation notice starting 7.4:
https://php.watch/versions/8.4/E_STRICT-deprecated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the linked article:

It is safe to assume that any PHP applications that run on PHP 8.0 and later will never encounter E_STRICT notices

but still the correct check would be <= 70400 or < 80000 instead of < 70400 @marcing

$errorLevels = E_ALL;
if (PHP_VERSION_ID < 70400) {
$errorLevels = E_ALL | E_STRICT;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatives:

single line:

$errorLevels = PHP_VERSION_ID < 70400 ? E_ALL | E_STRICT : E_ALL;`

multiline:

$errorLevels = E_ALL;

if (PHP_VERSION_ID < 70400) {
    $errorLevels |= E_STRICT;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the current one is clear enough and easy to understand.

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.

4 participants