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
This commit is contained in:
commit
2c059ee52c
@ -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 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
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));
|
||||
|
@ -333,6 +333,17 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$finder->in(__DIR__.'/Fixtures/A/a*');
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user