Add PHP 8.1 compatibility #60
Merged
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.
Fixes
Without these fixes you will encounter PHP messages similar to these when using modern versions of PHP (8.1+):
and
...plus a few others related to the various other
Iteratormethods inResourceCollection.php.Background
For a while we've been using an internally patched version of the older 2.x Trolley PHP SDK (the version previously using the
PaymentRailsnamespace).Given the recent library upgrades here and the new published versions, complete with new
Trolleynamespace, we decided to upgrade to the latest SDK here. In doing so we noticed these issues again, so I decided to go ahead and fork and create this PR!Notes
In the future you might consider adding return types within
ResourceCollection.phpas well and remove the#[\ReturnTypeWillChange]attributes which just suppress the notices. This may involve a little more work to ensure proper return types for each method.The
substr()deprecation fix we went with uses null coalescing and this requires PHP 7.0 or higher, so I've updated that dependency incomposer.jsonand updated the readme.Checklist