8000 [Finder] document array use for locations by mickaelandrieu · Pull Request #6917 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Finder] document array use for locations #6917

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
Sep 22, 2016
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
3 changes: 2 additions & 1 deletion components/finder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ directory to use for the search::
Search in several locations by chaining calls to
Copy link
Member
@wouterj wouterj Aug 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this no longer holds true.

I propose to merge the code examples (this one and the ones on line 80 & 89):

The location is the only mandatory criteria. It tells the finder which
directory to use for the search::

    $finder->in(__DIR__);

    // search in several locations
    $finder->in(array(__DIR__, '/elsewhere'));
    $finder->in(__DIR__)->in('/elsewhere');

    // use wildcard characters (it has to resolve to at least one directory path)
    $finder->in('src/Symfony/*/*/Resources');

Exclude directories from matching with the [...]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it's less readable...

Is it ok for you to suggest the 2 options ? See my update :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for Wouter's suggestion.

@mickaelandrieu we're including more code, with short comments to explain them, as we've found that people mostly scan to code-blocks anyways. This is a situation where this isn't a huge win, because the text between the paragraphs is so short, but I still like.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for one change:

// search inside *both* directories
$finder->in(array(__DIR__, '/elsewhere'));
// same as above
$finder->in(__DIR__)->in('/elsewhere');

This is to be clear what calling in() twice does - it does not replace the previous directory.

:method:`Symfony\\Component\\Finder\\Finder::in`::

$finder->files()->in(__DIR__)->in('/elsewhere');
$finder->files()->in(array(__DIR__, '/elsewhere'));
$finder->in(__DIR__)->in('/elsewhere');

Use wildcard characters to search in the directories matching a pattern::

Expand Down
0