Skip to content

[Component][Finder] Documented potential pitfalls when using iterator_to_array() with Finder #2098

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
Jan 27, 2013
Merged
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
11 changes: 11 additions & 0 deletions components/finder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ the Finder instance.
:phpfunction:`iterator_to_array` method, or get the number of items with
:phpfunction:`iterator_count`.

.. caution::

When searching through multiple locations passed to the
:method:`Symfony\\Component\\Finder\\Finder::in` method, a separate iterator
is created internally for every location. This means we have multiple result
sets aggregated into one.
Since :phpfunction:`iterator_to_array` uses keys of result sets by default,
when converting to an array, some keys might be duplicated and their values
overwritten. This can be avoided by passing ``false`` as a second parameter
to :phpfunction:`iterator_to_array`.

Criteria
--------

Expand Down