Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iterator return types #1123

Merged
merged 3 commits into from
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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