This repository was archived by the owner on Jul 31, 2025. It is now read-only.
Fix Argument Count Error in phpagi_error_handler() for PHP 8 Compatibility #35
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.
Summary
This PR removes the
$context
parameter from thephpagi_error_handler()
function to resolve an "ArgumentCountError" that occurs in PHP 8.1 when usingset_error_handler()
.Problem
In PHP 8.1,
set_error_handler()
only passes 4 arguments by default:$level
$message
$file
$line
However,
phpagi_error_handler()
is currently defined with 5 parameters:Problem
Solution
The $context parameter is not used anywhere in the function, so it is safe to remove it.
This change ensures full compatibility with PHP 8.1 while maintaining the expected behavior.
Changes in This PR
Modified phpagi_error_handler() to accept only 4 parameters (removing $context).
Updated send_error_email() to align with the new function signature.
Before (causing error in PHP 8.1)
After (fixes PHP 8.1 error)
Impact
✅ Fixes compatibility issues in PHP 8.1
✅ No change in behavior, as $context was never used
✅ Improves stability for projects using PHP 8.1+
Testing
Tested with PHP 8.1.
No regression found in error handling functionality.