Skip to content

Commit 74d460e

Browse files
sp1kerjaviereguiluz
authored andcommitted
Fix possible error code
Pseudo-type `iterable` accepts any `array` or `object` implementing the `Traversable` interface. Constructor will be crashed when we try to pass array instead of `Traversable` and use `iterator_to_array`. `iterator_to_array` dont work with arrays. Then if always passing `Traversable` we could write like this: ```php public function __construct(Traversable $handlers) ``` or check instance on `Traversable`.
1 parent ee18ef9 commit 74d460e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

service_container/tags.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ array element. For example, to retrieve the ``handler_two`` handler::
798798
{
799799
public function __construct(iterable $handlers)
800800
{
801-
$handlers = iterator_to_array($handlers);
801+
$handlers = $handlers instanceof \Traversable ? iterator_to_array($handlers) : $handlers;
802802

803803
$handlerTwo = $handlers['handler_two'];
804804
}

0 commit comments

Comments
 (0)