Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[Finder] Add support for GLOB in dir() #5450

Closed
sebastianbergmann opened this Issue · 1 comment

2 participants

@sebastianbergmann

Discussing sebastianbergmann/phpunit#637 with @fabpot revealed that dir() does not support GLOB and should be implemented.

@fabpot fabpot referenced this issue from a commit
@fabpot fabpot merged branch jakzal/finder-glob-support (PR #6531)
This PR was merged into the master branch.

Commits
-------

29b9611 [Finder] Added support for GLOB patterns in the directories passed to the in() method.

Discussion
----------

[Finder] Added support for wildcard characters (GLOB patterns)

Added support for wildcard characters in the paths passed to the *in()* method. Each pattern has to resolve to at least one directory, otherwise exception is thrown (just like when path to an invalid directory is passed).

Example usage:

```php
$finder = new \Symfony\Component\Finder\Finder();
$files = $finder->files()
    ->name('validators.en.*')
    ->in(array(
        'src/Symfony/*/*/Resources/translations',
    ));

foreach ($files as $file) {
    var_dump($file->getRealPath());
}
```

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #5450
Todo: -
License of the code: MIT
Documentation PR: symfony/symfony-docs#2089
6d3ed7a
@fabpot
Owner

@sebastianbergmann fixed now in 2.2.

@fabpot fabpot closed this
@sebastianbergmann sebastianbergmann referenced this issue in sebastianbergmann/php-code-coverage
Open

Replace File_Iterator with FinderFacade #144

@mmucklo mmucklo referenced this issue from a commit
@fabpot fabpot merged branch jakzal/finder-glob-support (PR #6531)
This PR was merged into the master branch.

Commits
-------

29b9611 [Finder] Added support for GLOB patterns in the directories passed to the in() method.

Discussion
----------

[Finder] Added support for wildcard characters (GLOB patterns)

Added support for wildcard characters in the paths passed to the *in()* method. Each pattern has to resolve to at least one directory, otherwise exception is thrown (just like when path to an invalid directory is passed).

Example usage:

```php
$finder = new \Symfony\Component\Finder\Finder();
$files = $finder->files()
    ->name('validators.en.*')
    ->in(array(
        'src/Symfony/*/*/Resources/translations',
    ));

foreach ($files as $file) {
    var_dump($file->getRealPath());
}
```

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #5450
Todo: -
License of the code: MIT
Documentation PR: symfony/symfony-docs#2089
41ed834
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.