Fixed PHP 8.2 deprecated dynamic property creation warning #604
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.
This PR fixes the PHP 8.2 deprecated dynamic property creation warning issue #590.
Description of the change
This adds a new class
ExceptionWrapper
to the SDK. It is used by theExceptionHandler::handle()
andRollbar::logUncaught()
methods. Both functions need to inform theRollbarLogger::report()
method that theException
instance we are passing it is on that was caught by the Rollbar SDK. To do that we had been setting theisUncaught
property on theException
instance. However, theException
class does not have anisUncaught
property. This means we were dynamically creating the property; something PHP allows. However, in PHP 8.2 dynamic property creation has been deprecated.ExceptionWrapper
let's us wrap the exception so that it can be passed to theRollbarLogger::log()
method and include anisUncaught
property while keeping thelog()
method compliant with the PSR logging interface.For test review purposes I pushed the test to the branch first. You can see the failed test in our CI (while the test logs are retained). Also, note, that in the latest commit to this branch the test passes.
This also fixes all the dynamic properties I could find in the test suite.
Type of change
Related issues
Checklists
Development
Code review