Skip to content

Commit

Permalink
Fix iterator return types (#1123)
Browse files Browse the repository at this point in the history
Co-authored-by: Hugo Hamon <hhamon@users.noreply.github.com>
  • Loading branch information
theofidry and hhamon committed Oct 2, 2022
1 parent e16e22d commit 0297bae
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Definition/FlagBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Countable;
use IteratorAggregate;
use function Nelmio\Alice\deep_clone;
use Traversable;

/**
* Collection of flags.
Expand Down Expand Up @@ -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));
}
Expand Down
3 changes: 2 additions & 1 deletion src/Definition/MethodCallBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use ArrayIterator;
use Countable;
use IteratorAggregate;
use Traversable;

final class MethodCallBag implements IteratorAggregate, Countable
{
Expand Down Expand Up @@ -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));
}
Expand Down
3 changes: 2 additions & 1 deletion src/Definition/PropertyBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use ArrayIterator;
use Countable;
use IteratorAggregate;
use Traversable;

final class PropertyBag implements IteratorAggregate, Countable
{
Expand Down Expand Up @@ -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));
}
Expand Down
3 changes: 2 additions & 1 deletion src/FixtureBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions src/ObjectBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion src/ParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 0297bae

Please sign in to comment.