Permalink
Browse files

feature #9926 [Finder] Added GLOB_BRACE support in Finder::in() metho…

…d (jakzal)

This PR was merged into the 2.5-dev branch.

Discussion
----------

[Finder] Added GLOB_BRACE support in Finder::in() method

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #9705
| License       | MIT
| Doc PR        | ~

**before**

```php
$finder->files()->in([
    'My/First/Directory',
    'My/Second/Directory',
    'My/Third/Directory',
]);
```

**after**

```php
$finder->files()->in('My/{First,Second,Third}/Directory');
```

Commits
-------

e2698fc [Finder] Included GLOB_BRACE support in the CHANGELOG.
30814d3 [Finder] Added a test case for the GLOB_BRACE in Finder:in().
da67f5d [Finder] Added GLOB_BRACE support in Finder::in() method
  • Loading branch information...
2 parents a12db9b + e2698fc commit 2c059ee52c21c50036e61d80df3aa2c2691009e4 @fabpot fabpot committed Jan 2, 2014
@@ -1,6 +1,10 @@
CHANGELOG
=========
+2.5.0
+-----
+ * added support for GLOB_BRACE in the paths passed to Finder::in()
+
2.3.0
-----
@@ -661,7 +661,7 @@ public function in($dirs)
foreach ((array) $dirs as $dir) {
if (is_dir($dir)) {
$resolvedDirs[] = $dir;
- } elseif ($glob = glob($dir, GLOB_ONLYDIR)) {
+ } elseif ($glob = glob($dir, GLOB_BRACE | GLOB_ONLYDIR)) {
$resolvedDirs = array_merge($resolvedDirs, $glob);
} else {
throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
@@ -336,6 +336,17 @@ public function testInWithNonDirectoryGlob($adapter)
/**
* @dataProvider getAdaptersTestData
*/
+ public function testInWithGlobBrace($adapter)
+ {
+ $finder = $this->buildFinder($adapter);
+ $finder->in(array(__DIR__.'/Fixtures/{A,copy/A}/B/C'))->getIterator();
+
+ $this->assertIterator($this->toAbsoluteFixtures(array('A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy')), $finder);
+ }
+
+ /**
+ * @dataProvider getAdaptersTestData
+ */
public function testGetIterator($adapter)
{
$finder = $this->buildFinder($adapter);

0 comments on commit 2c059ee

Please sign in to comment.