feature #27024 [Finder] added "use natural sort" option (vyshkant)
This PR was merged into the 4.2-dev branch.
Discussion
----------
[Finder] added "use natural sort" option
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #26930
| License | MIT
| Doc PR | symfony/symfony-docs#9671
Added `$useNaturalSort` optional argument to `Finder::sortByName()` method. If it is specified and equals to `true`, ["natural sort order" algorithm](https://en.wikipedia.org/wiki/Natural_sort_order) will be applied, which means that `strnatcmp` function will be used instead of `strcmp` (see #26930 for details).
Commits
-------
e697c7d272
[Finder] added "use natural sort" option
This commit is contained in:
commit
3bade96ff2
@ -1,6 +1,11 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
* added $useNaturalSort option to Finder::sortByName() method
|
||||
|
||||
4.0.0
|
||||
-----
|
||||
|
||||
|
@ -397,13 +397,17 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* This can be slow as all the matching files and directories must be retrieved for comparison.
|
||||
*
|
||||
* @param bool $useNaturalSort Whether to use natural sort or not, disabled by default
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sortByName()
|
||||
public function sortByName(/* bool $useNaturalSort = false */)
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_NAME;
|
||||
$useNaturalSort = 0 < func_num_args() && func_get_arg(0);
|
||||
|
||||
$this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL : Iterator\SortableIterator::SORT_BY_NAME;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ class SortableIterator implements \IteratorAggregate
|
||||
const SORT_BY_ACCESSED_TIME = 3;
|
||||
const SORT_BY_CHANGED_TIME = 4;
|
||||
const SORT_BY_MODIFIED_TIME = 5;
|
||||
const SORT_BY_NAME_NATURAL = 6;
|
||||
|
||||
private $iterator;
|
||||
private $sort;
|
||||
@ -41,6 +42,10 @@ class SortableIterator implements \IteratorAggregate
|
||||
$this->sort = function ($a, $b) {
|
||||
return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_NAME_NATURAL === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
return strnatcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_TYPE === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
if ($a->isDir() && $b->isFile()) {
|
||||
|
@ -24,33 +24,70 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->directories());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'qux', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->directories();
|
||||
$finder->files();
|
||||
$finder->directories();
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'qux', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testFiles()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->files());
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'foo bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->files();
|
||||
$finder->directories();
|
||||
$finder->files();
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'foo bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testRemoveTrailingSlash()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
|
||||
$expected = $this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar'));
|
||||
$expected = $this->toAbsolute(array(
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'foo bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
));
|
||||
$in = self::$tmpDir.'//';
|
||||
|
||||
$this->assertIterator($expected, $finder->in($in)->files()->getIterator());
|
||||
@ -89,15 +126,43 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->depth('< 1'));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->depth('<= 0'));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->depth('>= 1'));
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo/bar.tmp',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->depth('< 1')->depth('>= 1');
|
||||
@ -108,7 +173,15 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->name('*.php'));
|
||||
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'test.php',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->name('test.ph*');
|
||||
@ -121,7 +194,15 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->name('~\\.php$~i');
|
||||
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'test.php',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->name('test.p{hp,y}');
|
||||
@ -132,12 +213,27 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->notName('*.php'));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.py',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->notName('*.php');
|
||||
$finder->notName('*.py');
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->name('test.ph*');
|
||||
@ -160,7 +256,10 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$finder->name($regex);
|
||||
$this->assertIterator($this->toAbsolute(array('test.py', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'test.py',
|
||||
'test.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSize()
|
||||
@ -181,79 +280,356 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->exclude('foo'));
|
||||
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testIgnoreVCS()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->ignoreVCS(false)->ignoreDotFiles(false));
|
||||
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'.git',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->ignoreVCS(false)->ignoreVCS(false)->ignoreDotFiles(false);
|
||||
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'.git',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->ignoreVCS(true)->ignoreDotFiles(false));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testIgnoreDotFiles()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->ignoreDotFiles(false)->ignoreVCS(false));
|
||||
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'.git',
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$finder->ignoreDotFiles(false)->ignoreDotFiles(false)->ignoreVCS(false);
|
||||
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'.git',
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->ignoreDotFiles(true)->ignoreVCS(false));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByName()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByName());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByType()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByType());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'toto', 'foo/bar.tmp', 'test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo bar',
|
||||
'toto',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByAccessedTime()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByAccessedTime());
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'toto', 'test.py', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'toto',
|
||||
'test.py',
|
||||
'foo',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByChangedTime()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByChangedTime());
|
||||
$this->assertIterator($this->toAbsolute(array('toto', 'test.py', 'test.php', 'foo/bar.tmp', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'toto',
|
||||
'test.py',
|
||||
'test.php',
|
||||
'foo/bar.tmp',
|
||||
'foo',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByModifiedTime()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByModifiedTime());
|
||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'toto', 'test.py', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'toto',
|
||||
'test.py',
|
||||
'foo',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByNameNatural()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByName(true));
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sortByName(false));
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSort()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->sort(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }));
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testFilter()
|
||||
@ -271,7 +647,23 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertSame($finder, $finder->followLinks());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testIn()
|
||||
@ -283,6 +675,12 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
self::$tmpDir.DIRECTORY_SEPARATOR.'test.php',
|
||||
__DIR__.DIRECTORY_SEPARATOR.'FinderTest.php',
|
||||
__DIR__.DIRECTORY_SEPARATOR.'GlobTest.php',
|
||||
self::$tmpDir.DIRECTORY_SEPARATOR.'qux_0_1.php',
|
||||
self::$tmpDir.DIRECTORY_SEPARATOR.'qux_1000_1.php',
|
||||
self::$tmpDir.DIRECTORY_SEPARATOR.'qux_1002_0.php',
|
||||
self::$tmpDir.DIRECTORY_SEPARATOR.'qux_10_2.php',
|
||||
self::$tmpDir.DIRECTORY_SEPARATOR.'qux_12_0.php',
|
||||
self::$tmpDir.DIRECTORY_SEPARATOR.'qux_2_0.php',
|
||||
);
|
||||
|
||||
$this->assertIterator($expected, $iterator);
|
||||
@ -339,7 +737,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$dirs[] = (string) $dir;
|
||||
}
|
||||
|
||||
$expected = $this->toAbsolute(array('foo', 'toto'));
|
||||
$expected = $this->toAbsolute(array('foo', 'qux', 'toto'));
|
||||
|
||||
sort($dirs);
|
||||
sort($expected);
|
||||
@ -347,7 +745,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$this->assertEquals($expected, $dirs, 'implements the \IteratorAggregate interface');
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$this->assertEquals(2, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');
|
||||
$this->assertEquals(3, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');
|
||||
|
||||
$finder = $this->buildFinder();
|
||||
$a = iterator_to_array($finder->directories()->in(self::$tmpDir));
|
||||
@ -366,7 +764,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$paths[] = $file->getRelativePath();
|
||||
}
|
||||
|
||||
$ref = array('', '', '', '', 'foo', '');
|
||||
$ref = array('', '', '', '', '', '', '', '', '', '', '', 'foo', 'qux', 'qux', '');
|
||||
|
||||
sort($ref);
|
||||
sort($paths);
|
||||
@ -384,7 +782,23 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
$paths[] = $file->getRelativePathname();
|
||||
}
|
||||
|
||||
$ref = array('test.php', 'toto', 'test.py', 'foo', 'foo'.DIRECTORY_SEPARATOR.'bar.tmp', 'foo bar');
|
||||
$ref = array(
|
||||
'test.php',
|
||||
'toto',
|
||||
'test.py',
|
||||
'foo',
|
||||
'foo'.DIRECTORY_SEPARATOR.'bar.tmp',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux'.DIRECTORY_SEPARATOR.'baz_100_1.py',
|
||||
'qux'.DIRECTORY_SEPARATOR.'baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
sort($paths);
|
||||
sort($ref);
|
||||
@ -402,7 +816,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
|
||||
$finder = $finder->append($finder1);
|
||||
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto')), $finder->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'qux', 'toto')), $finder->getIterator());
|
||||
}
|
||||
|
||||
public function testAppendWithAnArray()
|
||||
@ -601,7 +1015,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
public function getRegexNameTestData()
|
||||
{
|
||||
return array(
|
||||
array('~.+\\.p.+~i'),
|
||||
array('~.*t\\.p.+~i'),
|
||||
array('~t.*s~i'),
|
||||
);
|
||||
}
|
||||
@ -718,7 +1132,20 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
chmod($testDir, 0333);
|
||||
|
||||
if (false === ($couldRead = is_readable($testDir))) {
|
||||
$this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator());
|
||||
$this->assertIterator($this->toAbsolute(array(
|
||||
'foo bar',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
)
|
||||
), $finder->getIterator());
|
||||
}
|
||||
|
||||
// restore original permissions
|
||||
|
@ -45,6 +45,15 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'.foo/.bar',
|
||||
'foo bar',
|
||||
'.foo/bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$since2MonthsAgo = array(
|
||||
@ -58,6 +67,15 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'.foo/.bar',
|
||||
'foo bar',
|
||||
'.foo/bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$untilLastMonth = array(
|
||||
|
@ -41,6 +41,13 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'.foo',
|
||||
'.bar',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$lessThanOrEqualTo1 = array(
|
||||
@ -56,6 +63,15 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'.bar',
|
||||
'foo bar',
|
||||
'.foo/bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$graterThanOrEqualTo1 = array(
|
||||
@ -63,6 +79,8 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'foo/bar.tmp',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
);
|
||||
|
||||
$equalTo1 = array(
|
||||
@ -70,6 +88,8 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'foo/bar.tmp',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
);
|
||||
|
||||
return array(
|
||||
|
@ -41,6 +41,15 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$fo = array(
|
||||
@ -56,6 +65,15 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$toto = array(
|
||||
@ -69,6 +87,15 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
return array(
|
||||
|
@ -37,11 +37,20 @@ class FileTypeFilterIteratorTest extends RealIteratorTestCase
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'foo bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
);
|
||||
|
||||
$onlyDirectories = array(
|
||||
'.git',
|
||||
'foo',
|
||||
'qux',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'.foo',
|
||||
|
@ -33,6 +33,15 @@ abstract class RealIteratorTestCase extends IteratorTestCase
|
||||
'toto/',
|
||||
'toto/.git/',
|
||||
'foo bar',
|
||||
'qux_0_1.php',
|
||||
'qux_2_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux/',
|
||||
'qux/baz_1_2.py',
|
||||
'qux/baz_100_1.py',
|
||||
);
|
||||
|
||||
self::$files = self::toAbsolute(self::$files);
|
||||
|
@ -34,6 +34,7 @@ class SizeRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
'.foo',
|
||||
'.git',
|
||||
'foo',
|
||||
'qux',
|
||||
'test.php',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
|
@ -82,6 +82,15 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
@ -92,6 +101,7 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
'.foo',
|
||||
'.git',
|
||||
'foo',
|
||||
'qux',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'.bar',
|
||||
@ -99,25 +109,18 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
'.foo/bar',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
);
|
||||
|
||||
$customComparison = array(
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'.git',
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
);
|
||||
|
||||
$sortByAccessedTime = array(
|
||||
// For these two files the access time was set to 2005-10-15
|
||||
array('foo/bar.tmp', 'test.php'),
|
||||
@ -132,6 +135,15 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
),
|
||||
// This file was accessed after sleeping for 1 sec
|
||||
array('.bar'),
|
||||
@ -149,6 +161,15 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
),
|
||||
array('test.php'),
|
||||
array('test.py'),
|
||||
@ -166,17 +187,75 @@ class SortableIteratorTest extends RealIteratorTestCase
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
),
|
||||
array('test.php'),
|
||||
array('test.py'),
|
||||
);
|
||||
|
||||
$sortByNameNatural = array(
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'.git',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'foo bar',
|
||||
'qux',
|
||||
'qux/baz_1_2.py',
|
||||
'qux/baz_100_1.py',
|
||||
'qux_0_1.php',
|
||||
'qux_2_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
);
|
||||
|
||||
$customComparison = array(
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'.git',
|
||||
'foo',
|
||||
'foo bar',
|
||||
'foo/bar.tmp',
|
||||
'qux',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'test.py',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
);
|
||||
|
||||
return array(
|
||||
array(SortableIterator::SORT_BY_NAME, $this->toAbsolute($sortByName)),
|
||||
array(SortableIterator::SORT_BY_TYPE, $this->toAbsolute($sortByType)),
|
||||
array(SortableIterator::SORT_BY_ACCESSED_TIME, $this->toAbsolute($sortByAccessedTime)),
|
||||
array(SortableIterator::SORT_BY_CHANGED_TIME, $this->toAbsolute($sortByChangedTime)),
|
||||
array(SortableIterator::SORT_BY_MODIFIED_TIME, $this->toAbsolute($sortByModifiedTime)),
|
||||
array(SortableIterator::SORT_BY_NAME_NATURAL, $this->toAbsolute($sortByNameNatural)),
|
||||
array(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, $this->toAbsolute($customComparison)),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user