Skip to content

Conversation

@Krinkle
Copy link
Contributor

@Krinkle Krinkle commented Jun 15, 2025

Calling trigger_error with E_USER_ERROR was the idiom in PHP 5.x for fatal errors that were (theoretically) recoverable but not meant to be caught by generic catch (Exception $e) statements.

Since PHP 7.0, this has been obsoleted by the Throwable interface and the new Error class, which sits outside the Exception hierarchy.

Internal use, such as for calling an undefined method, also throw Error since PHP 7.0 (https://3v4l.org/Y9bFm), and calling trigger_error with E_USER_ERROR emits a deprecation warning as of PHP 8.4.0.

Since this project supports PHP 5.6+, the old code is kept under a <7.0 condition.

The PHP_VERSION_ID constant is available since PHP 5.2.7 (https://3v4l.org/ifWRP).

Fixes #155.

Calling trigger_error with E_USER_ERROR was the idiom in PHP 5.x
for fatal errors that were (theoretically) recoverable but not meant
to be caught by generic `catch (Exception $e)` statements.

Since PHP 7.0, this has been obsoleted by the Throwable interface
and the new Error class, which is outside the Exception hierarchy.

Internal uses, such as for calling an undefined method, have been
replaced by `throw new Error` since PHP 7.0, and calling trigger_error
with E_USER_ERROR emits a deprecation warning as of PHP 8.4.0.

Since this project supports PHP 5.6+, the old code is kept under a <7.0
condition.

The PHP_VERSION_ID constant is available since PHP 5.2.7,
https://3v4l.org/ifWRP.

Fixes pear#155.
@sonarqubecloud
Copy link

Copy link
Member

@CloCkWeRX CloCkWeRX left a comment

Choose a reason for hiding this comment

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

That seems sensible, and broadly backwards compatible. I'll leave it to other maintainers to make the final call.

@ashnazg ashnazg self-assigned this Jul 19, 2025
@ashnazg ashnazg merged commit 434510c into pear:master Jul 19, 2025
14 checks passed
@Krinkle Krinkle deleted the fix-php84-trigger branch July 19, 2025 22:20
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.

E_USER_ERROR is deprecated as of PHP 8.4.0

3 participants