Merge pull request #930 from pestphp/feature/same-size-arg

[2.x] chore: resolve `toHaveSameSize` parameter
This commit is contained in:
Nuno Maduro
2023-08-23 12:01:34 +01:00
committed by GitHub

View File

@ -6,6 +6,7 @@ namespace Pest\Mixins;
use BadMethodCallException; use BadMethodCallException;
use Closure; use Closure;
use Countable;
use DateTimeInterface; use DateTimeInterface;
use Error; use Error;
use InvalidArgumentException; use InvalidArgumentException;
@ -275,10 +276,10 @@ final class Expectation
/** /**
* Asserts that the size of the value and $expected are the same. * Asserts that the size of the value and $expected are the same.
* *
* @param array<int|string, mixed> $expected * @param Countable|iterable<mixed> $expected
* @return self<TValue> * @return self<TValue>
*/ */
public function toHaveSameSize(iterable $expected, string $message = ''): self public function toHaveSameSize(Countable|iterable $expected, string $message = ''): self
{ {
if (! is_countable($this->value) && ! is_iterable($this->value)) { if (! is_countable($this->value) && ! is_iterable($this->value)) {
InvalidExpectationValue::expected('countable|iterable'); InvalidExpectationValue::expected('countable|iterable');