Skip to content

Commit

Permalink
minor #42151 Use is_iterable() function when possible (javiereguiluz)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

Use is_iterable() function when possible

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

PHP added `is_iterable()` in PHP 7.1.0 (see https://www.php.net/manual/en/function.is-iterable.php) and Symfony 4.4 requires `>=7.1.3`, so maybe we can use this function to simplify some code.

Commits
-------

6919c1317d Use is_iterable() function when possible
  • Loading branch information
Tobion committed Jul 17, 2021
2 parents dcc7738 + 860a301 commit f638807
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ public function append($iterator)
$this->iterators[] = $iterator->getIterator();
} elseif ($iterator instanceof \Iterator) {
$this->iterators[] = $iterator;
} elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
} elseif (is_iterable($iterator)) {
$it = new \ArrayIterator();
foreach ($iterator as $file) {
$file = $file instanceof \SplFileInfo ? $file : new \SplFileInfo($file);
Expand Down

0 comments on commit f638807

Please sign in to comment.