PHP 8.5 | FilteredIterator: do not accept objects#968
Merged
schlessera merged 1 commit intodevelopfrom Nov 20, 2025
Merged
Conversation
The tests for the `FilteredIterator::__construct()` method were failing on PHP 8.5 as we were explicitly testing the class for accepting objects. While this _is_ still supported on PHP 8.5, it is deprecated and results in the following deprecation notices: ``` 1) /home/runner/work/Requests/Requests/src/Utility/FilteredIterator.php:43 ArrayIterator::__construct(): Using an object as a backing array for ArrayIterator is deprecated, as it allows violating class constraints and invariants Triggered by: * WpOrg\Requests\Tests\Utility\FilteredIterator\ConstructorTest::testValidData#ArrayIterator object /home/runner/work/Requests/Requests/tests/Utility/FilteredIterator/ConstructorTest.php:26 * WpOrg\Requests\Tests\Utility\FilteredIterator\ConstructorTest::testValidData#Iterator object, no array access /home/runner/work/Requests/Requests/tests/Utility/FilteredIterator/ConstructorTest.php:26 ``` This commit now makes two changes: 1. Change the `FilteredIterator::__construct()` method to no longer accept objects as a backing array. 2. No longer pass objects to the method when testing. With that, these test failures on PHP 8.5 are fixed.
schlessera
approved these changes
Nov 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request Type
Context
PHP 8.5 compatibility
Detailed Description
The tests for the
FilteredIterator::__construct()method were failing on PHP 8.5 as we were explicitly testing the class for accepting objects.While this is still supported on PHP 8.5, it is deprecated and results in the following deprecation notices:
This commit now makes two changes:
FilteredIterator::__construct()method to no longer accept objects as a backing array.With that, these test failures on PHP 8.5 are fixed.
👉🏻 Note: this could be considered a breaking change, as the class accepting an object was documented behaviour. However, as this is primarily an internal class, I'm not too concerned about that.