Skip to content

[DependencyInjection] Fix possible error in example code #14729

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

Merged
merged 1 commit into from
Apr 16, 2021

Conversation

sp1ker
Copy link
Contributor

@sp1ker sp1ker commented Dec 21, 2020

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:

public function __construct(Traversable $handlers)

or check instance of Traversable.

@sp1ker sp1ker changed the title Fix possible error code [Service Container] Fix possible error in example code Dec 21, 2020
@carsonbot carsonbot changed the title [Service Container] Fix possible error in example code [DependencyInjection] [Service Container] Fix possible error in example code Apr 16, 2021
@javiereguiluz javiereguiluz changed the title [DependencyInjection] [Service Container] Fix possible error in example code [DependencyInjection] Fix possible error in example code Apr 16, 2021
@javiereguiluz javiereguiluz added this to the 4.4 milestone Apr 16, 2021
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`.
@javiereguiluz
Copy link
Member

Nice fix Evgeniy! Thanks and congrats on your first Symfony Docs contribution 🎉

@javiereguiluz javiereguiluz merged commit b01a241 into symfony:4.4 Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants