diff --git a/src/Definition/FlagBag.php b/src/Definition/FlagBag.php index a910664b..8c0e5c1d 100644 --- a/src/Definition/FlagBag.php +++ b/src/Definition/FlagBag.php @@ -17,6 +17,7 @@ use Countable; use IteratorAggregate; use function Nelmio\Alice\deep_clone; +use Traversable; /** * Collection of flags. @@ -94,7 +95,7 @@ public function getKey(): string return $this->key; } - public function getIterator(): ArrayIterator + public function getIterator(): Traversable { return new ArrayIterator(array_values($this->flags)); } diff --git a/src/Definition/MethodCallBag.php b/src/Definition/MethodCallBag.php index 1f80ce36..b893da6a 100644 --- a/src/Definition/MethodCallBag.php +++ b/src/Definition/MethodCallBag.php @@ -16,6 +16,7 @@ use ArrayIterator; use Countable; use IteratorAggregate; +use Traversable; final class MethodCallBag implements IteratorAggregate, Countable { @@ -51,7 +52,7 @@ public function isEmpty(): bool return [] === $this->methodCalls; } - public function getIterator(): ArrayIterator + public function getIterator(): Traversable { return new ArrayIterator(array_values($this->methodCalls)); } diff --git a/src/Definition/PropertyBag.php b/src/Definition/PropertyBag.php index 8c1dbfc7..ccf89db1 100644 --- a/src/Definition/PropertyBag.php +++ b/src/Definition/PropertyBag.php @@ -16,6 +16,7 @@ use ArrayIterator; use Countable; use IteratorAggregate; +use Traversable; final class PropertyBag implements IteratorAggregate, Countable { @@ -51,7 +52,7 @@ public function isEmpty(): bool return [] === $this->properties; } - public function getIterator(): ArrayIterator + public function getIterator(): Traversable { return new ArrayIterator(array_values($this->properties)); } diff --git a/src/FixtureBag.php b/src/FixtureBag.php index daf41852..2f877ce2 100644 --- a/src/FixtureBag.php +++ b/src/FixtureBag.php @@ -17,6 +17,7 @@ use IteratorAggregate; use Nelmio\Alice\Throwable\Exception\FixtureNotFoundException; use Nelmio\Alice\Throwable\Exception\FixtureNotFoundExceptionFactory; +use Traversable; /** * Value object containing a list of fixtures. @@ -85,7 +86,7 @@ public function get(string $id): FixtureInterface throw FixtureNotFoundExceptionFactory::create($id); } - public function getIterator(): ArrayIterator + public function getIterator(): Traversable { return new ArrayIterator($this->fixtures); } diff --git a/src/ObjectBag.php b/src/ObjectBag.php index 6921530c..b7b5ced2 100644 --- a/src/ObjectBag.php +++ b/src/ObjectBag.php @@ -21,6 +21,7 @@ use Nelmio\Alice\Throwable\Exception\InvalidArgumentExceptionFactory; use Nelmio\Alice\Throwable\Exception\ObjectNotFoundException; use Nelmio\Alice\Throwable\Exception\ObjectNotFoundExceptionFactory; +use Traversable; /** * Value object containing a list of objects. @@ -121,8 +122,8 @@ public function count(): int { return count($this->objects); } - - public function getIterator(): ArrayIterator + + public function getIterator(): Traversable { return new ArrayIterator($this->objects); } diff --git a/src/ParameterBag.php b/src/ParameterBag.php index 544b4d86..765b9a7a 100644 --- a/src/ParameterBag.php +++ b/src/ParameterBag.php @@ -18,6 +18,7 @@ use IteratorAggregate; use Nelmio\Alice\Throwable\Exception\ParameterNotFoundException; use Nelmio\Alice\Throwable\Exception\ParameterNotFoundExceptionFactory; +use Traversable; /** * Value object containing a list of parameters. @@ -78,7 +79,7 @@ public function get(string $key) throw ParameterNotFoundExceptionFactory::create($key); } - public function getIterator(): ArrayIterator + public function getIterator(): Traversable { return new ArrayIterator($this->parameters); }