Skip to content

Commit b0e0a2d

Browse files
committed
SequentialArray + ArrayHasItemWith: Update README.md to explain Iterator handling
1 parent eb5008b commit b0e0a2d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ The [`SequentialArray` constraint](https://github.com/PhrozenByte/phpunit-array-
172172

173173
Sequential arrays are defined as ordered lists with incrementing numeric keys starting from zero. This is especially true for native sequential arrays like `[ "foo", "bar" ]`. Empty arrays are considered valid, too. `Traversable` objects must have sequential keys to be considered valid. The expected minimum (parameter `$minItems`, defaults to `0`) and/or maximum (parameter `$maxItems`, defaults to `null`, meaning infinite) number of items, and the constraint to apply all items to (optional parameter `$constraint`), are passed in the constructor. The constraint can either be an arbitrary `Constraint` instance (e.g. `PHPUnit\Framework\Constraint\StringContains`), or any static value, requiring an exact match of the value. Requiring sequential keys can be disabled by setting parameter `$ignoreKeys` to `true` (defaults to `false`), causing the constraint to check just for the required number of items and whether they match the given constraint.
174174

175-
This constraint will fully traverse any `Traversable` object given. This also means that any `Generator` will be fully exhausted. If possible, it will try to restore an `Iterator`'s pointer to its previous state.
175+
This constraint will fully traverse any `Traversable` object given. It expects `Traversable`s to be rewindable. For `NoRewindIterator` instances it assumes that the iterator is still in its initial state. `Generator`s will be fully exhausted; if the iterator has begun already, the object is considered invalid. If an `Iterator` is given, it will try to restore the object's pointer to its previous state. This will silently fail for `NoRewindIterator` instances. The behaviour for `Iterator`s with non-unique keys is undefined.
176176

177177
The `ArrayAssertsTrait` trait exposes two public methods for the `SequentialArray` constraint: Use `ArrayAssertsTrait::assertSequentialArray()` to perform an assertion, and `ArrayAssertsTrait::sequentialArray()` to create a new instance of the `SequentialArray` constraint.
178178

@@ -233,7 +233,7 @@ The [`ArrayHasItemWith` constraint](https://github.com/PhrozenByte/phpunit-array
233233

234234
Accepts both native arrays and `Traversable` objects. The constraint will fail if the array has less items than required. The index of the item to check (parameter `$index`), and the constraint its value must pass (parameter `$constraint`) are passed in the constructor. The constraint can either be an arbitrary `Constraint` instance (e.g. `PHPUnit\Framework\Constraint\StringContains`), or any static value, requiring an exact match of the value.
235235

236-
This constraint will fully traverse any `Traversable` object given. This also means that any `Generator` will be fully exhausted. It doesn't restore an `Iterator`'s pointer to its previous state.
236+
This constraint will fully traverse any `Traversable` object given. It expects `Traversable`s to be rewindable. For `NoRewindIterator` instances it assumes that the iterator is still in its initial state. `Generator`s will be fully exhausted; if the iterator has begun already, the object is considered invalid. If an `Iterator` is given, it will try to restore the object's pointer to its previous state. This will silently fail for `NoRewindIterator` instances. The behaviour for `Iterator`s with non-unique keys is undefined.
237237

238238
The `ArrayAssertsTrait` trait exposes two public methods for the `ArrayHasItemWith` constraint: Use `ArrayAssertsTrait::assertArrayHasItemWith()` to perform an assertion, and `ArrayAssertsTrait::arrayHasItemWith()` to create a new instance of the `ArrayHasItemWith` constraint.
239239

0 commit comments

Comments
 (0)