Skip to content

Conversation

@lacatoire
Copy link

Summary

This PR replaces deprecated usages of trigger_error(..., E_USER_ERROR)
with proper exception handling.
As of PHP 8.4, E_USER_ERROR is deprecated and will be removed in a future release.

Motivation

  • Ensures forward compatibility with PHP 8.4 and beyond.
  • Improves error semantics and debuggability.
  • Replaces legacy fatal error triggers with modern exception-based handling.

Scope

  • Replaced trigger_error(..., E_USER_ERROR) with:
    • throw new RuntimeException(...) for runtime failures (I/O, missing dirs, etc.)
    • throw new Error(...) for programming or internal state issues
  • Left E_USER_WARNING / E_USER_NOTICE untouched.

Example

Before:

mkdir($this->userNotesBaseDir, 0777, true)
    or trigger_error("Can't create dir: $this->userNotesBaseDir", E_USER_ERROR);
After:
if (!mkdir($this->userNotesBaseDir, 0777, true)) {
    throw new \RuntimeException(sprintf(
        "Can't create the usernotes directory: %s",
        $this->userNotesBaseDir
    ));
}

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.

1 participant