updated packages

This commit is contained in:
2019-05-18 09:06:43 +00:00
parent 901d16349e
commit e9487fa58a
2025 changed files with 30366 additions and 49653 deletions

View File

@@ -64,7 +64,7 @@ class Comparator
$operator = '==';
}
if (!\in_array($operator, array('>', '<', '>=', '<=', '==', '!='))) {
if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
}

View File

@@ -29,7 +29,7 @@ use Symfony\Component\Finder\Iterator\SortableIterator;
*
* All rules may be invoked several times.
*
* All methods return the current Finder object to allow easy chaining:
* All methods return the current Finder object to allow chaining:
*
* $finder = Finder::create()->files()->name('*.php')->in(__DIR__);
*
@@ -41,26 +41,26 @@ class Finder implements \IteratorAggregate, \Countable
const IGNORE_DOT_FILES = 2;
private $mode = 0;
private $names = array();
private $notNames = array();
private $exclude = array();
private $filters = array();
private $depths = array();
private $sizes = array();
private $names = [];
private $notNames = [];
private $exclude = [];
private $filters = [];
private $depths = [];
private $sizes = [];
private $followLinks = false;
private $reverseSorting = false;
private $sort = false;
private $ignore = 0;
private $dirs = array();
private $dates = array();
private $iterators = array();
private $contains = array();
private $notContains = array();
private $paths = array();
private $notPaths = array();
private $dirs = [];
private $dates = [];
private $iterators = [];
private $contains = [];
private $notContains = [];
private $paths = [];
private $notPaths = [];
private $ignoreUnreadableDirs = false;
private static $vcsPatterns = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg');
private static $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
public function __construct()
{
@@ -570,13 +570,13 @@ class Finder implements \IteratorAggregate, \Countable
*/
public function in($dirs)
{
$resolvedDirs = array();
$resolvedDirs = [];
foreach ((array) $dirs as $dir) {
if (is_dir($dir)) {
$resolvedDirs[] = $this->normalizeDir($dir);
} elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
$resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob));
$resolvedDirs = array_merge($resolvedDirs, array_map([$this, 'normalizeDir'], $glob));
} else {
throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
}
@@ -674,12 +674,15 @@ class Finder implements \IteratorAggregate, \Countable
private function searchInDirectory(string $dir): \Iterator
{
$exclude = $this->exclude;
$notPaths = $this->notPaths;
if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
$this->exclude = array_merge($this->exclude, self::$vcsPatterns);
$exclude = array_merge($exclude, self::$vcsPatterns);
}
if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
$this->notPaths[] = '#(^|/)\..+(/|$)#';
$notPaths[] = '#(^|/)\..+(/|$)#';
}
$minDepth = 0;
@@ -712,8 +715,8 @@ class Finder implements \IteratorAggregate, \Countable
$iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
if ($this->exclude) {
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
if ($exclude) {
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $exclude);
}
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
@@ -746,8 +749,8 @@ class Finder implements \IteratorAggregate, \Countable
$iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
}
if ($this->paths || $this->notPaths) {
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
if ($this->paths || $notPaths) {
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths);
}
if ($this->sort || $this->reverseSorting) {

View File

@@ -18,7 +18,7 @@ namespace Symfony\Component\Finder;
*
* // prints foo.bar and foo.baz
* $regex = glob_to_regex("foo.*");
* for (array('foo.bar', 'foo.baz', 'foo', 'bar') as $t)
* for (['foo.bar', 'foo.baz', 'foo', 'bar'] as $t)
* {
* if (/$regex/) echo "matched: $car\n";
* }

View File

@@ -21,7 +21,7 @@ namespace Symfony\Component\Finder\Iterator;
*/
class CustomFilterIterator extends \FilterIterator
{
private $filters = array();
private $filters = [];
/**
* @param \Iterator $iterator The Iterator to filter

View File

@@ -20,7 +20,7 @@ use Symfony\Component\Finder\Comparator\DateComparator;
*/
class DateRangeFilterIterator extends \FilterIterator
{
private $comparators = array();
private $comparators = [];
/**
* @param \Iterator $iterator The Iterator to filter

View File

@@ -20,7 +20,7 @@ class ExcludeDirectoryFilterIterator extends \FilterIterator implements \Recursi
{
private $iterator;
private $isRecursive;
private $excludedDirs = array();
private $excludedDirs = [];
private $excludedPattern;
/**
@@ -31,7 +31,7 @@ class ExcludeDirectoryFilterIterator extends \FilterIterator implements \Recursi
{
$this->iterator = $iterator;
$this->isRecursive = $iterator instanceof \RecursiveIterator;
$patterns = array();
$patterns = [];
foreach ($directories as $directory) {
$directory = rtrim($directory, '/');
if (!$this->isRecursive || false !== strpos($directory, '/')) {
@@ -75,7 +75,7 @@ class ExcludeDirectoryFilterIterator extends \FilterIterator implements \Recursi
public function getChildren()
{
$children = new self($this->iterator->getChildren(), array());
$children = new self($this->iterator->getChildren(), []);
$children->excludedDirs = $this->excludedDirs;
$children->excludedPattern = $this->excludedPattern;

View File

@@ -18,8 +18,8 @@ namespace Symfony\Component\Finder\Iterator;
*/
abstract class MultiplePcreFilterIterator extends \FilterIterator
{
protected $matchRegexps = array();
protected $noMatchRegexps = array();
protected $matchRegexps = [];
protected $noMatchRegexps = [];
/**
* @param \Iterator $iterator The Iterator to filter
@@ -91,7 +91,7 @@ abstract class MultiplePcreFilterIterator extends \FilterIterator
return !preg_match('/[*?[:alnum:] \\\\]/', $start);
}
foreach (array(array('{', '}'), array('(', ')'), array('[', ']'), array('<', '>')) as $delimiters) {
foreach ([['{', '}'], ['(', ')'], ['[', ']'], ['<', '>']] as $delimiters) {
if ($start === $delimiters[0] && $end === $delimiters[1]) {
return true;
}

View File

@@ -96,7 +96,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
} catch (\UnexpectedValueException $e) {
if ($this->ignoreUnreadableDirs) {
// If directory is unreadable and finder is set to ignore it, a fake empty content is returned.
return new \RecursiveArrayIterator(array());
return new \RecursiveArrayIterator([]);
} else {
throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
}

View File

@@ -20,7 +20,7 @@ use Symfony\Component\Finder\Comparator\NumberComparator;
*/
class SizeRangeFilterIterator extends \FilterIterator
{
private $comparators = array();
private $comparators = [];
/**
* @param \Iterator $iterator The Iterator to filter

View File

@@ -73,7 +73,8 @@ class SortableIterator implements \IteratorAggregate
} elseif (self::SORT_BY_NONE === $sort) {
$this->sort = $order;
} elseif (\is_callable($sort)) {
$this->sort = $reverseOrder ? function ($a, $b) use ($sort) { return -$sort($a, $b); } : $sort;
$this->sort = $reverseOrder ? function ($a, $b) use ($sort) { return -$sort($a, $b); }
: $sort;
} else {
throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
}

View File

@@ -58,8 +58,8 @@ class ComparatorTest extends TestCase
public function getTestData()
{
return array(
array('<', '1000', array('500', '999'), array('1000', '1500')),
);
return [
['<', '1000', ['500', '999'], ['1000', '1500']],
];
}
}

View File

@@ -51,14 +51,14 @@ class DateComparatorTest extends TestCase
public function getTestData()
{
return array(
array('< 2005-10-10', array(strtotime('2005-10-09')), array(strtotime('2005-10-15'))),
array('until 2005-10-10', array(strtotime('2005-10-09')), array(strtotime('2005-10-15'))),
array('before 2005-10-10', array(strtotime('2005-10-09')), array(strtotime('2005-10-15'))),
array('> 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))),
array('after 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))),
array('since 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))),
array('!= 2005-10-10', array(strtotime('2005-10-11')), array(strtotime('2005-10-10'))),
);
return [
['< 2005-10-10', [strtotime('2005-10-09')], [strtotime('2005-10-15')]],
['until 2005-10-10', [strtotime('2005-10-09')], [strtotime('2005-10-15')]],
['before 2005-10-10', [strtotime('2005-10-09')], [strtotime('2005-10-15')]],
['> 2005-10-10', [strtotime('2005-10-15')], [strtotime('2005-10-09')]],
['after 2005-10-10', [strtotime('2005-10-15')], [strtotime('2005-10-09')]],
['since 2005-10-10', [strtotime('2005-10-15')], [strtotime('2005-10-09')]],
['!= 2005-10-10', [strtotime('2005-10-11')], [strtotime('2005-10-10')]],
];
}
}

View File

@@ -53,39 +53,39 @@ class NumberComparatorTest extends TestCase
public function getTestData()
{
return array(
array('< 1000', array('500', '999'), array('1000', '1500')),
return [
['< 1000', ['500', '999'], ['1000', '1500']],
array('< 1K', array('500', '999'), array('1000', '1500')),
array('<1k', array('500', '999'), array('1000', '1500')),
array(' < 1 K ', array('500', '999'), array('1000', '1500')),
array('<= 1K', array('1000'), array('1001')),
array('> 1K', array('1001'), array('1000')),
array('>= 1K', array('1000'), array('999')),
['< 1K', ['500', '999'], ['1000', '1500']],
['<1k', ['500', '999'], ['1000', '1500']],
[' < 1 K ', ['500', '999'], ['1000', '1500']],
['<= 1K', ['1000'], ['1001']],
['> 1K', ['1001'], ['1000']],
['>= 1K', ['1000'], ['999']],
array('< 1KI', array('500', '1023'), array('1024', '1500')),
array('<= 1KI', array('1024'), array('1025')),
array('> 1KI', array('1025'), array('1024')),
array('>= 1KI', array('1024'), array('1023')),
['< 1KI', ['500', '1023'], ['1024', '1500']],
['<= 1KI', ['1024'], ['1025']],
['> 1KI', ['1025'], ['1024']],
['>= 1KI', ['1024'], ['1023']],
array('1KI', array('1024'), array('1023', '1025')),
array('==1KI', array('1024'), array('1023', '1025')),
['1KI', ['1024'], ['1023', '1025']],
['==1KI', ['1024'], ['1023', '1025']],
array('==1m', array('1000000'), array('999999', '1000001')),
array('==1mi', array(1024 * 1024), array(1024 * 1024 - 1, 1024 * 1024 + 1)),
['==1m', ['1000000'], ['999999', '1000001']],
['==1mi', [1024 * 1024], [1024 * 1024 - 1, 1024 * 1024 + 1]],
array('==1g', array('1000000000'), array('999999999', '1000000001')),
array('==1gi', array(1024 * 1024 * 1024), array(1024 * 1024 * 1024 - 1, 1024 * 1024 * 1024 + 1)),
['==1g', ['1000000000'], ['999999999', '1000000001']],
['==1gi', [1024 * 1024 * 1024], [1024 * 1024 * 1024 - 1, 1024 * 1024 * 1024 + 1]],
array('!= 1000', array('500', '999'), array('1000')),
);
['!= 1000', ['500', '999'], ['1000']],
];
}
public function getConstructorTestData()
{
return array(
array(
array(
return [
[
[
'1', '0',
'3.5', '33.55', '123.456', '123456.78',
'.1', '.123',
@@ -94,15 +94,15 @@ class NumberComparatorTest extends TestCase
'==1', '!=1', '<1', '>1', '<=1', '>=1',
'==1k', '==1ki', '==1m', '==1mi', '==1g', '==1gi',
'1k', '1ki', '1m', '1mi', '1g', '1gi',
),
array(
],
[
false, null, '',
' ', 'foobar',
'=1', '===1',
'0 . 1', '123 .45', '234. 567',
'..', '.0.', '0.1.2',
),
),
);
],
],
];
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -39,7 +39,7 @@ class GlobTest extends TestCase
}
sort($match);
$this->assertSame(array('one/b/c.neon', 'one/b/d.neon'), $match);
$this->assertSame(['one/b/c.neon', 'one/b/d.neon'], $match);
}
public function testGlobToRegexDoubleStarNonStrictDots()
@@ -56,7 +56,7 @@ class GlobTest extends TestCase
}
sort($match);
$this->assertSame(array('.dot/b/c.neon', '.dot/b/d.neon', 'one/b/c.neon', 'one/b/d.neon'), $match);
$this->assertSame(['.dot/b/c.neon', '.dot/b/d.neon', 'one/b/c.neon', 'one/b/d.neon'], $match);
}
public function testGlobToRegexDoubleStarWithoutLeadingSlash()
@@ -73,7 +73,7 @@ class GlobTest extends TestCase
}
sort($match);
$this->assertSame(array('one/a', 'one/b', 'one/b/c.neon', 'one/b/d.neon'), $match);
$this->assertSame(['one/a', 'one/b', 'one/b/c.neon', 'one/b/d.neon'], $match);
}
public function testGlobToRegexDoubleStarWithoutLeadingSlashNotStrictLeadingDot()
@@ -90,6 +90,6 @@ class GlobTest extends TestCase
}
sort($match);
$this->assertSame(array('one/.dot', 'one/a', 'one/b', 'one/b/c.neon', 'one/b/d.neon'), $match);
$this->assertSame(['one/.dot', 'one/a', 'one/b', 'one/b/c.neon', 'one/b/d.neon'], $match);
}
}

View File

@@ -20,7 +20,7 @@ class CustomFilterIteratorTest extends IteratorTestCase
*/
public function testWithInvalidFilter()
{
new CustomFilterIterator(new Iterator(), array('foo'));
new CustomFilterIterator(new Iterator(), ['foo']);
}
/**
@@ -28,7 +28,7 @@ class CustomFilterIteratorTest extends IteratorTestCase
*/
public function testAccept($filters, $expected)
{
$inner = new Iterator(array('test.php', 'test.py', 'foo.php'));
$inner = new Iterator(['test.php', 'test.py', 'foo.php']);
$iterator = new CustomFilterIterator($inner, $filters);
@@ -37,10 +37,10 @@ class CustomFilterIteratorTest extends IteratorTestCase
public function getAcceptData()
{
return array(
array(array(function (\SplFileInfo $fileinfo) { return false; }), array()),
array(array(function (\SplFileInfo $fileinfo) { return 0 === strpos($fileinfo, 'test'); }), array('test.php', 'test.py')),
array(array('is_dir'), array()),
);
return [
[[function (\SplFileInfo $fileinfo) { return false; }], []],
[[function (\SplFileInfo $fileinfo) { return 0 === strpos($fileinfo, 'test'); }], ['test.php', 'test.py']],
[['is_dir'], []],
];
}
}

View File

@@ -32,7 +32,7 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase
public function getAcceptData()
{
$since20YearsAgo = array(
$since20YearsAgo = [
'.git',
'test.py',
'foo',
@@ -54,9 +54,9 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
);
];
$since2MonthsAgo = array(
$since2MonthsAgo = [
'.git',
'test.py',
'foo',
@@ -76,17 +76,17 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
);
];
$untilLastMonth = array(
$untilLastMonth = [
'foo/bar.tmp',
'test.php',
);
];
return array(
array(array(new DateComparator('since 20 years ago')), $this->toAbsolute($since20YearsAgo)),
array(array(new DateComparator('since 2 months ago')), $this->toAbsolute($since2MonthsAgo)),
array(array(new DateComparator('until last month')), $this->toAbsolute($untilLastMonth)),
);
return [
[[new DateComparator('since 20 years ago')], $this->toAbsolute($since20YearsAgo)],
[[new DateComparator('since 2 months ago')], $this->toAbsolute($since2MonthsAgo)],
[[new DateComparator('until last month')], $this->toAbsolute($untilLastMonth)],
];
}
}

View File

@@ -32,7 +32,7 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
public function getAcceptData()
{
$lessThan1 = array(
$lessThan1 = [
'.git',
'test.py',
'foo',
@@ -48,9 +48,9 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
);
];
$lessThanOrEqualTo1 = array(
$lessThanOrEqualTo1 = [
'.git',
'test.py',
'foo',
@@ -72,32 +72,32 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
);
];
$graterThanOrEqualTo1 = array(
$graterThanOrEqualTo1 = [
'toto/.git',
'foo/bar.tmp',
'.foo/.bar',
'.foo/bar',
'qux/baz_100_1.py',
'qux/baz_1_2.py',
);
];
$equalTo1 = array(
$equalTo1 = [
'toto/.git',
'foo/bar.tmp',
'.foo/.bar',
'.foo/bar',
'qux/baz_100_1.py',
'qux/baz_1_2.py',
);
];
return array(
array(0, 0, $this->toAbsolute($lessThan1)),
array(0, 1, $this->toAbsolute($lessThanOrEqualTo1)),
array(2, PHP_INT_MAX, array()),
array(1, PHP_INT_MAX, $this->toAbsolute($graterThanOrEqualTo1)),
array(1, 1, $this->toAbsolute($equalTo1)),
);
return [
[0, 0, $this->toAbsolute($lessThan1)],
[0, 1, $this->toAbsolute($lessThanOrEqualTo1)],
[2, PHP_INT_MAX, []],
[1, PHP_INT_MAX, $this->toAbsolute($graterThanOrEqualTo1)],
[1, 1, $this->toAbsolute($equalTo1)],
];
}
}

View File

@@ -30,7 +30,7 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
public function getAcceptData()
{
$foo = array(
$foo = [
'.bar',
'.foo',
'.foo/.bar',
@@ -50,9 +50,9 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
);
];
$fo = array(
$fo = [
'.bar',
'.foo',
'.foo/.bar',
@@ -74,9 +74,9 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
);
];
$toto = array(
$toto = [
'.bar',
'.foo',
'.foo/.bar',
@@ -96,12 +96,12 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
);
];
return array(
array(array('foo'), $this->toAbsolute($foo)),
array(array('fo'), $this->toAbsolute($fo)),
array(array('toto/'), $this->toAbsolute($toto)),
);
return [
[['foo'], $this->toAbsolute($foo)],
[['fo'], $this->toAbsolute($fo)],
[['toto/'], $this->toAbsolute($toto)],
];
}
}

View File

@@ -29,7 +29,7 @@ class FileTypeFilterIteratorTest extends RealIteratorTestCase
public function getAcceptData()
{
$onlyFiles = array(
$onlyFiles = [
'test.py',
'foo/bar.tmp',
'test.php',
@@ -45,21 +45,21 @@ class FileTypeFilterIteratorTest extends RealIteratorTestCase
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
);
];
$onlyDirectories = array(
$onlyDirectories = [
'.git',
'foo',
'qux',
'toto',
'toto/.git',
'.foo',
);
];
return array(
array(FileTypeFilterIterator::ONLY_FILES, $this->toAbsolute($onlyFiles)),
array(FileTypeFilterIterator::ONLY_DIRECTORIES, $this->toAbsolute($onlyDirectories)),
);
return [
[FileTypeFilterIterator::ONLY_FILES, $this->toAbsolute($onlyFiles)],
[FileTypeFilterIterator::ONLY_DIRECTORIES, $this->toAbsolute($onlyDirectories)],
];
}
}

View File

@@ -17,23 +17,23 @@ class FilecontentFilterIteratorTest extends IteratorTestCase
{
public function testAccept()
{
$inner = new MockFileListIterator(array('test.txt'));
$iterator = new FilecontentFilterIterator($inner, array(), array());
$this->assertIterator(array('test.txt'), $iterator);
$inner = new MockFileListIterator(['test.txt']);
$iterator = new FilecontentFilterIterator($inner, [], []);
$this->assertIterator(['test.txt'], $iterator);
}
public function testDirectory()
{
$inner = new MockFileListIterator(array('directory'));
$iterator = new FilecontentFilterIterator($inner, array('directory'), array());
$this->assertIterator(array(), $iterator);
$inner = new MockFileListIterator(['directory']);
$iterator = new FilecontentFilterIterator($inner, ['directory'], []);
$this->assertIterator([], $iterator);
}
public function testUnreadableFile()
{
$inner = new MockFileListIterator(array('file r-'));
$iterator = new FilecontentFilterIterator($inner, array('file r-'), array());
$this->assertIterator(array(), $iterator);
$inner = new MockFileListIterator(['file r-']);
$iterator = new FilecontentFilterIterator($inner, ['file r-'], []);
$this->assertIterator([], $iterator);
}
/**
@@ -49,38 +49,38 @@ class FilecontentFilterIteratorTest extends IteratorTestCase
{
$inner = new MockFileListIterator();
$inner[] = new MockSplFileInfo(array(
$inner[] = new MockSplFileInfo([
'name' => 'a.txt',
'contents' => 'Lorem ipsum...',
'type' => 'file',
'mode' => 'r+', )
'mode' => 'r+', ]
);
$inner[] = new MockSplFileInfo(array(
$inner[] = new MockSplFileInfo([
'name' => 'b.yml',
'contents' => 'dolor sit...',
'type' => 'file',
'mode' => 'r+', )
'mode' => 'r+', ]
);
$inner[] = new MockSplFileInfo(array(
$inner[] = new MockSplFileInfo([
'name' => 'some/other/dir/third.php',
'contents' => 'amet...',
'type' => 'file',
'mode' => 'r+', )
'mode' => 'r+', ]
);
$inner[] = new MockSplFileInfo(array(
$inner[] = new MockSplFileInfo([
'name' => 'unreadable-file.txt',
'contents' => false,
'type' => 'file',
'mode' => 'r+', )
'mode' => 'r+', ]
);
return array(
array($inner, array('.'), array(), array('a.txt', 'b.yml', 'some/other/dir/third.php')),
array($inner, array('ipsum'), array(), array('a.txt')),
array($inner, array('i', 'amet'), array('Lorem', 'amet'), array('b.yml')),
);
return [
[$inner, ['.'], [], ['a.txt', 'b.yml', 'some/other/dir/third.php']],
[$inner, ['ipsum'], [], ['a.txt']],
[$inner, ['i', 'amet'], ['Lorem', 'amet'], ['b.yml']],
];
}
}

View File

@@ -20,7 +20,7 @@ class FilenameFilterIteratorTest extends IteratorTestCase
*/
public function testAccept($matchPatterns, $noMatchPatterns, $expected)
{
$inner = new InnerNameIterator(array('test.php', 'test.py', 'foo.php'));
$inner = new InnerNameIterator(['test.php', 'test.py', 'foo.php']);
$iterator = new FilenameFilterIterator($inner, $matchPatterns, $noMatchPatterns);
@@ -29,14 +29,14 @@ class FilenameFilterIteratorTest extends IteratorTestCase
public function getAcceptData()
{
return array(
array(array('test.*'), array(), array('test.php', 'test.py')),
array(array(), array('test.*'), array('foo.php')),
array(array('*.php'), array('test.*'), array('foo.php')),
array(array('*.php', '*.py'), array('foo.*'), array('test.php', 'test.py')),
array(array('/\.php$/'), array(), array('test.php', 'foo.php')),
array(array(), array('/\.php$/'), array('test.py')),
);
return [
[['test.*'], [], ['test.php', 'test.py']],
[[], ['test.*'], ['foo.php']],
[['*.php'], ['test.*'], ['foo.php']],
[['*.php', '*.py'], ['foo.*'], ['test.php', 'test.py']],
[['/\.php$/'], [], ['test.php', 'foo.php']],
[[], ['/\.php$/'], ['test.py']],
];
}
}

View File

@@ -13,9 +13,9 @@ namespace Symfony\Component\Finder\Tests\Iterator;
class Iterator implements \Iterator
{
protected $values = array();
protected $values = [];
public function __construct(array $values = array())
public function __construct(array $values = [])
{
foreach ($values as $value) {
$this->attach(new \SplFileInfo($value));

View File

@@ -51,7 +51,7 @@ abstract class IteratorTestCase extends TestCase
$values = array_values(array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator)));
foreach ($expected as $subarray) {
$temp = array();
$temp = [];
while (\count($values) && \count($temp) < \count($subarray)) {
$temp[] = array_shift($values);
}
@@ -69,7 +69,7 @@ abstract class IteratorTestCase extends TestCase
*/
protected function assertIteratorInForeach($expected, \Traversable $iterator)
{
$values = array();
$values = [];
foreach ($iterator as $file) {
$this->assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $file);
$values[] = $file->getPathname();
@@ -89,7 +89,7 @@ abstract class IteratorTestCase extends TestCase
*/
protected function assertOrderedIteratorInForeach($expected, \Traversable $iterator)
{
$values = array();
$values = [];
foreach ($iterator as $file) {
$this->assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $file);
$values[] = $file->getPathname();

View File

@@ -13,7 +13,7 @@ namespace Symfony\Component\Finder\Tests\Iterator;
class MockFileListIterator extends \ArrayIterator
{
public function __construct(array $filesArray = array())
public function __construct(array $filesArray = [])
{
$files = array_map(function ($file) { return new MockSplFileInfo($file); }, $filesArray);
parent::__construct($files);

View File

@@ -28,14 +28,14 @@ class MockSplFileInfo extends \SplFileInfo
if (\is_string($param)) {
parent::__construct($param);
} elseif (\is_array($param)) {
$defaults = array(
$defaults = [
'name' => 'file.txt',
'contents' => null,
'mode' => null,
'type' => null,
'relativePath' => null,
'relativePathname' => null,
);
];
$defaults = array_merge($defaults, $param);
parent::__construct($defaults['name']);
$this->setContents($defaults['contents']);

View File

@@ -27,24 +27,24 @@ class MultiplePcreFilterIteratorTest extends TestCase
public function getIsRegexFixtures()
{
return array(
array('foo', false, 'string'),
array(' foo ', false, '" " is not a valid delimiter'),
array('\\foo\\', false, '"\\" is not a valid delimiter'),
array('afooa', false, '"a" is not a valid delimiter'),
array('//', false, 'the pattern should contain at least 1 character'),
array('/a/', true, 'valid regex'),
array('/foo/', true, 'valid regex'),
array('/foo/i', true, 'valid regex with a single modifier'),
array('/foo/imsxu', true, 'valid regex with multiple modifiers'),
array('#foo#', true, '"#" is a valid delimiter'),
array('{foo}', true, '"{,}" is a valid delimiter pair'),
array('[foo]', true, '"[,]" is a valid delimiter pair'),
array('(foo)', true, '"(,)" is a valid delimiter pair'),
array('<foo>', true, '"<,>" is a valid delimiter pair'),
array('*foo.*', false, '"*" is not considered as a valid delimiter'),
array('?foo.?', false, '"?" is not considered as a valid delimiter'),
);
return [
['foo', false, 'string'],
[' foo ', false, '" " is not a valid delimiter'],
['\\foo\\', false, '"\\" is not a valid delimiter'],
['afooa', false, '"a" is not a valid delimiter'],
['//', false, 'the pattern should contain at least 1 character'],
['/a/', true, 'valid regex'],
['/foo/', true, 'valid regex'],
['/foo/i', true, 'valid regex with a single modifier'],
['/foo/imsxu', true, 'valid regex with multiple modifiers'],
['#foo#', true, '"#" is a valid delimiter'],
['{foo}', true, '"{,}" is a valid delimiter pair'],
['[foo]', true, '"[,]" is a valid delimiter pair'],
['(foo)', true, '"(,)" is a valid delimiter pair'],
['<foo>', true, '"<,>" is a valid delimiter pair'],
['*foo.*', false, '"*" is not considered as a valid delimiter'],
['?foo.?', false, '"?" is not considered as a valid delimiter'],
];
}
}

View File

@@ -29,54 +29,54 @@ class PathFilterIteratorTest extends IteratorTestCase
$inner = new MockFileListIterator();
//PATH: A/B/C/abc.dat
$inner[] = new MockSplFileInfo(array(
$inner[] = new MockSplFileInfo([
'name' => 'abc.dat',
'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C'.\DIRECTORY_SEPARATOR.'abc.dat',
));
]);
//PATH: A/B/ab.dat
$inner[] = new MockSplFileInfo(array(
$inner[] = new MockSplFileInfo([
'name' => 'ab.dat',
'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat',
));
]);
//PATH: A/a.dat
$inner[] = new MockSplFileInfo(array(
$inner[] = new MockSplFileInfo([
'name' => 'a.dat',
'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'a.dat',
));
]);
//PATH: copy/A/B/C/abc.dat.copy
$inner[] = new MockSplFileInfo(array(
$inner[] = new MockSplFileInfo([
'name' => 'abc.dat.copy',
'relativePathname' => 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C'.\DIRECTORY_SEPARATOR.'abc.dat',
));
]);
//PATH: copy/A/B/ab.dat.copy
$inner[] = new MockSplFileInfo(array(
$inner[] = new MockSplFileInfo([
'name' => 'ab.dat.copy',
'relativePathname' => 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat',
));
]);
//PATH: copy/A/a.dat.copy
$inner[] = new MockSplFileInfo(array(
$inner[] = new MockSplFileInfo([
'name' => 'a.dat.copy',
'relativePathname' => 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'a.dat',
));
]);
return array(
array($inner, array('/^A/'), array(), array('abc.dat', 'ab.dat', 'a.dat')),
array($inner, array('/^A\/B/'), array(), array('abc.dat', 'ab.dat')),
array($inner, array('/^A\/B\/C/'), array(), array('abc.dat')),
array($inner, array('/A\/B\/C/'), array(), array('abc.dat', 'abc.dat.copy')),
return [
[$inner, ['/^A/'], [], ['abc.dat', 'ab.dat', 'a.dat']],
[$inner, ['/^A\/B/'], [], ['abc.dat', 'ab.dat']],
[$inner, ['/^A\/B\/C/'], [], ['abc.dat']],
[$inner, ['/A\/B\/C/'], [], ['abc.dat', 'abc.dat.copy']],
array($inner, array('A'), array(), array('abc.dat', 'ab.dat', 'a.dat', 'abc.dat.copy', 'ab.dat.copy', 'a.dat.copy')),
array($inner, array('A/B'), array(), array('abc.dat', 'ab.dat', 'abc.dat.copy', 'ab.dat.copy')),
array($inner, array('A/B/C'), array(), array('abc.dat', 'abc.dat.copy')),
[$inner, ['A'], [], ['abc.dat', 'ab.dat', 'a.dat', 'abc.dat.copy', 'ab.dat.copy', 'a.dat.copy']],
[$inner, ['A/B'], [], ['abc.dat', 'ab.dat', 'abc.dat.copy', 'ab.dat.copy']],
[$inner, ['A/B/C'], [], ['abc.dat', 'abc.dat.copy']],
array($inner, array('copy/A'), array(), array('abc.dat.copy', 'ab.dat.copy', 'a.dat.copy')),
array($inner, array('copy/A/B'), array(), array('abc.dat.copy', 'ab.dat.copy')),
array($inner, array('copy/A/B/C'), array(), array('abc.dat.copy')),
);
[$inner, ['copy/A'], [], ['abc.dat.copy', 'ab.dat.copy', 'a.dat.copy']],
[$inner, ['copy/A/B'], [], ['abc.dat.copy', 'ab.dat.copy']],
[$inner, ['copy/A/B/C'], [], ['abc.dat.copy']],
];
}
}

View File

@@ -20,7 +20,7 @@ abstract class RealIteratorTestCase extends IteratorTestCase
{
self::$tmpDir = realpath(sys_get_temp_dir()).\DIRECTORY_SEPARATOR.'symfony_finder';
self::$files = array(
self::$files = [
'.git/',
'.foo/',
'.foo/.bar',
@@ -42,7 +42,7 @@ abstract class RealIteratorTestCase extends IteratorTestCase
'qux/',
'qux/baz_1_2.py',
'qux/baz_100_1.py',
);
];
self::$files = self::toAbsolute(self::$files);
@@ -97,7 +97,7 @@ abstract class RealIteratorTestCase extends IteratorTestCase
}
if (\is_array($files)) {
$f = array();
$f = [];
foreach ($files as $file) {
if (\is_array($file)) {
$f[] = self::toAbsolute($file);
@@ -118,7 +118,7 @@ abstract class RealIteratorTestCase extends IteratorTestCase
protected static function toAbsoluteFixtures($files)
{
$f = array();
$f = [];
foreach ($files as $file) {
$f[] = realpath(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.$file);
}

View File

@@ -42,11 +42,11 @@ class RecursiveDirectoryIteratorTest extends IteratorTestCase
$this->markTestSkipped('Unsupported stream "ftp".');
}
$contains = array(
$contains = [
'ftp://speedtest.tele2.net'.\DIRECTORY_SEPARATOR.'1000GB.zip',
'ftp://speedtest.tele2.net'.\DIRECTORY_SEPARATOR.'100GB.zip',
);
$actual = array();
];
$actual = [];
$i->seek(0);
$actual[] = $i->getPathname();

View File

@@ -30,7 +30,7 @@ class SizeRangeFilterIteratorTest extends RealIteratorTestCase
public function getAcceptData()
{
$lessThan1KGreaterThan05K = array(
$lessThan1KGreaterThan05K = [
'.foo',
'.git',
'foo',
@@ -38,11 +38,11 @@ class SizeRangeFilterIteratorTest extends RealIteratorTestCase
'test.php',
'toto',
'toto/.git',
);
];
return array(
array(array(new NumberComparator('< 1K'), new NumberComparator('> 0.5K')), $this->toAbsolute($lessThan1KGreaterThan05K)),
);
return [
[[new NumberComparator('< 1K'), new NumberComparator('> 0.5K')], $this->toAbsolute($lessThan1KGreaterThan05K)],
];
}
}

View File

@@ -18,7 +18,7 @@ class SortableIteratorTest extends RealIteratorTestCase
public function testConstructor()
{
try {
new SortableIterator(new Iterator(array()), 'foobar');
new SortableIterator(new Iterator([]), 'foobar');
$this->fail('__construct() throws an \InvalidArgumentException exception if the mode is not valid');
} catch (\Exception $e) {
$this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException exception if the mode is not valid');
@@ -73,7 +73,7 @@ class SortableIteratorTest extends RealIteratorTestCase
public function getAcceptData()
{
$sortByName = array(
$sortByName = [
'.bar',
'.foo',
'.foo/.bar',
@@ -95,9 +95,9 @@ class SortableIteratorTest extends RealIteratorTestCase
'test.py',
'toto',
'toto/.git',
);
];
$sortByType = array(
$sortByType = [
'.foo',
'.git',
'foo',
@@ -119,13 +119,13 @@ class SortableIteratorTest extends RealIteratorTestCase
'qux_2_0.php',
'test.php',
'test.py',
);
];
$sortByAccessedTime = array(
$sortByAccessedTime = [
// For these two files the access time was set to 2005-10-15
array('foo/bar.tmp', 'test.php'),
['foo/bar.tmp', 'test.php'],
// These files were created more or less at the same time
array(
[
'.git',
'.foo',
'.foo/.bar',
@@ -144,13 +144,13 @@ class SortableIteratorTest extends RealIteratorTestCase
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
),
],
// This file was accessed after sleeping for 1 sec
array('.bar'),
);
['.bar'],
];
$sortByChangedTime = array(
array(
$sortByChangedTime = [
[
'.git',
'.foo',
'.foo/.bar',
@@ -170,13 +170,13 @@ class SortableIteratorTest extends RealIteratorTestCase
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
),
array('test.php'),
array('test.py'),
);
],
['test.php'],
['test.py'],
];
$sortByModifiedTime = array(
array(
$sortByModifiedTime = [
[
'.git',
'.foo',
'.foo/.bar',
@@ -196,12 +196,12 @@ class SortableIteratorTest extends RealIteratorTestCase
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
),
array('test.php'),
array('test.py'),
);
],
['test.php'],
['test.py'],
];
$sortByNameNatural = array(
$sortByNameNatural = [
'.bar',
'.foo',
'.foo/.bar',
@@ -223,9 +223,9 @@ class SortableIteratorTest extends RealIteratorTestCase
'test.py',
'toto',
'toto/.git',
);
];
$customComparison = array(
$customComparison = [
'.bar',
'.foo',
'.foo/.bar',
@@ -247,16 +247,16 @@ class SortableIteratorTest extends RealIteratorTestCase
'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)),
);
return [
[SortableIterator::SORT_BY_NAME, $this->toAbsolute($sortByName)],
[SortableIterator::SORT_BY_TYPE, $this->toAbsolute($sortByType)],
[SortableIterator::SORT_BY_ACCESSED_TIME, $this->toAbsolute($sortByAccessedTime)],
[SortableIterator::SORT_BY_CHANGED_TIME, $this->toAbsolute($sortByChangedTime)],
[SortableIterator::SORT_BY_MODIFIED_TIME, $this->toAbsolute($sortByModifiedTime)],
[SortableIterator::SORT_BY_NAME_NATURAL, $this->toAbsolute($sortByNameNatural)],
[function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, $this->toAbsolute($customComparison)],
];
}
}