You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The [`SequentialArray` constraint](https://github.com/PhrozenByte/phpunit-array-asserts/blob/master/src/Constraint/SequentialArray.php) asserts that a value is like a sequential array, has a minimum and/or maximum number of items, and that all items pass another constraint.
172
172
173
-
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.
173
+
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.
174
174
175
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.
176
176
@@ -181,18 +181,18 @@ The `ArrayAssertsTrait` trait exposes two public methods for the `SequentialArra
181
181
```php
182
182
// using `\PhrozenByte\PHPUnitArrayAsserts\ArrayAssertsTrait` trait
183
183
ArrayAssertsTrait::assertSequentialArray(
184
-
array|Traversable $array, // the sequential array to check
185
-
int $minItems, // required minimum number of items
186
-
int $maxItems = null, // required maximum number of items (pass null for infinite)
187
-
Constraint $constraint = null, // optional constraint to apply all items to
188
-
string $message = '' // additional information about the test
184
+
array|Traversable $array, // the sequential array to check
185
+
int $minItems, // required minimum number of items
186
+
int $maxItems = null, // required maximum number of items (pass null for infinite)
187
+
Constraint|mixed $constraint = null, // optional constraint to apply all items to
188
+
string $message = '' // additional information about the test
189
189
);
190
190
191
191
// using new instance of `\PhrozenByte\PHPUnitArrayAsserts\Constraint\SequentialArray`
0 commit comments