updated-packages
This commit is contained in:
3
vendor/symfony/finder/.gitignore
vendored
3
vendor/symfony/finder/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
5
vendor/symfony/finder/CHANGELOG.md
vendored
5
vendor/symfony/finder/CHANGELOG.md
vendored
@@ -1,6 +1,11 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
* added Finder::ignoreVCSIgnored() to ignore files based on rules listed in .gitignore
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
|
@@ -64,7 +64,7 @@ class Comparator
|
||||
$operator = '==';
|
||||
}
|
||||
|
||||
if (!\in_array($operator, array('>', '<', '>=', '<=', '==', '!='))) {
|
||||
if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ class DateComparator extends Comparator
|
||||
throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
|
||||
}
|
||||
|
||||
$operator = isset($matches[1]) ? $matches[1] : '==';
|
||||
$operator = $matches[1] ?? '==';
|
||||
if ('since' === $operator || 'after' === $operator) {
|
||||
$operator = '>';
|
||||
}
|
||||
|
@@ -41,8 +41,8 @@ class NumberComparator extends Comparator
|
||||
*/
|
||||
public function __construct(?string $test)
|
||||
{
|
||||
if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
|
||||
throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test));
|
||||
if (null === $test || !preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
|
||||
throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test ?? 'null'));
|
||||
}
|
||||
|
||||
$target = $matches[2];
|
||||
@@ -74,6 +74,6 @@ class NumberComparator extends Comparator
|
||||
}
|
||||
|
||||
$this->setTarget($target);
|
||||
$this->setOperator(isset($matches[1]) ? $matches[1] : '==');
|
||||
$this->setOperator($matches[1] ?? '==');
|
||||
}
|
||||
}
|
||||
|
19
vendor/symfony/finder/Exception/DirectoryNotFoundException.php
vendored
Normal file
19
vendor/symfony/finder/Exception/DirectoryNotFoundException.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Exception;
|
||||
|
||||
/**
|
||||
* @author Andreas Erhard <andreas.erhard@i-med.ac.at>
|
||||
*/
|
||||
class DirectoryNotFoundException extends \InvalidArgumentException
|
||||
{
|
||||
}
|
155
vendor/symfony/finder/Finder.php
vendored
155
vendor/symfony/finder/Finder.php
vendored
@@ -13,12 +13,14 @@ namespace Symfony\Component\Finder;
|
||||
|
||||
use Symfony\Component\Finder\Comparator\DateComparator;
|
||||
use Symfony\Component\Finder\Comparator\NumberComparator;
|
||||
use Symfony\Component\Finder\Exception\DirectoryNotFoundException;
|
||||
use Symfony\Component\Finder\Iterator\CustomFilterIterator;
|
||||
use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
|
||||
use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
|
||||
use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
|
||||
use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
|
||||
use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
|
||||
use Symfony\Component\Finder\Iterator\LazyIterator;
|
||||
use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
|
||||
use Symfony\Component\Finder\Iterator\SortableIterator;
|
||||
|
||||
@@ -29,7 +31,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__);
|
||||
*
|
||||
@@ -37,30 +39,31 @@ use Symfony\Component\Finder\Iterator\SortableIterator;
|
||||
*/
|
||||
class Finder implements \IteratorAggregate, \Countable
|
||||
{
|
||||
const IGNORE_VCS_FILES = 1;
|
||||
const IGNORE_DOT_FILES = 2;
|
||||
public const IGNORE_VCS_FILES = 1;
|
||||
public const IGNORE_DOT_FILES = 2;
|
||||
public const IGNORE_VCS_IGNORED_FILES = 4;
|
||||
|
||||
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()
|
||||
{
|
||||
@@ -172,7 +175,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function name($patterns)
|
||||
{
|
||||
$this->names = \array_merge($this->names, (array) $patterns);
|
||||
$this->names = array_merge($this->names, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -188,7 +191,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function notName($patterns)
|
||||
{
|
||||
$this->notNames = \array_merge($this->notNames, (array) $patterns);
|
||||
$this->notNames = array_merge($this->notNames, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -210,7 +213,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function contains($patterns)
|
||||
{
|
||||
$this->contains = \array_merge($this->contains, (array) $patterns);
|
||||
$this->contains = array_merge($this->contains, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -232,7 +235,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function notContains($patterns)
|
||||
{
|
||||
$this->notContains = \array_merge($this->notContains, (array) $patterns);
|
||||
$this->notContains = array_merge($this->notContains, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -256,7 +259,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function path($patterns)
|
||||
{
|
||||
$this->paths = \array_merge($this->paths, (array) $patterns);
|
||||
$this->paths = array_merge($this->paths, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -280,7 +283,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function notPath($patterns)
|
||||
{
|
||||
$this->notPaths = \array_merge($this->notPaths, (array) $patterns);
|
||||
$this->notPaths = array_merge($this->notPaths, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -373,6 +376,24 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces Finder to obey .gitignore and ignore files based on rules listed there.
|
||||
*
|
||||
* This option is disabled by default.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ignoreVCSIgnored(bool $ignoreVCSIgnored)
|
||||
{
|
||||
if ($ignoreVCSIgnored) {
|
||||
$this->ignore |= static::IGNORE_VCS_IGNORED_FILES;
|
||||
} else {
|
||||
$this->ignore &= ~static::IGNORE_VCS_IGNORED_FILES;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds VCS patterns.
|
||||
*
|
||||
@@ -420,8 +441,8 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function sortByName(/* bool $useNaturalSort = false */)
|
||||
{
|
||||
if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
|
||||
@trigger_error(sprintf('The "%s()" method will have a new "bool $useNaturalSort = false" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
|
||||
if (\func_num_args() < 1 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface && !$this instanceof \Mockery\MockInterface) {
|
||||
@trigger_error(sprintf('The "%s()" method will have a new "bool $useNaturalSort = false" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), \E_USER_DEPRECATED);
|
||||
}
|
||||
$useNaturalSort = 0 < \func_num_args() && func_get_arg(0);
|
||||
|
||||
@@ -562,23 +583,24 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Searches files and directories which match defined rules.
|
||||
*
|
||||
* @param string|array $dirs A directory path or an array of directories
|
||||
* @param string|string[] $dirs A directory path or an array of directories
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException if one of the directories does not exist
|
||||
* @throws DirectoryNotFoundException if one of the directories does not exist
|
||||
*/
|
||||
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));
|
||||
} elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? \GLOB_BRACE : 0) | \GLOB_ONLYDIR | \GLOB_NOSORT)) {
|
||||
sort($glob);
|
||||
$resolvedDirs = array_merge($resolvedDirs, array_map([$this, 'normalizeDir'], $glob));
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
|
||||
throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,6 +618,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @throws \LogicException if the in() method has not been called
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
{
|
||||
if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
|
||||
@@ -603,18 +626,30 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
}
|
||||
|
||||
if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
|
||||
return $this->searchInDirectory($this->dirs[0]);
|
||||
$iterator = $this->searchInDirectory($this->dirs[0]);
|
||||
|
||||
if ($this->sort || $this->reverseSorting) {
|
||||
$iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
|
||||
}
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
|
||||
$iterator = new \AppendIterator();
|
||||
foreach ($this->dirs as $dir) {
|
||||
$iterator->append($this->searchInDirectory($dir));
|
||||
$iterator->append(new \IteratorIterator(new LazyIterator(function () use ($dir) {
|
||||
return $this->searchInDirectory($dir);
|
||||
})));
|
||||
}
|
||||
|
||||
foreach ($this->iterators as $it) {
|
||||
$iterator->append($it);
|
||||
}
|
||||
|
||||
if ($this->sort || $this->reverseSorting) {
|
||||
$iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
|
||||
}
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
|
||||
@@ -635,10 +670,11 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
$this->iterators[] = $iterator->getIterator();
|
||||
} elseif ($iterator instanceof \Iterator) {
|
||||
$this->iterators[] = $iterator;
|
||||
} elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
|
||||
} elseif (is_iterable($iterator)) {
|
||||
$it = new \ArrayIterator();
|
||||
foreach ($iterator as $file) {
|
||||
$it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
|
||||
$file = $file instanceof \SplFileInfo ? $file : new \SplFileInfo($file);
|
||||
$it[$file->getPathname()] = $file;
|
||||
}
|
||||
$this->iterators[] = $it;
|
||||
} else {
|
||||
@@ -649,7 +685,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the any results were found.
|
||||
* Check if any results were found.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -667,6 +703,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return iterator_count($this->getIterator());
|
||||
@@ -674,16 +711,27 @@ 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[] = '#(^|/)\..+(/|$)#';
|
||||
}
|
||||
|
||||
if (static::IGNORE_VCS_IGNORED_FILES === (static::IGNORE_VCS_IGNORED_FILES & $this->ignore)) {
|
||||
$gitignoreFilePath = sprintf('%s/.gitignore', $dir);
|
||||
if (!is_readable($gitignoreFilePath)) {
|
||||
throw new \RuntimeException(sprintf('The "ignoreVCSIgnored" option cannot be used by the Finder as the "%s" file is not readable.', $gitignoreFilePath));
|
||||
}
|
||||
$notPaths = array_merge($notPaths, [Gitignore::toRegex(file_get_contents($gitignoreFilePath))]);
|
||||
}
|
||||
|
||||
$minDepth = 0;
|
||||
$maxDepth = PHP_INT_MAX;
|
||||
$maxDepth = \PHP_INT_MAX;
|
||||
|
||||
foreach ($this->depths as $comparator) {
|
||||
switch ($comparator->getOperator()) {
|
||||
@@ -712,13 +760,13 @@ 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);
|
||||
|
||||
if ($minDepth > 0 || $maxDepth < PHP_INT_MAX) {
|
||||
if ($minDepth > 0 || $maxDepth < \PHP_INT_MAX) {
|
||||
$iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
|
||||
}
|
||||
|
||||
@@ -746,13 +794,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->sort || $this->reverseSorting) {
|
||||
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting);
|
||||
$iterator = $iteratorAggregate->getIterator();
|
||||
if ($this->paths || $notPaths) {
|
||||
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths);
|
||||
}
|
||||
|
||||
return $iterator;
|
||||
@@ -761,17 +804,17 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Normalizes given directory names by removing trailing slashes.
|
||||
*
|
||||
* Excluding: (s)ftp:// wrapper
|
||||
*
|
||||
* @param string $dir
|
||||
*
|
||||
* @return string
|
||||
* Excluding: (s)ftp:// or ssh2.(s)ftp:// wrapper
|
||||
*/
|
||||
private function normalizeDir($dir)
|
||||
private function normalizeDir(string $dir): string
|
||||
{
|
||||
if ('/' === $dir) {
|
||||
return $dir;
|
||||
}
|
||||
|
||||
$dir = rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
|
||||
|
||||
if (preg_match('#^s?ftp://#', $dir)) {
|
||||
if (preg_match('#^(ssh2\.)?s?ftp://#', $dir)) {
|
||||
$dir .= '/';
|
||||
}
|
||||
|
||||
|
83
vendor/symfony/finder/Gitignore.php
vendored
Normal file
83
vendor/symfony/finder/Gitignore.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder;
|
||||
|
||||
/**
|
||||
* Gitignore matches against text.
|
||||
*
|
||||
* @author Michael Voříšek <vorismi3@fel.cvut.cz>
|
||||
* @author Ahmed Abdou <mail@ahmd.io>
|
||||
*/
|
||||
class Gitignore
|
||||
{
|
||||
/**
|
||||
* Returns a regexp which is the equivalent of the gitignore pattern.
|
||||
*
|
||||
* Format specification: https://git-scm.com/docs/gitignore#_pattern_format
|
||||
*/
|
||||
public static function toRegex(string $gitignoreFileContent): string
|
||||
{
|
||||
$gitignoreFileContent = preg_replace('~(?<!\\\\)#[^\n\r]*~', '', $gitignoreFileContent);
|
||||
$gitignoreLines = preg_split('~\r\n?|\n~', $gitignoreFileContent);
|
||||
|
||||
$res = self::lineToRegex('');
|
||||
foreach ($gitignoreLines as $i => $line) {
|
||||
$line = preg_replace('~(?<!\\\\)[ \t]+$~', '', $line);
|
||||
|
||||
if ('!' === substr($line, 0, 1)) {
|
||||
$line = substr($line, 1);
|
||||
$isNegative = true;
|
||||
} else {
|
||||
$isNegative = false;
|
||||
}
|
||||
|
||||
if ('' !== $line) {
|
||||
if ($isNegative) {
|
||||
$res = '(?!'.self::lineToRegex($line).'$)'.$res;
|
||||
} else {
|
||||
$res = '(?:'.$res.'|'.self::lineToRegex($line).')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '~^(?:'.$res.')~s';
|
||||
}
|
||||
|
||||
private static function lineToRegex(string $gitignoreLine): string
|
||||
{
|
||||
if ('' === $gitignoreLine) {
|
||||
return '$f'; // always false
|
||||
}
|
||||
|
||||
$slashPos = strpos($gitignoreLine, '/');
|
||||
if (false !== $slashPos && \strlen($gitignoreLine) - 1 !== $slashPos) {
|
||||
if (0 === $slashPos) {
|
||||
$gitignoreLine = substr($gitignoreLine, 1);
|
||||
}
|
||||
$isAbsolute = true;
|
||||
} else {
|
||||
$isAbsolute = false;
|
||||
}
|
||||
|
||||
$regex = preg_quote(str_replace('\\', '', $gitignoreLine), '~');
|
||||
$regex = preg_replace_callback('~\\\\\[((?:\\\\!)?)([^\[\]]*)\\\\\]~', function (array $matches): string {
|
||||
return '['.('' !== $matches[1] ? '^' : '').str_replace('\\-', '-', $matches[2]).']';
|
||||
}, $regex);
|
||||
$regex = preg_replace('~(?:(?:\\\\\*){2,}(/?))+~', '(?:(?:(?!//).(?<!//))+$1)?', $regex);
|
||||
$regex = preg_replace('~\\\\\*~', '[^/]*', $regex);
|
||||
$regex = preg_replace('~\\\\\?~', '[^/]', $regex);
|
||||
|
||||
return ($isAbsolute ? '' : '(?:[^/]+/)*')
|
||||
.$regex
|
||||
.(!str_ends_with($gitignoreLine, '/') ? '(?:$|/)' : '');
|
||||
}
|
||||
}
|
2
vendor/symfony/finder/Glob.php
vendored
2
vendor/symfony/finder/Glob.php
vendored
@@ -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";
|
||||
* }
|
||||
|
@@ -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
|
||||
@@ -46,12 +46,13 @@ class CustomFilterIterator extends \FilterIterator
|
||||
*
|
||||
* @return bool true if the value should be kept, false otherwise
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
$fileinfo = $this->current();
|
||||
|
||||
foreach ($this->filters as $filter) {
|
||||
if (false === \call_user_func($filter, $fileinfo)) {
|
||||
if (false === $filter($fileinfo)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
@@ -38,6 +38,7 @@ class DateRangeFilterIterator extends \FilterIterator
|
||||
*
|
||||
* @return bool true if the value should be kept, false otherwise
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
$fileinfo = $this->current();
|
||||
|
@@ -25,10 +25,10 @@ class DepthRangeFilterIterator extends \FilterIterator
|
||||
* @param int $minDepth The min depth
|
||||
* @param int $maxDepth The max depth
|
||||
*/
|
||||
public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth = 0, int $maxDepth = PHP_INT_MAX)
|
||||
public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth = 0, int $maxDepth = \PHP_INT_MAX)
|
||||
{
|
||||
$this->minDepth = $minDepth;
|
||||
$iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
|
||||
$iterator->setMaxDepth(\PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
|
||||
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
@@ -38,6 +38,7 @@ class DepthRangeFilterIterator extends \FilterIterator
|
||||
*
|
||||
* @return bool true if the value should be kept, false otherwise
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
return $this->getInnerIterator()->getDepth() >= $this->minDepth;
|
||||
|
@@ -20,21 +20,21 @@ class ExcludeDirectoryFilterIterator extends \FilterIterator implements \Recursi
|
||||
{
|
||||
private $iterator;
|
||||
private $isRecursive;
|
||||
private $excludedDirs = array();
|
||||
private $excludedDirs = [];
|
||||
private $excludedPattern;
|
||||
|
||||
/**
|
||||
* @param \Iterator $iterator The Iterator to filter
|
||||
* @param array $directories An array of directories to exclude
|
||||
* @param string[] $directories An array of directories to exclude
|
||||
*/
|
||||
public function __construct(\Iterator $iterator, array $directories)
|
||||
{
|
||||
$this->iterator = $iterator;
|
||||
$this->isRecursive = $iterator instanceof \RecursiveIterator;
|
||||
$patterns = array();
|
||||
$patterns = [];
|
||||
foreach ($directories as $directory) {
|
||||
$directory = rtrim($directory, '/');
|
||||
if (!$this->isRecursive || false !== strpos($directory, '/')) {
|
||||
if (!$this->isRecursive || str_contains($directory, '/')) {
|
||||
$patterns[] = preg_quote($directory, '#');
|
||||
} else {
|
||||
$this->excludedDirs[$directory] = true;
|
||||
@@ -52,6 +52,7 @@ class ExcludeDirectoryFilterIterator extends \FilterIterator implements \Recursi
|
||||
*
|
||||
* @return bool True if the value should be kept, false otherwise
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
|
||||
@@ -68,14 +69,22 @@ class ExcludeDirectoryFilterIterator extends \FilterIterator implements \Recursi
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function hasChildren()
|
||||
{
|
||||
return $this->isRecursive && $this->iterator->hasChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getChildren()
|
||||
{
|
||||
$children = new self($this->iterator->getChildren(), array());
|
||||
$children = new self($this->iterator->getChildren(), []);
|
||||
$children->excludedDirs = $this->excludedDirs;
|
||||
$children->excludedPattern = $this->excludedPattern;
|
||||
|
||||
|
@@ -18,8 +18,8 @@ namespace Symfony\Component\Finder\Iterator;
|
||||
*/
|
||||
class FileTypeFilterIterator extends \FilterIterator
|
||||
{
|
||||
const ONLY_FILES = 1;
|
||||
const ONLY_DIRECTORIES = 2;
|
||||
public const ONLY_FILES = 1;
|
||||
public const ONLY_DIRECTORIES = 2;
|
||||
|
||||
private $mode;
|
||||
|
||||
@@ -39,6 +39,7 @@ class FileTypeFilterIterator extends \FilterIterator
|
||||
*
|
||||
* @return bool true if the value should be kept, false otherwise
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
$fileinfo = $this->current();
|
||||
|
@@ -24,6 +24,7 @@ class FilecontentFilterIterator extends MultiplePcreFilterIterator
|
||||
*
|
||||
* @return bool true if the value should be kept, false otherwise
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
if (!$this->matchRegexps && !$this->noMatchRegexps) {
|
||||
|
@@ -25,6 +25,7 @@ class FilenameFilterIterator extends MultiplePcreFilterIterator
|
||||
*
|
||||
* @return bool true if the value should be kept, false otherwise
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
return $this->isAccepted($this->current()->getFilename());
|
||||
|
32
vendor/symfony/finder/Iterator/LazyIterator.php
vendored
Normal file
32
vendor/symfony/finder/Iterator/LazyIterator.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Iterator;
|
||||
|
||||
/**
|
||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class LazyIterator implements \IteratorAggregate
|
||||
{
|
||||
private $iteratorFactory;
|
||||
|
||||
public function __construct(callable $iteratorFactory)
|
||||
{
|
||||
$this->iteratorFactory = $iteratorFactory;
|
||||
}
|
||||
|
||||
public function getIterator(): \Traversable
|
||||
{
|
||||
yield from ($this->iteratorFactory)();
|
||||
}
|
||||
}
|
@@ -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
|
||||
@@ -83,7 +83,13 @@ abstract class MultiplePcreFilterIterator extends \FilterIterator
|
||||
*/
|
||||
protected function isRegex($str)
|
||||
{
|
||||
if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
|
||||
$availableModifiers = 'imsxuADU';
|
||||
|
||||
if (\PHP_VERSION_ID >= 80200) {
|
||||
$availableModifiers .= 'n';
|
||||
}
|
||||
|
||||
if (preg_match('/^(.{3,}?)['.$availableModifiers.']*$/', $str, $m)) {
|
||||
$start = substr($m[1], 0, 1);
|
||||
$end = substr($m[1], -1);
|
||||
|
||||
@@ -91,7 +97,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;
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator
|
||||
*
|
||||
* @return bool true if the value should be kept, false otherwise
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
$filename = $this->current()->getRelativePathname();
|
||||
|
@@ -58,19 +58,24 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
||||
*
|
||||
* @return SplFileInfo File information
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
// the logic here avoids redoing the same work in all iterations
|
||||
|
||||
if (null === $subPathname = $this->subPath) {
|
||||
$subPathname = $this->subPath = (string) $this->getSubPath();
|
||||
$subPathname = $this->subPath = $this->getSubPath();
|
||||
}
|
||||
if ('' !== $subPathname) {
|
||||
$subPathname .= $this->directorySeparator;
|
||||
}
|
||||
$subPathname .= $this->getFilename();
|
||||
|
||||
return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname);
|
||||
if ('/' !== $basePath = $this->rootPath) {
|
||||
$basePath .= $this->directorySeparator;
|
||||
}
|
||||
|
||||
return new SplFileInfo($basePath.$subPathname, $this->subPath, $subPathname);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,6 +83,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
||||
*
|
||||
* @throws AccessDeniedException
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getChildren()
|
||||
{
|
||||
try {
|
||||
@@ -96,7 +102,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);
|
||||
}
|
||||
@@ -105,7 +111,10 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
||||
|
||||
/**
|
||||
* Do nothing for non rewindable stream.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
if (false === $this->isRewindable()) {
|
||||
|
@@ -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
|
||||
@@ -38,6 +38,7 @@ class SizeRangeFilterIterator extends \FilterIterator
|
||||
*
|
||||
* @return bool true if the value should be kept, false otherwise
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
$fileinfo = $this->current();
|
||||
|
@@ -18,20 +18,19 @@ namespace Symfony\Component\Finder\Iterator;
|
||||
*/
|
||||
class SortableIterator implements \IteratorAggregate
|
||||
{
|
||||
const SORT_BY_NONE = 0;
|
||||
const SORT_BY_NAME = 1;
|
||||
const SORT_BY_TYPE = 2;
|
||||
const SORT_BY_ACCESSED_TIME = 3;
|
||||
const SORT_BY_CHANGED_TIME = 4;
|
||||
const SORT_BY_MODIFIED_TIME = 5;
|
||||
const SORT_BY_NAME_NATURAL = 6;
|
||||
public const SORT_BY_NONE = 0;
|
||||
public const SORT_BY_NAME = 1;
|
||||
public const SORT_BY_TYPE = 2;
|
||||
public const SORT_BY_ACCESSED_TIME = 3;
|
||||
public const SORT_BY_CHANGED_TIME = 4;
|
||||
public const SORT_BY_MODIFIED_TIME = 5;
|
||||
public const SORT_BY_NAME_NATURAL = 6;
|
||||
|
||||
private $iterator;
|
||||
private $sort;
|
||||
|
||||
/**
|
||||
* @param \Traversable $iterator The Iterator to filter
|
||||
* @param int|callable $sort The sort type (SORT_BY_NAME, SORT_BY_TYPE, or a PHP callback)
|
||||
* @param int|callable $sort The sort type (SORT_BY_NAME, SORT_BY_TYPE, or a PHP callback)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
@@ -41,44 +40,48 @@ class SortableIterator implements \IteratorAggregate
|
||||
$order = $reverseOrder ? -1 : 1;
|
||||
|
||||
if (self::SORT_BY_NAME === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
return $order * strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
|
||||
$this->sort = static function ($a, $b) use ($order) {
|
||||
return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_NAME_NATURAL === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
$this->sort = static function ($a, $b) use ($order) {
|
||||
return $order * strnatcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_TYPE === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
$this->sort = static function ($a, $b) use ($order) {
|
||||
if ($a->isDir() && $b->isFile()) {
|
||||
return -$order;
|
||||
} elseif ($a->isFile() && $b->isDir()) {
|
||||
return $order;
|
||||
}
|
||||
|
||||
return $order * strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
|
||||
return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
$this->sort = static function ($a, $b) use ($order) {
|
||||
return $order * ($a->getATime() - $b->getATime());
|
||||
};
|
||||
} elseif (self::SORT_BY_CHANGED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
$this->sort = static function ($a, $b) use ($order) {
|
||||
return $order * ($a->getCTime() - $b->getCTime());
|
||||
};
|
||||
} elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
$this->sort = static function ($a, $b) use ($order) {
|
||||
return $order * ($a->getMTime() - $b->getMTime());
|
||||
};
|
||||
} elseif (self::SORT_BY_NONE === $sort) {
|
||||
$this->sort = $order;
|
||||
} elseif (\is_callable($sort)) {
|
||||
$this->sort = $reverseOrder ? function ($a, $b) use ($sort) { return -\call_user_func($sort, $a, $b); } : $sort;
|
||||
$this->sort = $reverseOrder ? static 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.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Traversable
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
{
|
||||
if (1 === $this->sort) {
|
||||
|
2
vendor/symfony/finder/LICENSE
vendored
2
vendor/symfony/finder/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2018 Fabien Potencier
|
||||
Copyright (c) 2004-2022 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
10
vendor/symfony/finder/README.md
vendored
10
vendor/symfony/finder/README.md
vendored
@@ -7,8 +7,8 @@ interface.
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Documentation](https://symfony.com/doc/current/components/finder.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
* [Documentation](https://symfony.com/doc/current/components/finder.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
|
7
vendor/symfony/finder/SplFileInfo.php
vendored
7
vendor/symfony/finder/SplFileInfo.php
vendored
@@ -57,6 +57,13 @@ class SplFileInfo extends \SplFileInfo
|
||||
return $this->relativePathname;
|
||||
}
|
||||
|
||||
public function getFilenameWithoutExtension(): string
|
||||
{
|
||||
$filename = $this->getFilename();
|
||||
|
||||
return pathinfo($filename, \PATHINFO_FILENAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contents of the file.
|
||||
*
|
||||
|
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Finder\Comparator\Comparator;
|
||||
|
||||
class ComparatorTest extends TestCase
|
||||
{
|
||||
public function testGetSetOperator()
|
||||
{
|
||||
$comparator = new Comparator();
|
||||
try {
|
||||
$comparator->setOperator('foo');
|
||||
$this->fail('->setOperator() throws an \InvalidArgumentException if the operator is not valid.');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('InvalidArgumentException', $e, '->setOperator() throws an \InvalidArgumentException if the operator is not valid.');
|
||||
}
|
||||
|
||||
$comparator = new Comparator();
|
||||
$comparator->setOperator('>');
|
||||
$this->assertEquals('>', $comparator->getOperator(), '->getOperator() returns the current operator');
|
||||
}
|
||||
|
||||
public function testGetSetTarget()
|
||||
{
|
||||
$comparator = new Comparator();
|
||||
$comparator->setTarget(8);
|
||||
$this->assertEquals(8, $comparator->getTarget(), '->getTarget() returns the target');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestData
|
||||
*/
|
||||
public function testTest($operator, $target, $match, $noMatch)
|
||||
{
|
||||
$c = new Comparator();
|
||||
$c->setOperator($operator);
|
||||
$c->setTarget($target);
|
||||
|
||||
foreach ($match as $m) {
|
||||
$this->assertTrue($c->test($m), '->test() tests a string against the expression');
|
||||
}
|
||||
|
||||
foreach ($noMatch as $m) {
|
||||
$this->assertFalse($c->test($m), '->test() tests a string against the expression');
|
||||
}
|
||||
}
|
||||
|
||||
public function getTestData()
|
||||
{
|
||||
return array(
|
||||
array('<', '1000', array('500', '999'), array('1000', '1500')),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Finder\Comparator\DateComparator;
|
||||
|
||||
class DateComparatorTest extends TestCase
|
||||
{
|
||||
public function testConstructor()
|
||||
{
|
||||
try {
|
||||
new DateComparator('foobar');
|
||||
$this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
||||
}
|
||||
|
||||
try {
|
||||
new DateComparator('');
|
||||
$this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestData
|
||||
*/
|
||||
public function testTest($test, $match, $noMatch)
|
||||
{
|
||||
$c = new DateComparator($test);
|
||||
|
||||
foreach ($match as $m) {
|
||||
$this->assertTrue($c->test($m), '->test() tests a string against the expression');
|
||||
}
|
||||
|
||||
foreach ($noMatch as $m) {
|
||||
$this->assertFalse($c->test($m), '->test() tests a string against the expression');
|
||||
}
|
||||
}
|
||||
|
||||
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'))),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,108 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Comparator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Finder\Comparator\NumberComparator;
|
||||
|
||||
class NumberComparatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getConstructorTestData
|
||||
*/
|
||||
public function testConstructor($successes, $failures)
|
||||
{
|
||||
foreach ($successes as $s) {
|
||||
new NumberComparator($s);
|
||||
}
|
||||
|
||||
foreach ($failures as $f) {
|
||||
try {
|
||||
new NumberComparator($f);
|
||||
$this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestData
|
||||
*/
|
||||
public function testTest($test, $match, $noMatch)
|
||||
{
|
||||
$c = new NumberComparator($test);
|
||||
|
||||
foreach ($match as $m) {
|
||||
$this->assertTrue($c->test($m), '->test() tests a string against the expression');
|
||||
}
|
||||
|
||||
foreach ($noMatch as $m) {
|
||||
$this->assertFalse($c->test($m), '->test() tests a string against the expression');
|
||||
}
|
||||
}
|
||||
|
||||
public function getTestData()
|
||||
{
|
||||
return array(
|
||||
array('< 1000', array('500', '999'), array('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')),
|
||||
|
||||
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')),
|
||||
|
||||
array('1KI', array('1024'), array('1023', '1025')),
|
||||
array('==1KI', array('1024'), array('1023', '1025')),
|
||||
|
||||
array('==1m', array('1000000'), array('999999', '1000001')),
|
||||
array('==1mi', array(1024 * 1024), array(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)),
|
||||
|
||||
array('!= 1000', array('500', '999'), array('1000')),
|
||||
);
|
||||
}
|
||||
|
||||
public function getConstructorTestData()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'1', '0',
|
||||
'3.5', '33.55', '123.456', '123456.78',
|
||||
'.1', '.123',
|
||||
'.0', '0.0',
|
||||
'1.', '0.', '123.',
|
||||
'==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',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
1280
vendor/symfony/finder/Tests/FinderTest.php
vendored
1280
vendor/symfony/finder/Tests/FinderTest.php
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
dolor sit amet
|
||||
DOLOR SIT AMET
|
@@ -1,2 +0,0 @@
|
||||
ipsum dolor sit amet
|
||||
IPSUM DOLOR SIT AMET
|
@@ -1,2 +0,0 @@
|
||||
lorem ipsum dolor sit amet
|
||||
LOREM IPSUM DOLOR SIT AMET
|
@@ -1 +0,0 @@
|
||||
.dot
|
95
vendor/symfony/finder/Tests/GlobTest.php
vendored
95
vendor/symfony/finder/Tests/GlobTest.php
vendored
@@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\Finder\Glob;
|
||||
|
||||
class GlobTest extends TestCase
|
||||
{
|
||||
public function testGlobToRegexDelimiters()
|
||||
{
|
||||
$this->assertEquals('#^(?=[^\.])\#$#', Glob::toRegex('#'));
|
||||
$this->assertEquals('#^\.[^/]*$#', Glob::toRegex('.*'));
|
||||
$this->assertEquals('^\.[^/]*$', Glob::toRegex('.*', true, true, ''));
|
||||
$this->assertEquals('/^\.[^/]*$/', Glob::toRegex('.*', true, true, '/'));
|
||||
}
|
||||
|
||||
public function testGlobToRegexDoubleStarStrictDots()
|
||||
{
|
||||
$finder = new Finder();
|
||||
$finder->ignoreDotFiles(false);
|
||||
$regex = Glob::toRegex('/**/*.neon');
|
||||
|
||||
foreach ($finder->in(__DIR__) as $k => $v) {
|
||||
$k = str_replace(\DIRECTORY_SEPARATOR, '/', $k);
|
||||
if (preg_match($regex, substr($k, \strlen(__DIR__)))) {
|
||||
$match[] = substr($k, 10 + \strlen(__DIR__));
|
||||
}
|
||||
}
|
||||
sort($match);
|
||||
|
||||
$this->assertSame(array('one/b/c.neon', 'one/b/d.neon'), $match);
|
||||
}
|
||||
|
||||
public function testGlobToRegexDoubleStarNonStrictDots()
|
||||
{
|
||||
$finder = new Finder();
|
||||
$finder->ignoreDotFiles(false);
|
||||
$regex = Glob::toRegex('/**/*.neon', false);
|
||||
|
||||
foreach ($finder->in(__DIR__) as $k => $v) {
|
||||
$k = str_replace(\DIRECTORY_SEPARATOR, '/', $k);
|
||||
if (preg_match($regex, substr($k, \strlen(__DIR__)))) {
|
||||
$match[] = substr($k, 10 + \strlen(__DIR__));
|
||||
}
|
||||
}
|
||||
sort($match);
|
||||
|
||||
$this->assertSame(array('.dot/b/c.neon', '.dot/b/d.neon', 'one/b/c.neon', 'one/b/d.neon'), $match);
|
||||
}
|
||||
|
||||
public function testGlobToRegexDoubleStarWithoutLeadingSlash()
|
||||
{
|
||||
$finder = new Finder();
|
||||
$finder->ignoreDotFiles(false);
|
||||
$regex = Glob::toRegex('/Fixtures/one/**');
|
||||
|
||||
foreach ($finder->in(__DIR__) as $k => $v) {
|
||||
$k = str_replace(\DIRECTORY_SEPARATOR, '/', $k);
|
||||
if (preg_match($regex, substr($k, \strlen(__DIR__)))) {
|
||||
$match[] = substr($k, 10 + \strlen(__DIR__));
|
||||
}
|
||||
}
|
||||
sort($match);
|
||||
|
||||
$this->assertSame(array('one/a', 'one/b', 'one/b/c.neon', 'one/b/d.neon'), $match);
|
||||
}
|
||||
|
||||
public function testGlobToRegexDoubleStarWithoutLeadingSlashNotStrictLeadingDot()
|
||||
{
|
||||
$finder = new Finder();
|
||||
$finder->ignoreDotFiles(false);
|
||||
$regex = Glob::toRegex('/Fixtures/one/**', false);
|
||||
|
||||
foreach ($finder->in(__DIR__) as $k => $v) {
|
||||
$k = str_replace(\DIRECTORY_SEPARATOR, '/', $k);
|
||||
if (preg_match($regex, substr($k, \strlen(__DIR__)))) {
|
||||
$match[] = substr($k, 10 + \strlen(__DIR__));
|
||||
}
|
||||
}
|
||||
sort($match);
|
||||
|
||||
$this->assertSame(array('one/.dot', 'one/a', 'one/b', 'one/b/c.neon', 'one/b/d.neon'), $match);
|
||||
}
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use Symfony\Component\Finder\Iterator\CustomFilterIterator;
|
||||
|
||||
class CustomFilterIteratorTest extends IteratorTestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testWithInvalidFilter()
|
||||
{
|
||||
new CustomFilterIterator(new Iterator(), array('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getAcceptData
|
||||
*/
|
||||
public function testAccept($filters, $expected)
|
||||
{
|
||||
$inner = new Iterator(array('test.php', 'test.py', 'foo.php'));
|
||||
|
||||
$iterator = new CustomFilterIterator($inner, $filters);
|
||||
|
||||
$this->assertIterator($expected, $iterator);
|
||||
}
|
||||
|
||||
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()),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use Symfony\Component\Finder\Comparator\DateComparator;
|
||||
use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
|
||||
|
||||
class DateRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getAcceptData
|
||||
*/
|
||||
public function testAccept($size, $expected)
|
||||
{
|
||||
$files = self::$files;
|
||||
$files[] = self::toAbsolute('doesnotexist');
|
||||
$inner = new Iterator($files);
|
||||
|
||||
$iterator = new DateRangeFilterIterator($inner, $size);
|
||||
|
||||
$this->assertIterator($expected, $iterator);
|
||||
}
|
||||
|
||||
public function getAcceptData()
|
||||
{
|
||||
$since20YearsAgo = array(
|
||||
'.git',
|
||||
'test.py',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'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',
|
||||
);
|
||||
|
||||
$since2MonthsAgo = array(
|
||||
'.git',
|
||||
'test.py',
|
||||
'foo',
|
||||
'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',
|
||||
);
|
||||
|
||||
$untilLastMonth = array(
|
||||
'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)),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
|
||||
|
||||
class DepthRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getAcceptData
|
||||
*/
|
||||
public function testAccept($minDepth, $maxDepth, $expected)
|
||||
{
|
||||
$inner = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
$iterator = new DepthRangeFilterIterator($inner, $minDepth, $maxDepth);
|
||||
|
||||
$actual = array_keys(iterator_to_array($iterator));
|
||||
sort($expected);
|
||||
sort($actual);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
public function getAcceptData()
|
||||
{
|
||||
$lessThan1 = array(
|
||||
'.git',
|
||||
'test.py',
|
||||
'foo',
|
||||
'test.php',
|
||||
'toto',
|
||||
'.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(
|
||||
'.git',
|
||||
'test.py',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.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(
|
||||
'toto/.git',
|
||||
'foo/bar.tmp',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
);
|
||||
|
||||
$equalTo1 = array(
|
||||
'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)),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
|
||||
use Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator;
|
||||
|
||||
class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getAcceptData
|
||||
*/
|
||||
public function testAccept($directories, $expected)
|
||||
{
|
||||
$inner = new \RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
$iterator = new ExcludeDirectoryFilterIterator($inner, $directories);
|
||||
|
||||
$this->assertIterator($expected, $iterator);
|
||||
}
|
||||
|
||||
public function getAcceptData()
|
||||
{
|
||||
$foo = array(
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'.git',
|
||||
'test.py',
|
||||
'test.php',
|
||||
'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(
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'.git',
|
||||
'test.py',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'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(
|
||||
'.bar',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'.git',
|
||||
'test.py',
|
||||
'foo',
|
||||
'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(
|
||||
array(array('foo'), $this->toAbsolute($foo)),
|
||||
array(array('fo'), $this->toAbsolute($fo)),
|
||||
array(array('toto/'), $this->toAbsolute($toto)),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use Symfony\Component\Finder\Iterator\FileTypeFilterIterator;
|
||||
|
||||
class FileTypeFilterIteratorTest extends RealIteratorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getAcceptData
|
||||
*/
|
||||
public function testAccept($mode, $expected)
|
||||
{
|
||||
$inner = new InnerTypeIterator(self::$files);
|
||||
|
||||
$iterator = new FileTypeFilterIterator($inner, $mode);
|
||||
|
||||
$this->assertIterator($expected, $iterator);
|
||||
}
|
||||
|
||||
public function getAcceptData()
|
||||
{
|
||||
$onlyFiles = array(
|
||||
'test.py',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'.bar',
|
||||
'.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',
|
||||
);
|
||||
|
||||
return array(
|
||||
array(FileTypeFilterIterator::ONLY_FILES, $this->toAbsolute($onlyFiles)),
|
||||
array(FileTypeFilterIterator::ONLY_DIRECTORIES, $this->toAbsolute($onlyDirectories)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InnerTypeIterator extends \ArrayIterator
|
||||
{
|
||||
public function current()
|
||||
{
|
||||
return new \SplFileInfo(parent::current());
|
||||
}
|
||||
|
||||
public function isFile()
|
||||
{
|
||||
return $this->current()->isFile();
|
||||
}
|
||||
|
||||
public function isDir()
|
||||
{
|
||||
return $this->current()->isDir();
|
||||
}
|
||||
}
|
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public function testDirectory()
|
||||
{
|
||||
$inner = new MockFileListIterator(array('directory'));
|
||||
$iterator = new FilecontentFilterIterator($inner, array('directory'), array());
|
||||
$this->assertIterator(array(), $iterator);
|
||||
}
|
||||
|
||||
public function testUnreadableFile()
|
||||
{
|
||||
$inner = new MockFileListIterator(array('file r-'));
|
||||
$iterator = new FilecontentFilterIterator($inner, array('file r-'), array());
|
||||
$this->assertIterator(array(), $iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestFilterData
|
||||
*/
|
||||
public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatchPatterns, array $resultArray)
|
||||
{
|
||||
$iterator = new FilecontentFilterIterator($inner, $matchPatterns, $noMatchPatterns);
|
||||
$this->assertIterator($resultArray, $iterator);
|
||||
}
|
||||
|
||||
public function getTestFilterData()
|
||||
{
|
||||
$inner = new MockFileListIterator();
|
||||
|
||||
$inner[] = new MockSplFileInfo(array(
|
||||
'name' => 'a.txt',
|
||||
'contents' => 'Lorem ipsum...',
|
||||
'type' => 'file',
|
||||
'mode' => 'r+', )
|
||||
);
|
||||
|
||||
$inner[] = new MockSplFileInfo(array(
|
||||
'name' => 'b.yml',
|
||||
'contents' => 'dolor sit...',
|
||||
'type' => 'file',
|
||||
'mode' => 'r+', )
|
||||
);
|
||||
|
||||
$inner[] = new MockSplFileInfo(array(
|
||||
'name' => 'some/other/dir/third.php',
|
||||
'contents' => 'amet...',
|
||||
'type' => 'file',
|
||||
'mode' => 'r+', )
|
||||
);
|
||||
|
||||
$inner[] = new MockSplFileInfo(array(
|
||||
'name' => 'unreadable-file.txt',
|
||||
'contents' => false,
|
||||
'type' => 'file',
|
||||
'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')),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
|
||||
|
||||
class FilenameFilterIteratorTest extends IteratorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getAcceptData
|
||||
*/
|
||||
public function testAccept($matchPatterns, $noMatchPatterns, $expected)
|
||||
{
|
||||
$inner = new InnerNameIterator(array('test.php', 'test.py', 'foo.php'));
|
||||
|
||||
$iterator = new FilenameFilterIterator($inner, $matchPatterns, $noMatchPatterns);
|
||||
|
||||
$this->assertIterator($expected, $iterator);
|
||||
}
|
||||
|
||||
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')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InnerNameIterator extends \ArrayIterator
|
||||
{
|
||||
public function current()
|
||||
{
|
||||
return new \SplFileInfo(parent::current());
|
||||
}
|
||||
|
||||
public function getFilename()
|
||||
{
|
||||
return parent::current();
|
||||
}
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
class Iterator implements \Iterator
|
||||
{
|
||||
protected $values = array();
|
||||
|
||||
public function __construct(array $values = array())
|
||||
{
|
||||
foreach ($values as $value) {
|
||||
$this->attach(new \SplFileInfo($value));
|
||||
}
|
||||
$this->rewind();
|
||||
}
|
||||
|
||||
public function attach(\SplFileInfo $fileinfo)
|
||||
{
|
||||
$this->values[] = $fileinfo;
|
||||
}
|
||||
|
||||
public function rewind()
|
||||
{
|
||||
reset($this->values);
|
||||
}
|
||||
|
||||
public function valid()
|
||||
{
|
||||
return false !== $this->current();
|
||||
}
|
||||
|
||||
public function next()
|
||||
{
|
||||
next($this->values);
|
||||
}
|
||||
|
||||
public function current()
|
||||
{
|
||||
return current($this->values);
|
||||
}
|
||||
|
||||
public function key()
|
||||
{
|
||||
return key($this->values);
|
||||
}
|
||||
}
|
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class IteratorTestCase extends TestCase
|
||||
{
|
||||
protected function assertIterator($expected, \Traversable $iterator)
|
||||
{
|
||||
// set iterator_to_array $use_key to false to avoid values merge
|
||||
// this made FinderTest::testAppendWithAnArray() fail with GnuFinderAdapter
|
||||
$values = array_map(function (\SplFileInfo $fileinfo) { return str_replace('/', \DIRECTORY_SEPARATOR, $fileinfo->getPathname()); }, iterator_to_array($iterator, false));
|
||||
|
||||
$expected = array_map(function ($path) { return str_replace('/', \DIRECTORY_SEPARATOR, $path); }, $expected);
|
||||
|
||||
sort($values);
|
||||
sort($expected);
|
||||
|
||||
$this->assertEquals($expected, array_values($values));
|
||||
}
|
||||
|
||||
protected function assertOrderedIterator($expected, \Traversable $iterator)
|
||||
{
|
||||
$values = array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator));
|
||||
|
||||
$this->assertEquals($expected, array_values($values));
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as assertOrderedIterator, but checks the order of groups of
|
||||
* array elements.
|
||||
*
|
||||
* @param array $expected - an array of arrays. For any two subarrays
|
||||
* $a and $b such that $a goes before $b in $expected, the method
|
||||
* asserts that any element of $a goes before any element of $b
|
||||
* in the sequence generated by $iterator
|
||||
* @param \Traversable $iterator
|
||||
*/
|
||||
protected function assertOrderedIteratorForGroups($expected, \Traversable $iterator)
|
||||
{
|
||||
$values = array_values(array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator)));
|
||||
|
||||
foreach ($expected as $subarray) {
|
||||
$temp = array();
|
||||
while (\count($values) && \count($temp) < \count($subarray)) {
|
||||
$temp[] = array_shift($values);
|
||||
}
|
||||
sort($temp);
|
||||
sort($subarray);
|
||||
$this->assertEquals($subarray, $temp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as IteratorTestCase::assertIterator with foreach usage.
|
||||
*
|
||||
* @param array $expected
|
||||
* @param \Traversable $iterator
|
||||
*/
|
||||
protected function assertIteratorInForeach($expected, \Traversable $iterator)
|
||||
{
|
||||
$values = array();
|
||||
foreach ($iterator as $file) {
|
||||
$this->assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $file);
|
||||
$values[] = $file->getPathname();
|
||||
}
|
||||
|
||||
sort($values);
|
||||
sort($expected);
|
||||
|
||||
$this->assertEquals($expected, array_values($values));
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as IteratorTestCase::assertOrderedIterator with foreach usage.
|
||||
*
|
||||
* @param array $expected
|
||||
* @param \Traversable $iterator
|
||||
*/
|
||||
protected function assertOrderedIteratorInForeach($expected, \Traversable $iterator)
|
||||
{
|
||||
$values = array();
|
||||
foreach ($iterator as $file) {
|
||||
$this->assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $file);
|
||||
$values[] = $file->getPathname();
|
||||
}
|
||||
|
||||
$this->assertEquals($expected, array_values($values));
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
class MockFileListIterator extends \ArrayIterator
|
||||
{
|
||||
public function __construct(array $filesArray = array())
|
||||
{
|
||||
$files = array_map(function ($file) { return new MockSplFileInfo($file); }, $filesArray);
|
||||
parent::__construct($files);
|
||||
}
|
||||
}
|
@@ -1,132 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
class MockSplFileInfo extends \SplFileInfo
|
||||
{
|
||||
const TYPE_DIRECTORY = 1;
|
||||
const TYPE_FILE = 2;
|
||||
const TYPE_UNKNOWN = 3;
|
||||
|
||||
private $contents = null;
|
||||
private $mode = null;
|
||||
private $type = null;
|
||||
private $relativePath = null;
|
||||
private $relativePathname = null;
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
if (\is_string($param)) {
|
||||
parent::__construct($param);
|
||||
} elseif (\is_array($param)) {
|
||||
$defaults = array(
|
||||
'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']);
|
||||
$this->setMode($defaults['mode']);
|
||||
$this->setType($defaults['type']);
|
||||
$this->setRelativePath($defaults['relativePath']);
|
||||
$this->setRelativePathname($defaults['relativePathname']);
|
||||
} else {
|
||||
throw new \RuntimeException(sprintf('Incorrect parameter "%s"', $param));
|
||||
}
|
||||
}
|
||||
|
||||
public function isFile()
|
||||
{
|
||||
if (null === $this->type) {
|
||||
return false !== strpos($this->getFilename(), 'file');
|
||||
}
|
||||
|
||||
return self::TYPE_FILE === $this->type;
|
||||
}
|
||||
|
||||
public function isDir()
|
||||
{
|
||||
if (null === $this->type) {
|
||||
return false !== strpos($this->getFilename(), 'directory');
|
||||
}
|
||||
|
||||
return self::TYPE_DIRECTORY === $this->type;
|
||||
}
|
||||
|
||||
public function isReadable()
|
||||
{
|
||||
if (null === $this->mode) {
|
||||
return preg_match('/r\+/', $this->getFilename());
|
||||
}
|
||||
|
||||
return preg_match('/r\+/', $this->mode);
|
||||
}
|
||||
|
||||
public function getContents()
|
||||
{
|
||||
return $this->contents;
|
||||
}
|
||||
|
||||
public function setContents($contents)
|
||||
{
|
||||
$this->contents = $contents;
|
||||
}
|
||||
|
||||
public function setMode($mode)
|
||||
{
|
||||
$this->mode = $mode;
|
||||
}
|
||||
|
||||
public function setType($type)
|
||||
{
|
||||
if (\is_string($type)) {
|
||||
switch ($type) {
|
||||
case 'directory':
|
||||
case 'd':
|
||||
$this->type = self::TYPE_DIRECTORY;
|
||||
break;
|
||||
case 'file':
|
||||
case 'f':
|
||||
$this->type = self::TYPE_FILE;
|
||||
break;
|
||||
default:
|
||||
$this->type = self::TYPE_UNKNOWN;
|
||||
}
|
||||
} else {
|
||||
$this->type = $type;
|
||||
}
|
||||
}
|
||||
|
||||
public function setRelativePath($relativePath)
|
||||
{
|
||||
$this->relativePath = $relativePath;
|
||||
}
|
||||
|
||||
public function setRelativePathname($relativePathname)
|
||||
{
|
||||
$this->relativePathname = $relativePathname;
|
||||
}
|
||||
|
||||
public function getRelativePath()
|
||||
{
|
||||
return $this->relativePath;
|
||||
}
|
||||
|
||||
public function getRelativePathname()
|
||||
{
|
||||
return $this->relativePathname;
|
||||
}
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Finder\Iterator\MultiplePcreFilterIterator;
|
||||
|
||||
class MultiplePcreFilterIteratorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getIsRegexFixtures
|
||||
*/
|
||||
public function testIsRegex($string, $isRegex, $message)
|
||||
{
|
||||
$testIterator = new TestMultiplePcreFilterIterator();
|
||||
$this->assertEquals($isRegex, $testIterator->isRegex($string), $message);
|
||||
}
|
||||
|
||||
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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestMultiplePcreFilterIterator extends MultiplePcreFilterIterator
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function accept()
|
||||
{
|
||||
throw new \BadFunctionCallException('Not implemented');
|
||||
}
|
||||
|
||||
public function isRegex($str)
|
||||
{
|
||||
return parent::isRegex($str);
|
||||
}
|
||||
|
||||
public function toRegex($str)
|
||||
{
|
||||
throw new \BadFunctionCallException('Not implemented');
|
||||
}
|
||||
}
|
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use Symfony\Component\Finder\Iterator\PathFilterIterator;
|
||||
|
||||
class PathFilterIteratorTest extends IteratorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getTestFilterData
|
||||
*/
|
||||
public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatchPatterns, array $resultArray)
|
||||
{
|
||||
$iterator = new PathFilterIterator($inner, $matchPatterns, $noMatchPatterns);
|
||||
$this->assertIterator($resultArray, $iterator);
|
||||
}
|
||||
|
||||
public function getTestFilterData()
|
||||
{
|
||||
$inner = new MockFileListIterator();
|
||||
|
||||
//PATH: A/B/C/abc.dat
|
||||
$inner[] = new MockSplFileInfo(array(
|
||||
'name' => 'abc.dat',
|
||||
'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C'.\DIRECTORY_SEPARATOR.'abc.dat',
|
||||
));
|
||||
|
||||
//PATH: A/B/ab.dat
|
||||
$inner[] = new MockSplFileInfo(array(
|
||||
'name' => 'ab.dat',
|
||||
'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat',
|
||||
));
|
||||
|
||||
//PATH: A/a.dat
|
||||
$inner[] = new MockSplFileInfo(array(
|
||||
'name' => 'a.dat',
|
||||
'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'a.dat',
|
||||
));
|
||||
|
||||
//PATH: copy/A/B/C/abc.dat.copy
|
||||
$inner[] = new MockSplFileInfo(array(
|
||||
'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(
|
||||
'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(
|
||||
'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')),
|
||||
|
||||
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')),
|
||||
|
||||
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')),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,128 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
abstract class RealIteratorTestCase extends IteratorTestCase
|
||||
{
|
||||
protected static $tmpDir;
|
||||
protected static $files;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$tmpDir = realpath(sys_get_temp_dir()).\DIRECTORY_SEPARATOR.'symfony_finder';
|
||||
|
||||
self::$files = array(
|
||||
'.git/',
|
||||
'.foo/',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'.bar',
|
||||
'test.py',
|
||||
'foo/',
|
||||
'foo/bar.tmp',
|
||||
'test.php',
|
||||
'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);
|
||||
|
||||
if (is_dir(self::$tmpDir)) {
|
||||
self::tearDownAfterClass();
|
||||
} else {
|
||||
mkdir(self::$tmpDir);
|
||||
}
|
||||
|
||||
foreach (self::$files as $file) {
|
||||
if (\DIRECTORY_SEPARATOR === $file[\strlen($file) - 1]) {
|
||||
mkdir($file);
|
||||
} else {
|
||||
touch($file);
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents(self::toAbsolute('test.php'), str_repeat(' ', 800));
|
||||
file_put_contents(self::toAbsolute('test.py'), str_repeat(' ', 2000));
|
||||
|
||||
touch(self::toAbsolute('foo/bar.tmp'), strtotime('2005-10-15'));
|
||||
touch(self::toAbsolute('test.php'), strtotime('2005-10-15'));
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$paths = new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator(self::$tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS),
|
||||
\RecursiveIteratorIterator::CHILD_FIRST
|
||||
);
|
||||
|
||||
foreach ($paths as $path) {
|
||||
if ($path->isDir()) {
|
||||
if ($path->isLink()) {
|
||||
@unlink($path);
|
||||
} else {
|
||||
@rmdir($path);
|
||||
}
|
||||
} else {
|
||||
@unlink($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function toAbsolute($files = null)
|
||||
{
|
||||
/*
|
||||
* Without the call to setUpBeforeClass() property can be null.
|
||||
*/
|
||||
if (!self::$tmpDir) {
|
||||
self::$tmpDir = realpath(sys_get_temp_dir()).\DIRECTORY_SEPARATOR.'symfony_finder';
|
||||
}
|
||||
|
||||
if (\is_array($files)) {
|
||||
$f = array();
|
||||
foreach ($files as $file) {
|
||||
if (\is_array($file)) {
|
||||
$f[] = self::toAbsolute($file);
|
||||
} else {
|
||||
$f[] = self::$tmpDir.\DIRECTORY_SEPARATOR.str_replace('/', \DIRECTORY_SEPARATOR, $file);
|
||||
}
|
||||
}
|
||||
|
||||
return $f;
|
||||
}
|
||||
|
||||
if (\is_string($files)) {
|
||||
return self::$tmpDir.\DIRECTORY_SEPARATOR.str_replace('/', \DIRECTORY_SEPARATOR, $files);
|
||||
}
|
||||
|
||||
return self::$tmpDir;
|
||||
}
|
||||
|
||||
protected static function toAbsoluteFixtures($files)
|
||||
{
|
||||
$f = array();
|
||||
foreach ($files as $file) {
|
||||
$f[] = realpath(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.$file);
|
||||
}
|
||||
|
||||
return $f;
|
||||
}
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator;
|
||||
|
||||
class RecursiveDirectoryIteratorTest extends IteratorTestCase
|
||||
{
|
||||
/**
|
||||
* @group network
|
||||
*/
|
||||
public function testRewindOnFtp()
|
||||
{
|
||||
try {
|
||||
$i = new RecursiveDirectoryIterator('ftp://speedtest.tele2.net/', \RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
$this->markTestSkipped('Unsupported stream "ftp".');
|
||||
}
|
||||
|
||||
$i->rewind();
|
||||
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group network
|
||||
*/
|
||||
public function testSeekOnFtp()
|
||||
{
|
||||
try {
|
||||
$i = new RecursiveDirectoryIterator('ftp://speedtest.tele2.net/', \RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
$this->markTestSkipped('Unsupported stream "ftp".');
|
||||
}
|
||||
|
||||
$contains = array(
|
||||
'ftp://speedtest.tele2.net'.\DIRECTORY_SEPARATOR.'1000GB.zip',
|
||||
'ftp://speedtest.tele2.net'.\DIRECTORY_SEPARATOR.'100GB.zip',
|
||||
);
|
||||
$actual = array();
|
||||
|
||||
$i->seek(0);
|
||||
$actual[] = $i->getPathname();
|
||||
|
||||
$i->seek(1);
|
||||
$actual[] = $i->getPathname();
|
||||
|
||||
$this->assertEquals($contains, $actual);
|
||||
}
|
||||
}
|
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use Symfony\Component\Finder\Comparator\NumberComparator;
|
||||
use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
|
||||
|
||||
class SizeRangeFilterIteratorTest extends RealIteratorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getAcceptData
|
||||
*/
|
||||
public function testAccept($size, $expected)
|
||||
{
|
||||
$inner = new InnerSizeIterator(self::$files);
|
||||
|
||||
$iterator = new SizeRangeFilterIterator($inner, $size);
|
||||
|
||||
$this->assertIterator($expected, $iterator);
|
||||
}
|
||||
|
||||
public function getAcceptData()
|
||||
{
|
||||
$lessThan1KGreaterThan05K = array(
|
||||
'.foo',
|
||||
'.git',
|
||||
'foo',
|
||||
'qux',
|
||||
'test.php',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
);
|
||||
|
||||
return array(
|
||||
array(array(new NumberComparator('< 1K'), new NumberComparator('> 0.5K')), $this->toAbsolute($lessThan1KGreaterThan05K)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InnerSizeIterator extends \ArrayIterator
|
||||
{
|
||||
public function current()
|
||||
{
|
||||
return new \SplFileInfo(parent::current());
|
||||
}
|
||||
|
||||
public function getFilename()
|
||||
{
|
||||
return parent::current();
|
||||
}
|
||||
|
||||
public function isFile()
|
||||
{
|
||||
return $this->current()->isFile();
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
return $this->current()->getSize();
|
||||
}
|
||||
}
|
@@ -1,262 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
||||
|
||||
use Symfony\Component\Finder\Iterator\SortableIterator;
|
||||
|
||||
class SortableIteratorTest extends RealIteratorTestCase
|
||||
{
|
||||
public function testConstructor()
|
||||
{
|
||||
try {
|
||||
new SortableIterator(new Iterator(array()), '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');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getAcceptData
|
||||
*/
|
||||
public function testAccept($mode, $expected)
|
||||
{
|
||||
if (!\is_callable($mode)) {
|
||||
switch ($mode) {
|
||||
case SortableIterator::SORT_BY_ACCESSED_TIME:
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
touch(self::toAbsolute('.git'));
|
||||
} else {
|
||||
file_get_contents(self::toAbsolute('.git'));
|
||||
}
|
||||
sleep(1);
|
||||
file_get_contents(self::toAbsolute('.bar'));
|
||||
break;
|
||||
case SortableIterator::SORT_BY_CHANGED_TIME:
|
||||
file_put_contents(self::toAbsolute('test.php'), 'foo');
|
||||
sleep(1);
|
||||
file_put_contents(self::toAbsolute('test.py'), 'foo');
|
||||
break;
|
||||
case SortableIterator::SORT_BY_MODIFIED_TIME:
|
||||
file_put_contents(self::toAbsolute('test.php'), 'foo');
|
||||
sleep(1);
|
||||
file_put_contents(self::toAbsolute('test.py'), 'foo');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$inner = new Iterator(self::$files);
|
||||
|
||||
$iterator = new SortableIterator($inner, $mode);
|
||||
|
||||
if (SortableIterator::SORT_BY_ACCESSED_TIME === $mode
|
||||
|| SortableIterator::SORT_BY_CHANGED_TIME === $mode
|
||||
|| SortableIterator::SORT_BY_MODIFIED_TIME === $mode
|
||||
) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && SortableIterator::SORT_BY_MODIFIED_TIME !== $mode) {
|
||||
$this->markTestSkipped('Sorting by atime or ctime is not supported on Windows');
|
||||
}
|
||||
$this->assertOrderedIteratorForGroups($expected, $iterator);
|
||||
} else {
|
||||
$this->assertOrderedIterator($expected, $iterator);
|
||||
}
|
||||
}
|
||||
|
||||
public function getAcceptData()
|
||||
{
|
||||
$sortByName = 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',
|
||||
);
|
||||
|
||||
$sortByType = array(
|
||||
'.foo',
|
||||
'.git',
|
||||
'foo',
|
||||
'qux',
|
||||
'toto',
|
||||
'toto/.git',
|
||||
'.bar',
|
||||
'.foo/.bar',
|
||||
'.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',
|
||||
);
|
||||
|
||||
$sortByAccessedTime = array(
|
||||
// For these two files the access time was set to 2005-10-15
|
||||
array('foo/bar.tmp', 'test.php'),
|
||||
// These files were created more or less at the same time
|
||||
array(
|
||||
'.git',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'test.py',
|
||||
'foo',
|
||||
'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'),
|
||||
);
|
||||
|
||||
$sortByChangedTime = array(
|
||||
array(
|
||||
'.git',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'.bar',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'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'),
|
||||
);
|
||||
|
||||
$sortByModifiedTime = array(
|
||||
array(
|
||||
'.git',
|
||||
'.foo',
|
||||
'.foo/.bar',
|
||||
'.foo/bar',
|
||||
'.bar',
|
||||
'foo',
|
||||
'foo/bar.tmp',
|
||||
'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)),
|
||||
);
|
||||
}
|
||||
}
|
12
vendor/symfony/finder/composer.json
vendored
12
vendor/symfony/finder/composer.json
vendored
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
"type": "library",
|
||||
"description": "Symfony Finder Component",
|
||||
"description": "Finds files and directories via an intuitive fluent interface",
|
||||
"keywords": [],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
@@ -16,7 +16,8 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3"
|
||||
"php": ">=7.1.3",
|
||||
"symfony/polyfill-php80": "^1.16"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\Finder\\": "" },
|
||||
@@ -24,10 +25,5 @@
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
}
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
|
30
vendor/symfony/finder/phpunit.xml.dist
vendored
30
vendor/symfony/finder/phpunit.xml.dist
vendored
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
failOnRisky="true"
|
||||
failOnWarning="true"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Symfony Finder Component Test Suite">
|
||||
<directory>./Tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
Reference in New Issue
Block a user