8000 feature #9926 [Finder] Added GLOB_BRACE support in Finder::in() metho… · symfony/symfony@2c059ee · GitHub
[go: up one dir, main page]

Skip to content

Commit 2c059ee

Browse files
committed
feature #9926 [Finder] Added GLOB_BRACE support in Finder::in() method (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
2 parents a12db9b + e2698fc commit 2c059ee

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/Symfony/Component/Finder/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
CHANGELOG
22
=========
33

4+
2.5.0
5+
-----
6+
* added support for GLOB_BRACE in the paths passed to Finder::in()
7+
48
2.3.0
59
-----
610

src/Symfony/Component/Finder/Finder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ public function in($dirs)
661661
foreach ((array) $dirs as $dir) {
662662
if (is_dir($dir)) {
663663
$resolvedDirs[] = $dir;
664-
} elseif ($glob = glob($dir, GLOB_ONLYDIR)) {
664+
} elseif ($glob = glob($dir, GLOB_BRACE | GLOB_ONLYDIR)) {
665665
$resolvedDirs = array_merge($resolvedDirs, $glob);
666666
} else {
667667
throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,17 @@ public function testInWithNonDirectoryGlob($adapter)
333333
$finder->in(__DIR__.'/Fixtures/A/a*');
334334
}
335335

336+
/**
337+
* @dataProvider getAdaptersTestData
338+
*/
339+
public function testInWithGlobBrace($adapter)
340+
{
341+
$finder = $this->buildFinder($adapter);
342+
$finder->in(array(__DIR__.'/Fixtures/{A,copy/A}/B/C'))->getIterator();
343+
344+
$this->assertIterator($this->toAbsoluteFixtures(array('A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy')), $finder);
345+
}
346+
336347
/**
337348
* @dataProvider getAdaptersTestData
338349
*/

0 commit comments

Comments
 (0)
0