Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
87
vendor/symfony/finder/CHANGELOG.md
vendored
Normal file
87
vendor/symfony/finder/CHANGELOG.md
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
5.4.0
|
||||
-----
|
||||
|
||||
* Deprecate `Comparator::setTarget()` and `Comparator::setOperator()`
|
||||
* Add a constructor to `Comparator` that allows setting target and operator
|
||||
* Finder's iterator has now `Symfony\Component\Finder\SplFileInfo` inner type specified
|
||||
* Add recursive .gitignore files support
|
||||
|
||||
5.0.0
|
||||
-----
|
||||
|
||||
* added `$useNaturalSort` argument to `Finder::sortByName()`
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
* added Finder::ignoreVCSIgnored() to ignore files based on rules listed in .gitignore
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
* added $useNaturalSort option to Finder::sortByName() method
|
||||
* the `Finder::sortByName()` method will have a new `$useNaturalSort`
|
||||
argument in version 5.0, not defining it is deprecated
|
||||
* added `Finder::reverseSorting()` to reverse the sorting
|
||||
|
||||
4.0.0
|
||||
-----
|
||||
|
||||
* removed `ExceptionInterface`
|
||||
* removed `Symfony\Component\Finder\Iterator\FilterIterator`
|
||||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
* deprecated `Symfony\Component\Finder\Iterator\FilterIterator`
|
||||
* added Finder::hasResults() method to check if any results were found
|
||||
|
||||
3.3.0
|
||||
-----
|
||||
|
||||
* added double-star matching to Glob::toRegex()
|
||||
|
||||
3.0.0
|
||||
-----
|
||||
|
||||
* removed deprecated classes
|
||||
|
||||
2.8.0
|
||||
-----
|
||||
|
||||
* deprecated adapters and related classes
|
||||
|
||||
2.5.0
|
||||
-----
|
||||
* added support for GLOB_BRACE in the paths passed to Finder::in()
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
|
||||
* added a way to ignore unreadable directories (via Finder::ignoreUnreadableDirs())
|
||||
* unified the way subfolders that are not executable are handled by always throwing an AccessDeniedException exception
|
||||
|
||||
2.2.0
|
||||
-----
|
||||
|
||||
* added Finder::path() and Finder::notPath() methods
|
||||
* added finder adapters to improve performance on specific platforms
|
||||
* added support for wildcard characters (glob patterns) in the paths passed
|
||||
to Finder::in()
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
* added Finder::sortByAccessedTime(), Finder::sortByChangedTime(), and
|
||||
Finder::sortByModifiedTime()
|
||||
* added Countable to Finder
|
||||
* added support for an array of directories as an argument to
|
||||
Finder::exclude()
|
||||
* added searching based on the file content via Finder::contains() and
|
||||
Finder::notContains()
|
||||
* added support for the != operator in the Comparator
|
||||
* [BC BREAK] filter expressions (used for file name and content) are no more
|
||||
considered as regexps but glob patterns when they are enclosed in '*' or '?'
|
117
vendor/symfony/finder/Comparator/Comparator.php
vendored
Normal file
117
vendor/symfony/finder/Comparator/Comparator.php
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
<?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\Comparator;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Comparator
|
||||
{
|
||||
private $target;
|
||||
private $operator = '==';
|
||||
|
||||
public function __construct(?string $target = null, string $operator = '==')
|
||||
{
|
||||
if (null === $target) {
|
||||
trigger_deprecation('symfony/finder', '5.4', 'Constructing a "%s" without setting "$target" is deprecated.', __CLASS__);
|
||||
}
|
||||
|
||||
$this->target = $target;
|
||||
$this->doSetOperator($operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the target value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTarget()
|
||||
{
|
||||
if (null === $this->target) {
|
||||
trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
|
||||
}
|
||||
|
||||
return $this->target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated set the target via the constructor instead
|
||||
*/
|
||||
public function setTarget(string $target)
|
||||
{
|
||||
trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the target via the constructor instead.', __METHOD__);
|
||||
|
||||
$this->target = $target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the comparison operator.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOperator()
|
||||
{
|
||||
return $this->operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the comparison operator.
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @deprecated set the operator via the constructor instead
|
||||
*/
|
||||
public function setOperator(string $operator)
|
||||
{
|
||||
trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the operator via the constructor instead.', __METHOD__);
|
||||
|
||||
$this->doSetOperator('' === $operator ? '==' : $operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests against the target.
|
||||
*
|
||||
* @param mixed $test A test value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function test($test)
|
||||
{
|
||||
if (null === $this->target) {
|
||||
trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
|
||||
}
|
||||
|
||||
switch ($this->operator) {
|
||||
case '>':
|
||||
return $test > $this->target;
|
||||
case '>=':
|
||||
return $test >= $this->target;
|
||||
case '<':
|
||||
return $test < $this->target;
|
||||
case '<=':
|
||||
return $test <= $this->target;
|
||||
case '!=':
|
||||
return $test != $this->target;
|
||||
}
|
||||
|
||||
return $test == $this->target;
|
||||
}
|
||||
|
||||
private function doSetOperator(string $operator): void
|
||||
{
|
||||
if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
|
||||
}
|
||||
|
||||
$this->operator = $operator;
|
||||
}
|
||||
}
|
50
vendor/symfony/finder/Comparator/DateComparator.php
vendored
Normal file
50
vendor/symfony/finder/Comparator/DateComparator.php
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?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\Comparator;
|
||||
|
||||
/**
|
||||
* DateCompare compiles date comparisons.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class DateComparator extends Comparator
|
||||
{
|
||||
/**
|
||||
* @param string $test A comparison string
|
||||
*
|
||||
* @throws \InvalidArgumentException If the test is not understood
|
||||
*/
|
||||
public function __construct(string $test)
|
||||
{
|
||||
if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
|
||||
throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
|
||||
}
|
||||
|
||||
try {
|
||||
$date = new \DateTime($matches[2]);
|
||||
$target = $date->format('U');
|
||||
} catch (\Exception $e) {
|
||||
throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
|
||||
}
|
||||
|
||||
$operator = $matches[1] ?? '==';
|
||||
if ('since' === $operator || 'after' === $operator) {
|
||||
$operator = '>';
|
||||
}
|
||||
|
||||
if ('until' === $operator || 'before' === $operator) {
|
||||
$operator = '<';
|
||||
}
|
||||
|
||||
parent::__construct($target, $operator);
|
||||
}
|
||||
}
|
78
vendor/symfony/finder/Comparator/NumberComparator.php
vendored
Normal file
78
vendor/symfony/finder/Comparator/NumberComparator.php
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?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\Comparator;
|
||||
|
||||
/**
|
||||
* NumberComparator compiles a simple comparison to an anonymous
|
||||
* subroutine, which you can call with a value to be tested again.
|
||||
*
|
||||
* Now this would be very pointless, if NumberCompare didn't understand
|
||||
* magnitudes.
|
||||
*
|
||||
* The target value may use magnitudes of kilobytes (k, ki),
|
||||
* megabytes (m, mi), or gigabytes (g, gi). Those suffixed
|
||||
* with an i use the appropriate 2**n version in accordance with the
|
||||
* IEC standard: http://physics.nist.gov/cuu/Units/binary.html
|
||||
*
|
||||
* Based on the Perl Number::Compare module.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com> PHP port
|
||||
* @author Richard Clamp <richardc@unixbeard.net> Perl version
|
||||
* @copyright 2004-2005 Fabien Potencier <fabien@symfony.com>
|
||||
* @copyright 2002 Richard Clamp <richardc@unixbeard.net>
|
||||
*
|
||||
* @see http://physics.nist.gov/cuu/Units/binary.html
|
||||
*/
|
||||
class NumberComparator extends Comparator
|
||||
{
|
||||
/**
|
||||
* @param string|null $test A comparison string or null
|
||||
*
|
||||
* @throws \InvalidArgumentException If the test is not understood
|
||||
*/
|
||||
public function __construct(?string $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];
|
||||
if (!is_numeric($target)) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
|
||||
}
|
||||
if (isset($matches[3])) {
|
||||
// magnitude
|
||||
switch (strtolower($matches[3])) {
|
||||
case 'k':
|
||||
$target *= 1000;
|
||||
break;
|
||||
case 'ki':
|
||||
$target *= 1024;
|
||||
break;
|
||||
case 'm':
|
||||
$target *= 1000000;
|
||||
break;
|
||||
case 'mi':
|
||||
$target *= 1024 * 1024;
|
||||
break;
|
||||
case 'g':
|
||||
$target *= 1000000000;
|
||||
break;
|
||||
case 'gi':
|
||||
$target *= 1024 * 1024 * 1024;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($target, $matches[1] ?: '==');
|
||||
}
|
||||
}
|
19
vendor/symfony/finder/Exception/AccessDeniedException.php
vendored
Normal file
19
vendor/symfony/finder/Exception/AccessDeniedException.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 Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*/
|
||||
class AccessDeniedException extends \UnexpectedValueException
|
||||
{
|
||||
}
|
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
|
||||
{
|
||||
}
|
806
vendor/symfony/finder/Finder.php
vendored
Normal file
806
vendor/symfony/finder/Finder.php
vendored
Normal file
|
@ -0,0 +1,806 @@
|
|||
<?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;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Finder allows to build rules to find files and directories.
|
||||
*
|
||||
* It is a thin wrapper around several specialized iterator classes.
|
||||
*
|
||||
* All rules may be invoked several times.
|
||||
*
|
||||
* All methods return the current Finder object to allow chaining:
|
||||
*
|
||||
* $finder = Finder::create()->files()->name('*.php')->in(__DIR__);
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @implements \IteratorAggregate<string, SplFileInfo>
|
||||
*/
|
||||
class Finder implements \IteratorAggregate, \Countable
|
||||
{
|
||||
public const IGNORE_VCS_FILES = 1;
|
||||
public const IGNORE_DOT_FILES = 2;
|
||||
public const IGNORE_VCS_IGNORED_FILES = 4;
|
||||
|
||||
private $mode = 0;
|
||||
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 = [];
|
||||
private $dates = [];
|
||||
private $iterators = [];
|
||||
private $contains = [];
|
||||
private $notContains = [];
|
||||
private $paths = [];
|
||||
private $notPaths = [];
|
||||
private $ignoreUnreadableDirs = false;
|
||||
|
||||
private static $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Finder.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
return new static();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts the matching to directories only.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function directories()
|
||||
{
|
||||
$this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts the matching to files only.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function files()
|
||||
{
|
||||
$this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds tests for the directory depth.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* $finder->depth('> 1') // the Finder will start matching at level 1.
|
||||
* $finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point.
|
||||
* $finder->depth(['>= 1', '< 3'])
|
||||
*
|
||||
* @param string|int|string[]|int[] $levels The depth level expression or an array of depth levels
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see DepthRangeFilterIterator
|
||||
* @see NumberComparator
|
||||
*/
|
||||
public function depth($levels)
|
||||
{
|
||||
foreach ((array) $levels as $level) {
|
||||
$this->depths[] = new Comparator\NumberComparator($level);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds tests for file dates (last modified).
|
||||
*
|
||||
* The date must be something that strtotime() is able to parse:
|
||||
*
|
||||
* $finder->date('since yesterday');
|
||||
* $finder->date('until 2 days ago');
|
||||
* $finder->date('> now - 2 hours');
|
||||
* $finder->date('>= 2005-10-15');
|
||||
* $finder->date(['>= 2005-10-15', '<= 2006-05-27']);
|
||||
*
|
||||
* @param string|string[] $dates A date range string or an array of date ranges
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see strtotime
|
||||
* @see DateRangeFilterIterator
|
||||
* @see DateComparator
|
||||
*/
|
||||
public function date($dates)
|
||||
{
|
||||
foreach ((array) $dates as $date) {
|
||||
$this->dates[] = new Comparator\DateComparator($date);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds rules that files must match.
|
||||
*
|
||||
* You can use patterns (delimited with / sign), globs or simple strings.
|
||||
*
|
||||
* $finder->name('/\.php$/')
|
||||
* $finder->name('*.php') // same as above, without dot files
|
||||
* $finder->name('test.php')
|
||||
* $finder->name(['test.py', 'test.php'])
|
||||
*
|
||||
* @param string|string[] $patterns A pattern (a regexp, a glob, or a string) or an array of patterns
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see FilenameFilterIterator
|
||||
*/
|
||||
public function name($patterns)
|
||||
{
|
||||
$this->names = array_merge($this->names, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds rules that files must not match.
|
||||
*
|
||||
* @param string|string[] $patterns A pattern (a regexp, a glob, or a string) or an array of patterns
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see FilenameFilterIterator
|
||||
*/
|
||||
public function notName($patterns)
|
||||
{
|
||||
$this->notNames = array_merge($this->notNames, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds tests that file contents must match.
|
||||
*
|
||||
* Strings or PCRE patterns can be used:
|
||||
*
|
||||
* $finder->contains('Lorem ipsum')
|
||||
* $finder->contains('/Lorem ipsum/i')
|
||||
* $finder->contains(['dolor', '/ipsum/i'])
|
||||
*
|
||||
* @param string|string[] $patterns A pattern (string or regexp) or an array of patterns
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see FilecontentFilterIterator
|
||||
*/
|
||||
public function contains($patterns)
|
||||
{
|
||||
$this->contains = array_merge($this->contains, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds tests that file contents must not match.
|
||||
*
|
||||
* Strings or PCRE patterns can be used:
|
||||
*
|
||||
* $finder->notContains('Lorem ipsum')
|
||||
* $finder->notContains('/Lorem ipsum/i')
|
||||
* $finder->notContains(['lorem', '/dolor/i'])
|
||||
*
|
||||
* @param string|string[] $patterns A pattern (string or regexp) or an array of patterns
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see FilecontentFilterIterator
|
||||
*/
|
||||
public function notContains($patterns)
|
||||
{
|
||||
$this->notContains = array_merge($this->notContains, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds rules that filenames must match.
|
||||
*
|
||||
* You can use patterns (delimited with / sign) or simple strings.
|
||||
*
|
||||
* $finder->path('some/special/dir')
|
||||
* $finder->path('/some\/special\/dir/') // same as above
|
||||
* $finder->path(['some dir', 'another/dir'])
|
||||
*
|
||||
* Use only / as dirname separator.
|
||||
*
|
||||
* @param string|string[] $patterns A pattern (a regexp or a string) or an array of patterns
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see FilenameFilterIterator
|
||||
*/
|
||||
public function path($patterns)
|
||||
{
|
||||
$this->paths = array_merge($this->paths, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds rules that filenames must not match.
|
||||
*
|
||||
* You can use patterns (delimited with / sign) or simple strings.
|
||||
*
|
||||
* $finder->notPath('some/special/dir')
|
||||
* $finder->notPath('/some\/special\/dir/') // same as above
|
||||
* $finder->notPath(['some/file.txt', 'another/file.log'])
|
||||
*
|
||||
* Use only / as dirname separator.
|
||||
*
|
||||
* @param string|string[] $patterns A pattern (a regexp or a string) or an array of patterns
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see FilenameFilterIterator
|
||||
*/
|
||||
public function notPath($patterns)
|
||||
{
|
||||
$this->notPaths = array_merge($this->notPaths, (array) $patterns);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds tests for file sizes.
|
||||
*
|
||||
* $finder->size('> 10K');
|
||||
* $finder->size('<= 1Ki');
|
||||
* $finder->size(4);
|
||||
* $finder->size(['> 10K', '< 20K'])
|
||||
*
|
||||
* @param string|int|string[]|int[] $sizes A size range string or an integer or an array of size ranges
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see SizeRangeFilterIterator
|
||||
* @see NumberComparator
|
||||
*/
|
||||
public function size($sizes)
|
||||
{
|
||||
foreach ((array) $sizes as $size) {
|
||||
$this->sizes[] = new Comparator\NumberComparator($size);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Excludes directories.
|
||||
*
|
||||
* Directories passed as argument must be relative to the ones defined with the `in()` method. For example:
|
||||
*
|
||||
* $finder->in(__DIR__)->exclude('ruby');
|
||||
*
|
||||
* @param string|array $dirs A directory path or an array of directories
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see ExcludeDirectoryFilterIterator
|
||||
*/
|
||||
public function exclude($dirs)
|
||||
{
|
||||
$this->exclude = array_merge($this->exclude, (array) $dirs);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Excludes "hidden" directories and files (starting with a dot).
|
||||
*
|
||||
* This option is enabled by default.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see ExcludeDirectoryFilterIterator
|
||||
*/
|
||||
public function ignoreDotFiles(bool $ignoreDotFiles)
|
||||
{
|
||||
if ($ignoreDotFiles) {
|
||||
$this->ignore |= static::IGNORE_DOT_FILES;
|
||||
} else {
|
||||
$this->ignore &= ~static::IGNORE_DOT_FILES;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the finder to ignore version control directories.
|
||||
*
|
||||
* This option is enabled by default.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see ExcludeDirectoryFilterIterator
|
||||
*/
|
||||
public function ignoreVCS(bool $ignoreVCS)
|
||||
{
|
||||
if ($ignoreVCS) {
|
||||
$this->ignore |= static::IGNORE_VCS_FILES;
|
||||
} else {
|
||||
$this->ignore &= ~static::IGNORE_VCS_FILES;
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* @see ignoreVCS()
|
||||
*
|
||||
* @param string|string[] $pattern VCS patterns to ignore
|
||||
*/
|
||||
public static function addVCSPattern($pattern)
|
||||
{
|
||||
foreach ((array) $pattern as $p) {
|
||||
self::$vcsPatterns[] = $p;
|
||||
}
|
||||
|
||||
self::$vcsPatterns = array_unique(self::$vcsPatterns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts files and directories by an anonymous function.
|
||||
*
|
||||
* The anonymous function receives two \SplFileInfo instances to compare.
|
||||
*
|
||||
* This can be slow as all the matching files and directories must be retrieved for comparison.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sort(\Closure $closure)
|
||||
{
|
||||
$this->sort = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts files and directories by name.
|
||||
*
|
||||
* This can be slow as all the matching files and directories must be retrieved for comparison.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sortByName(bool $useNaturalSort = false)
|
||||
{
|
||||
$this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL : Iterator\SortableIterator::SORT_BY_NAME;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts files and directories by type (directories before files), then by name.
|
||||
*
|
||||
* This can be slow as all the matching files and directories must be retrieved for comparison.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sortByType()
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts files and directories by the last accessed time.
|
||||
*
|
||||
* This is the time that the file was last accessed, read or written to.
|
||||
*
|
||||
* This can be slow as all the matching files and directories must be retrieved for comparison.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sortByAccessedTime()
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverses the sorting.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function reverseSorting()
|
||||
{
|
||||
$this->reverseSorting = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts files and directories by the last inode changed time.
|
||||
*
|
||||
* This is the time that the inode information was last modified (permissions, owner, group or other metadata).
|
||||
*
|
||||
* On Windows, since inode is not available, changed time is actually the file creation time.
|
||||
*
|
||||
* This can be slow as all the matching files and directories must be retrieved for comparison.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sortByChangedTime()
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts files and directories by the last modified time.
|
||||
*
|
||||
* This is the last time the actual contents of the file were last modified.
|
||||
*
|
||||
* This can be slow as all the matching files and directories must be retrieved for comparison.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sortByModifiedTime()
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the iterator with an anonymous function.
|
||||
*
|
||||
* The anonymous function receives a \SplFileInfo and must return false
|
||||
* to remove files.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see CustomFilterIterator
|
||||
*/
|
||||
public function filter(\Closure $closure)
|
||||
{
|
||||
$this->filters[] = $closure;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the following of symlinks.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function followLinks()
|
||||
{
|
||||
$this->followLinks = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells finder to ignore unreadable directories.
|
||||
*
|
||||
* By default, scanning unreadable directories content throws an AccessDeniedException.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ignoreUnreadableDirs(bool $ignore = true)
|
||||
{
|
||||
$this->ignoreUnreadableDirs = $ignore;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches files and directories which match defined rules.
|
||||
*
|
||||
* @param string|string[] $dirs A directory path or an array of directories
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws DirectoryNotFoundException if one of the directories does not exist
|
||||
*/
|
||||
public function in($dirs)
|
||||
{
|
||||
$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 | \GLOB_NOSORT)) {
|
||||
sort($glob);
|
||||
$resolvedDirs[] = array_map([$this, 'normalizeDir'], $glob);
|
||||
} else {
|
||||
throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
|
||||
}
|
||||
}
|
||||
|
||||
$this->dirs = array_merge($this->dirs, ...$resolvedDirs);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Iterator for the current Finder configuration.
|
||||
*
|
||||
* This method implements the IteratorAggregate interface.
|
||||
*
|
||||
* @return \Iterator<string, SplFileInfo>
|
||||
*
|
||||
* @throws \LogicException if the in() method has not been called
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
{
|
||||
if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
|
||||
throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
|
||||
}
|
||||
|
||||
if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
|
||||
$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(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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an existing set of files/directories to the finder.
|
||||
*
|
||||
* The set can be another Finder, an Iterator, an IteratorAggregate, or even a plain array.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException when the given argument is not iterable
|
||||
*/
|
||||
public function append(iterable $iterator)
|
||||
{
|
||||
if ($iterator instanceof \IteratorAggregate) {
|
||||
$this->iterators[] = $iterator->getIterator();
|
||||
} elseif ($iterator instanceof \Iterator) {
|
||||
$this->iterators[] = $iterator;
|
||||
} elseif (is_iterable($iterator)) {
|
||||
$it = new \ArrayIterator();
|
||||
foreach ($iterator as $file) {
|
||||
$file = $file instanceof \SplFileInfo ? $file : new \SplFileInfo($file);
|
||||
$it[$file->getPathname()] = $file;
|
||||
}
|
||||
$this->iterators[] = $it;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any results were found.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasResults()
|
||||
{
|
||||
foreach ($this->getIterator() as $_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts all the results collected by the iterators.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return iterator_count($this->getIterator());
|
||||
}
|
||||
|
||||
private function searchInDirectory(string $dir): \Iterator
|
||||
{
|
||||
$exclude = $this->exclude;
|
||||
$notPaths = $this->notPaths;
|
||||
|
||||
if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
|
||||
$exclude = array_merge($exclude, self::$vcsPatterns);
|
||||
}
|
||||
|
||||
if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
|
||||
$notPaths[] = '#(^|/)\..+(/|$)#';
|
||||
}
|
||||
|
||||
$minDepth = 0;
|
||||
$maxDepth = \PHP_INT_MAX;
|
||||
|
||||
foreach ($this->depths as $comparator) {
|
||||
switch ($comparator->getOperator()) {
|
||||
case '>':
|
||||
$minDepth = $comparator->getTarget() + 1;
|
||||
break;
|
||||
case '>=':
|
||||
$minDepth = $comparator->getTarget();
|
||||
break;
|
||||
case '<':
|
||||
$maxDepth = $comparator->getTarget() - 1;
|
||||
break;
|
||||
case '<=':
|
||||
$maxDepth = $comparator->getTarget();
|
||||
break;
|
||||
default:
|
||||
$minDepth = $maxDepth = $comparator->getTarget();
|
||||
}
|
||||
}
|
||||
|
||||
$flags = \RecursiveDirectoryIterator::SKIP_DOTS;
|
||||
|
||||
if ($this->followLinks) {
|
||||
$flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
|
||||
}
|
||||
|
||||
$iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
|
||||
|
||||
if ($exclude) {
|
||||
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $exclude);
|
||||
}
|
||||
|
||||
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
if ($minDepth > 0 || $maxDepth < \PHP_INT_MAX) {
|
||||
$iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
|
||||
}
|
||||
|
||||
if ($this->mode) {
|
||||
$iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
|
||||
}
|
||||
|
||||
if ($this->names || $this->notNames) {
|
||||
$iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
|
||||
}
|
||||
|
||||
if ($this->contains || $this->notContains) {
|
||||
$iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
|
||||
}
|
||||
|
||||
if ($this->sizes) {
|
||||
$iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
|
||||
}
|
||||
|
||||
if ($this->dates) {
|
||||
$iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
|
||||
}
|
||||
|
||||
if ($this->filters) {
|
||||
$iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
|
||||
}
|
||||
|
||||
if ($this->paths || $notPaths) {
|
||||
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths);
|
||||
}
|
||||
|
||||
if (static::IGNORE_VCS_IGNORED_FILES === (static::IGNORE_VCS_IGNORED_FILES & $this->ignore)) {
|
||||
$iterator = new Iterator\VcsIgnoredFilterIterator($iterator, $dir);
|
||||
}
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes given directory names by removing trailing slashes.
|
||||
*
|
||||
* Excluding: (s)ftp:// or ssh2.(s)ftp:// wrapper
|
||||
*/
|
||||
private function normalizeDir(string $dir): string
|
||||
{
|
||||
if ('/' === $dir) {
|
||||
return $dir;
|
||||
}
|
||||
|
||||
$dir = rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
|
||||
|
||||
if (preg_match('#^(ssh2\.)?s?ftp://#', $dir)) {
|
||||
$dir .= '/';
|
||||
}
|
||||
|
||||
return $dir;
|
||||
}
|
||||
}
|
93
vendor/symfony/finder/Gitignore.php
vendored
Normal file
93
vendor/symfony/finder/Gitignore.php
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?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
|
||||
{
|
||||
return self::buildRegex($gitignoreFileContent, false);
|
||||
}
|
||||
|
||||
public static function toRegexMatchingNegatedPatterns(string $gitignoreFileContent): string
|
||||
{
|
||||
return self::buildRegex($gitignoreFileContent, true);
|
||||
}
|
||||
|
||||
private static function buildRegex(string $gitignoreFileContent, bool $inverted): string
|
||||
{
|
||||
$gitignoreFileContent = preg_replace('~(?<!\\\\)#[^\n\r]*~', '', $gitignoreFileContent);
|
||||
$gitignoreLines = preg_split('~\r\n?|\n~', $gitignoreFileContent);
|
||||
|
||||
$res = self::lineToRegex('');
|
||||
foreach ($gitignoreLines as $line) {
|
||||
$line = preg_replace('~(?<!\\\\)[ \t]+$~', '', $line);
|
||||
|
||||
if ('!' === substr($line, 0, 1)) {
|
||||
$line = substr($line, 1);
|
||||
$isNegative = true;
|
||||
} else {
|
||||
$isNegative = false;
|
||||
}
|
||||
|
||||
if ('' !== $line) {
|
||||
if ($isNegative xor $inverted) {
|
||||
$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, '/') ? '(?:$|/)' : '');
|
||||
}
|
||||
}
|
111
vendor/symfony/finder/Glob.php
vendored
Normal file
111
vendor/symfony/finder/Glob.php
vendored
Normal file
|
@ -0,0 +1,111 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* Glob matches globbing patterns against text.
|
||||
*
|
||||
* if match_glob("foo.*", "foo.bar") echo "matched\n";
|
||||
*
|
||||
* // prints foo.bar and foo.baz
|
||||
* $regex = glob_to_regex("foo.*");
|
||||
* for (['foo.bar', 'foo.baz', 'foo', 'bar'] as $t)
|
||||
* {
|
||||
* if (/$regex/) echo "matched: $car\n";
|
||||
* }
|
||||
*
|
||||
* Glob implements glob(3) style matching that can be used to match
|
||||
* against text, rather than fetching names from a filesystem.
|
||||
*
|
||||
* Based on the Perl Text::Glob module.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com> PHP port
|
||||
* @author Richard Clamp <richardc@unixbeard.net> Perl version
|
||||
* @copyright 2004-2005 Fabien Potencier <fabien@symfony.com>
|
||||
* @copyright 2002 Richard Clamp <richardc@unixbeard.net>
|
||||
*/
|
||||
class Glob
|
||||
{
|
||||
/**
|
||||
* Returns a regexp which is the equivalent of the glob pattern.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#')
|
||||
{
|
||||
$firstByte = true;
|
||||
$escaping = false;
|
||||
$inCurlies = 0;
|
||||
$regex = '';
|
||||
$sizeGlob = \strlen($glob);
|
||||
for ($i = 0; $i < $sizeGlob; ++$i) {
|
||||
$car = $glob[$i];
|
||||
if ($firstByte && $strictLeadingDot && '.' !== $car) {
|
||||
$regex .= '(?=[^\.])';
|
||||
}
|
||||
|
||||
$firstByte = '/' === $car;
|
||||
|
||||
if ($firstByte && $strictWildcardSlash && isset($glob[$i + 2]) && '**' === $glob[$i + 1].$glob[$i + 2] && (!isset($glob[$i + 3]) || '/' === $glob[$i + 3])) {
|
||||
$car = '[^/]++/';
|
||||
if (!isset($glob[$i + 3])) {
|
||||
$car .= '?';
|
||||
}
|
||||
|
||||
if ($strictLeadingDot) {
|
||||
$car = '(?=[^\.])'.$car;
|
||||
}
|
||||
|
||||
$car = '/(?:'.$car.')*';
|
||||
$i += 2 + isset($glob[$i + 3]);
|
||||
|
||||
if ('/' === $delimiter) {
|
||||
$car = str_replace('/', '\\/', $car);
|
||||
}
|
||||
}
|
||||
|
||||
if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
|
||||
$regex .= "\\$car";
|
||||
} elseif ('*' === $car) {
|
||||
$regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
|
||||
} elseif ('?' === $car) {
|
||||
$regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
|
||||
} elseif ('{' === $car) {
|
||||
$regex .= $escaping ? '\\{' : '(';
|
||||
if (!$escaping) {
|
||||
++$inCurlies;
|
||||
}
|
||||
} elseif ('}' === $car && $inCurlies) {
|
||||
$regex .= $escaping ? '}' : ')';
|
||||
if (!$escaping) {
|
||||
--$inCurlies;
|
||||
}
|
||||
} elseif (',' === $car && $inCurlies) {
|
||||
$regex .= $escaping ? ',' : '|';
|
||||
} elseif ('\\' === $car) {
|
||||
if ($escaping) {
|
||||
$regex .= '\\\\';
|
||||
$escaping = false;
|
||||
} else {
|
||||
$escaping = true;
|
||||
}
|
||||
|
||||
continue;
|
||||
} else {
|
||||
$regex .= $car;
|
||||
}
|
||||
$escaping = false;
|
||||
}
|
||||
|
||||
return $delimiter.'^'.$regex.'$'.$delimiter;
|
||||
}
|
||||
}
|
64
vendor/symfony/finder/Iterator/CustomFilterIterator.php
vendored
Normal file
64
vendor/symfony/finder/Iterator/CustomFilterIterator.php
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* CustomFilterIterator filters files by applying anonymous functions.
|
||||
*
|
||||
* The anonymous function receives a \SplFileInfo and must return false
|
||||
* to remove files.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @extends \FilterIterator<string, \SplFileInfo>
|
||||
*/
|
||||
class CustomFilterIterator extends \FilterIterator
|
||||
{
|
||||
private $filters = [];
|
||||
|
||||
/**
|
||||
* @param \Iterator<string, \SplFileInfo> $iterator The Iterator to filter
|
||||
* @param callable[] $filters An array of PHP callbacks
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(\Iterator $iterator, array $filters)
|
||||
{
|
||||
foreach ($filters as $filter) {
|
||||
if (!\is_callable($filter)) {
|
||||
throw new \InvalidArgumentException('Invalid PHP callback.');
|
||||
}
|
||||
}
|
||||
$this->filters = $filters;
|
||||
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the iterator values.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
$fileinfo = $this->current();
|
||||
|
||||
foreach ($this->filters as $filter) {
|
||||
if (false === $filter($fileinfo)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
61
vendor/symfony/finder/Iterator/DateRangeFilterIterator.php
vendored
Normal file
61
vendor/symfony/finder/Iterator/DateRangeFilterIterator.php
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?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;
|
||||
|
||||
use Symfony\Component\Finder\Comparator\DateComparator;
|
||||
|
||||
/**
|
||||
* DateRangeFilterIterator filters out files that are not in the given date range (last modified dates).
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @extends \FilterIterator<string, \SplFileInfo>
|
||||
*/
|
||||
class DateRangeFilterIterator extends \FilterIterator
|
||||
{
|
||||
private $comparators = [];
|
||||
|
||||
/**
|
||||
* @param \Iterator<string, \SplFileInfo> $iterator
|
||||
* @param DateComparator[] $comparators
|
||||
*/
|
||||
public function __construct(\Iterator $iterator, array $comparators)
|
||||
{
|
||||
$this->comparators = $comparators;
|
||||
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the iterator values.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
$fileinfo = $this->current();
|
||||
|
||||
if (!file_exists($fileinfo->getPathname())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$filedate = $fileinfo->getMTime();
|
||||
foreach ($this->comparators as $compare) {
|
||||
if (!$compare->test($filedate)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
51
vendor/symfony/finder/Iterator/DepthRangeFilterIterator.php
vendored
Normal file
51
vendor/symfony/finder/Iterator/DepthRangeFilterIterator.php
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* DepthRangeFilterIterator limits the directory depth.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @template-covariant TKey
|
||||
* @template-covariant TValue
|
||||
*
|
||||
* @extends \FilterIterator<TKey, TValue>
|
||||
*/
|
||||
class DepthRangeFilterIterator extends \FilterIterator
|
||||
{
|
||||
private $minDepth = 0;
|
||||
|
||||
/**
|
||||
* @param \RecursiveIteratorIterator<\RecursiveIterator<TKey, TValue>> $iterator The Iterator to filter
|
||||
* @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)
|
||||
{
|
||||
$this->minDepth = $minDepth;
|
||||
$iterator->setMaxDepth(\PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
|
||||
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the iterator values.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
return $this->getInnerIterator()->getDepth() >= $this->minDepth;
|
||||
}
|
||||
}
|
97
vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php
vendored
Normal file
97
vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php
vendored
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* ExcludeDirectoryFilterIterator filters out directories.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @extends \FilterIterator<string, \SplFileInfo>
|
||||
*
|
||||
* @implements \RecursiveIterator<string, \SplFileInfo>
|
||||
*/
|
||||
class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator
|
||||
{
|
||||
private $iterator;
|
||||
private $isRecursive;
|
||||
private $excludedDirs = [];
|
||||
private $excludedPattern;
|
||||
|
||||
/**
|
||||
* @param \Iterator $iterator The Iterator to filter
|
||||
* @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 = [];
|
||||
foreach ($directories as $directory) {
|
||||
$directory = rtrim($directory, '/');
|
||||
if (!$this->isRecursive || str_contains($directory, '/')) {
|
||||
$patterns[] = preg_quote($directory, '#');
|
||||
} else {
|
||||
$this->excludedDirs[$directory] = true;
|
||||
}
|
||||
}
|
||||
if ($patterns) {
|
||||
$this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
|
||||
}
|
||||
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the iterator values.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->excludedPattern) {
|
||||
$path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
|
||||
$path = str_replace('\\', '/', $path);
|
||||
|
||||
return !preg_match($this->excludedPattern, $path);
|
||||
}
|
||||
|
||||
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(), []);
|
||||
$children->excludedDirs = $this->excludedDirs;
|
||||
$children->excludedPattern = $this->excludedPattern;
|
||||
|
||||
return $children;
|
||||
}
|
||||
}
|
56
vendor/symfony/finder/Iterator/FileTypeFilterIterator.php
vendored
Normal file
56
vendor/symfony/finder/Iterator/FileTypeFilterIterator.php
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* FileTypeFilterIterator only keeps files, directories, or both.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @extends \FilterIterator<string, \SplFileInfo>
|
||||
*/
|
||||
class FileTypeFilterIterator extends \FilterIterator
|
||||
{
|
||||
public const ONLY_FILES = 1;
|
||||
public const ONLY_DIRECTORIES = 2;
|
||||
|
||||
private $mode;
|
||||
|
||||
/**
|
||||
* @param \Iterator $iterator The Iterator to filter
|
||||
* @param int $mode The mode (self::ONLY_FILES or self::ONLY_DIRECTORIES)
|
||||
*/
|
||||
public function __construct(\Iterator $iterator, int $mode)
|
||||
{
|
||||
$this->mode = $mode;
|
||||
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the iterator values.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
$fileinfo = $this->current();
|
||||
if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
|
||||
return false;
|
||||
} elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
61
vendor/symfony/finder/Iterator/FilecontentFilterIterator.php
vendored
Normal file
61
vendor/symfony/finder/Iterator/FilecontentFilterIterator.php
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* FilecontentFilterIterator filters files by their contents using patterns (regexps or strings).
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Włodzimierz Gajda <gajdaw@gajdaw.pl>
|
||||
*
|
||||
* @extends MultiplePcreFilterIterator<string, \SplFileInfo>
|
||||
*/
|
||||
class FilecontentFilterIterator extends MultiplePcreFilterIterator
|
||||
{
|
||||
/**
|
||||
* Filters the iterator values.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
if (!$this->matchRegexps && !$this->noMatchRegexps) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$fileinfo = $this->current();
|
||||
|
||||
if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$content = $fileinfo->getContents();
|
||||
if (!$content) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->isAccepted($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts string to regexp if necessary.
|
||||
*
|
||||
* @param string $str Pattern: string or regexp
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function toRegex(string $str)
|
||||
{
|
||||
return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
|
||||
}
|
||||
}
|
50
vendor/symfony/finder/Iterator/FilenameFilterIterator.php
vendored
Normal file
50
vendor/symfony/finder/Iterator/FilenameFilterIterator.php
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?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;
|
||||
|
||||
use Symfony\Component\Finder\Glob;
|
||||
|
||||
/**
|
||||
* FilenameFilterIterator filters files by patterns (a regexp, a glob, or a string).
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @extends MultiplePcreFilterIterator<string, \SplFileInfo>
|
||||
*/
|
||||
class FilenameFilterIterator extends MultiplePcreFilterIterator
|
||||
{
|
||||
/**
|
||||
* Filters the iterator values.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
return $this->isAccepted($this->current()->getFilename());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts glob to regexp.
|
||||
*
|
||||
* PCRE patterns are left unchanged.
|
||||
* Glob strings are transformed with Glob::toRegex().
|
||||
*
|
||||
* @param string $str Pattern: glob or regexp
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function toRegex(string $str)
|
||||
{
|
||||
return $this->isRegex($str) ? $str : Glob::toRegex($str);
|
||||
}
|
||||
}
|
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)();
|
||||
}
|
||||
}
|
117
vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php
vendored
Normal file
117
vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* MultiplePcreFilterIterator filters files using patterns (regexps, globs or strings).
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @template-covariant TKey
|
||||
* @template-covariant TValue
|
||||
*
|
||||
* @extends \FilterIterator<TKey, TValue>
|
||||
*/
|
||||
abstract class MultiplePcreFilterIterator extends \FilterIterator
|
||||
{
|
||||
protected $matchRegexps = [];
|
||||
protected $noMatchRegexps = [];
|
||||
|
||||
/**
|
||||
* @param \Iterator $iterator The Iterator to filter
|
||||
* @param string[] $matchPatterns An array of patterns that need to match
|
||||
* @param string[] $noMatchPatterns An array of patterns that need to not match
|
||||
*/
|
||||
public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
|
||||
{
|
||||
foreach ($matchPatterns as $pattern) {
|
||||
$this->matchRegexps[] = $this->toRegex($pattern);
|
||||
}
|
||||
|
||||
foreach ($noMatchPatterns as $pattern) {
|
||||
$this->noMatchRegexps[] = $this->toRegex($pattern);
|
||||
}
|
||||
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the string is accepted by the regex filters.
|
||||
*
|
||||
* If there is no regexps defined in the class, this method will accept the string.
|
||||
* Such case can be handled by child classes before calling the method if they want to
|
||||
* apply a different behavior.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isAccepted(string $string)
|
||||
{
|
||||
// should at least not match one rule to exclude
|
||||
foreach ($this->noMatchRegexps as $regex) {
|
||||
if (preg_match($regex, $string)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// should at least match one rule
|
||||
if ($this->matchRegexps) {
|
||||
foreach ($this->matchRegexps as $regex) {
|
||||
if (preg_match($regex, $string)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// If there is no match rules, the file is accepted
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the string is a regex.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isRegex(string $str)
|
||||
{
|
||||
$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);
|
||||
|
||||
if ($start === $end) {
|
||||
return !preg_match('/[*?[:alnum:] \\\\]/', $start);
|
||||
}
|
||||
|
||||
foreach ([['{', '}'], ['(', ')'], ['[', ']'], ['<', '>']] as $delimiters) {
|
||||
if ($start === $delimiters[0] && $end === $delimiters[1]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts string into regexp.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function toRegex(string $str);
|
||||
}
|
59
vendor/symfony/finder/Iterator/PathFilterIterator.php
vendored
Normal file
59
vendor/symfony/finder/Iterator/PathFilterIterator.php
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* PathFilterIterator filters files by path patterns (e.g. some/special/dir).
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Włodzimierz Gajda <gajdaw@gajdaw.pl>
|
||||
*
|
||||
* @extends MultiplePcreFilterIterator<string, \SplFileInfo>
|
||||
*/
|
||||
class PathFilterIterator extends MultiplePcreFilterIterator
|
||||
{
|
||||
/**
|
||||
* Filters the iterator values.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
$filename = $this->current()->getRelativePathname();
|
||||
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$filename = str_replace('\\', '/', $filename);
|
||||
}
|
||||
|
||||
return $this->isAccepted($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts strings to regexp.
|
||||
*
|
||||
* PCRE patterns are left unchanged.
|
||||
*
|
||||
* Default conversion:
|
||||
* 'lorem/ipsum/dolor' ==> 'lorem\/ipsum\/dolor/'
|
||||
*
|
||||
* Use only / as directory separator (on Windows also).
|
||||
*
|
||||
* @param string $str Pattern: regexp or dirname
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function toRegex(string $str)
|
||||
{
|
||||
return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
|
||||
}
|
||||
}
|
158
vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php
vendored
Normal file
158
vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php
vendored
Normal file
|
@ -0,0 +1,158 @@
|
|||
<?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;
|
||||
|
||||
use Symfony\Component\Finder\Exception\AccessDeniedException;
|
||||
use Symfony\Component\Finder\SplFileInfo;
|
||||
|
||||
/**
|
||||
* Extends the \RecursiveDirectoryIterator to support relative paths.
|
||||
*
|
||||
* @author Victor Berchet <victor@suumit.com>
|
||||
*/
|
||||
class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $ignoreUnreadableDirs;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $ignoreFirstRewind = true;
|
||||
|
||||
// these 3 properties take part of the performance optimization to avoid redoing the same work in all iterations
|
||||
private $rootPath;
|
||||
private $subPath;
|
||||
private $directorySeparator = '/';
|
||||
|
||||
/**
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct(string $path, int $flags, bool $ignoreUnreadableDirs = false)
|
||||
{
|
||||
if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
|
||||
throw new \RuntimeException('This iterator only support returning current as fileinfo.');
|
||||
}
|
||||
|
||||
parent::__construct($path, $flags);
|
||||
$this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
|
||||
$this->rootPath = $path;
|
||||
if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
|
||||
$this->directorySeparator = \DIRECTORY_SEPARATOR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of SplFileInfo with support for relative paths.
|
||||
*
|
||||
* @return SplFileInfo
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
// the logic here avoids redoing the same work in all iterations
|
||||
|
||||
if (null === $subPathname = $this->subPath) {
|
||||
$subPathname = $this->subPath = $this->getSubPath();
|
||||
}
|
||||
if ('' !== $subPathname) {
|
||||
$subPathname .= $this->directorySeparator;
|
||||
}
|
||||
$subPathname .= $this->getFilename();
|
||||
$basePath = $this->rootPath;
|
||||
|
||||
if ('/' !== $basePath && !str_ends_with($basePath, $this->directorySeparator) && !str_ends_with($basePath, '/')) {
|
||||
$basePath .= $this->directorySeparator;
|
||||
}
|
||||
|
||||
return new SplFileInfo($basePath.$subPathname, $this->subPath, $subPathname);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $allowLinks
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function hasChildren($allowLinks = false)
|
||||
{
|
||||
$hasChildren = parent::hasChildren($allowLinks);
|
||||
|
||||
if (!$hasChildren || !$this->ignoreUnreadableDirs) {
|
||||
return $hasChildren;
|
||||
}
|
||||
|
||||
try {
|
||||
parent::getChildren();
|
||||
|
||||
return true;
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
// If directory is unreadable and finder is set to ignore it, skip children
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RecursiveDirectoryIterator
|
||||
*
|
||||
* @throws AccessDeniedException
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getChildren()
|
||||
{
|
||||
try {
|
||||
$children = parent::getChildren();
|
||||
|
||||
if ($children instanceof self) {
|
||||
// parent method will call the constructor with default arguments, so unreadable dirs won't be ignored anymore
|
||||
$children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
|
||||
|
||||
// performance optimization to avoid redoing the same work in all children
|
||||
$children->rootPath = $this->rootPath;
|
||||
}
|
||||
|
||||
return $children;
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function next()
|
||||
{
|
||||
$this->ignoreFirstRewind = false;
|
||||
|
||||
parent::next();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
// some streams like FTP are not rewindable, ignore the first rewind after creation,
|
||||
// as newly created DirectoryIterator does not need to be rewound
|
||||
if ($this->ignoreFirstRewind) {
|
||||
$this->ignoreFirstRewind = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::rewind();
|
||||
}
|
||||
}
|
60
vendor/symfony/finder/Iterator/SizeRangeFilterIterator.php
vendored
Normal file
60
vendor/symfony/finder/Iterator/SizeRangeFilterIterator.php
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?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;
|
||||
|
||||
use Symfony\Component\Finder\Comparator\NumberComparator;
|
||||
|
||||
/**
|
||||
* SizeRangeFilterIterator filters out files that are not in the given size range.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @extends \FilterIterator<string, \SplFileInfo>
|
||||
*/
|
||||
class SizeRangeFilterIterator extends \FilterIterator
|
||||
{
|
||||
private $comparators = [];
|
||||
|
||||
/**
|
||||
* @param \Iterator<string, \SplFileInfo> $iterator
|
||||
* @param NumberComparator[] $comparators
|
||||
*/
|
||||
public function __construct(\Iterator $iterator, array $comparators)
|
||||
{
|
||||
$this->comparators = $comparators;
|
||||
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the iterator values.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
$fileinfo = $this->current();
|
||||
if (!$fileinfo->isFile()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$filesize = $fileinfo->getSize();
|
||||
foreach ($this->comparators as $compare) {
|
||||
if (!$compare->test($filesize)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
104
vendor/symfony/finder/Iterator/SortableIterator.php
vendored
Normal file
104
vendor/symfony/finder/Iterator/SortableIterator.php
vendored
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* SortableIterator applies a sort on a given Iterator.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @implements \IteratorAggregate<string, \SplFileInfo>
|
||||
*/
|
||||
class SortableIterator implements \IteratorAggregate
|
||||
{
|
||||
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<string, \SplFileInfo> $iterator
|
||||
* @param int|callable $sort The sort type (SORT_BY_NAME, SORT_BY_TYPE, or a PHP callback)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(\Traversable $iterator, $sort, bool $reverseOrder = false)
|
||||
{
|
||||
$this->iterator = $iterator;
|
||||
$order = $reverseOrder ? -1 : 1;
|
||||
|
||||
if (self::SORT_BY_NAME === $sort) {
|
||||
$this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
|
||||
return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_NAME_NATURAL === $sort) {
|
||||
$this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
|
||||
return $order * strnatcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_TYPE === $sort) {
|
||||
$this->sort = static function (\SplFileInfo $a, \SplFileInfo $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());
|
||||
};
|
||||
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
|
||||
$this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
|
||||
return $order * ($a->getATime() - $b->getATime());
|
||||
};
|
||||
} elseif (self::SORT_BY_CHANGED_TIME === $sort) {
|
||||
$this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
|
||||
return $order * ($a->getCTime() - $b->getCTime());
|
||||
};
|
||||
} elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
|
||||
$this->sort = static function (\SplFileInfo $a, \SplFileInfo $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 ? static function (\SplFileInfo $a, \SplFileInfo $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<string, \SplFileInfo>
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
{
|
||||
if (1 === $this->sort) {
|
||||
return $this->iterator;
|
||||
}
|
||||
|
||||
$array = iterator_to_array($this->iterator, true);
|
||||
|
||||
if (-1 === $this->sort) {
|
||||
$array = array_reverse($array);
|
||||
} else {
|
||||
uasort($array, $this->sort);
|
||||
}
|
||||
|
||||
return new \ArrayIterator($array);
|
||||
}
|
||||
}
|
151
vendor/symfony/finder/Iterator/VcsIgnoredFilterIterator.php
vendored
Normal file
151
vendor/symfony/finder/Iterator/VcsIgnoredFilterIterator.php
vendored
Normal file
|
@ -0,0 +1,151 @@
|
|||
<?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;
|
||||
|
||||
use Symfony\Component\Finder\Gitignore;
|
||||
|
||||
final class VcsIgnoredFilterIterator extends \FilterIterator
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $baseDir;
|
||||
|
||||
/**
|
||||
* @var array<string, array{0: string, 1: string}|null>
|
||||
*/
|
||||
private $gitignoreFilesCache = [];
|
||||
|
||||
/**
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
private $ignoredPathsCache = [];
|
||||
|
||||
public function __construct(\Iterator $iterator, string $baseDir)
|
||||
{
|
||||
$this->baseDir = $this->normalizePath($baseDir);
|
||||
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
||||
public function accept(): bool
|
||||
{
|
||||
$file = $this->current();
|
||||
|
||||
$fileRealPath = $this->normalizePath($file->getRealPath());
|
||||
|
||||
return !$this->isIgnored($fileRealPath);
|
||||
}
|
||||
|
||||
private function isIgnored(string $fileRealPath): bool
|
||||
{
|
||||
if (is_dir($fileRealPath) && !str_ends_with($fileRealPath, '/')) {
|
||||
$fileRealPath .= '/';
|
||||
}
|
||||
|
||||
if (isset($this->ignoredPathsCache[$fileRealPath])) {
|
||||
return $this->ignoredPathsCache[$fileRealPath];
|
||||
}
|
||||
|
||||
$ignored = false;
|
||||
|
||||
foreach ($this->parentsDirectoryDownward($fileRealPath) as $parentDirectory) {
|
||||
if ($this->isIgnored($parentDirectory)) {
|
||||
// rules in ignored directories are ignored, no need to check further.
|
||||
break;
|
||||
}
|
||||
|
||||
$fileRelativePath = substr($fileRealPath, \strlen($parentDirectory) + 1);
|
||||
|
||||
if (null === $regexps = $this->readGitignoreFile("{$parentDirectory}/.gitignore")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
[$exclusionRegex, $inclusionRegex] = $regexps;
|
||||
|
||||
if (preg_match($exclusionRegex, $fileRelativePath)) {
|
||||
$ignored = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match($inclusionRegex, $fileRelativePath)) {
|
||||
$ignored = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->ignoredPathsCache[$fileRealPath] = $ignored;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
private function parentsDirectoryDownward(string $fileRealPath): array
|
||||
{
|
||||
$parentDirectories = [];
|
||||
|
||||
$parentDirectory = $fileRealPath;
|
||||
|
||||
while (true) {
|
||||
$newParentDirectory = \dirname($parentDirectory);
|
||||
|
||||
// dirname('/') = '/'
|
||||
if ($newParentDirectory === $parentDirectory) {
|
||||
break;
|
||||
}
|
||||
|
||||
$parentDirectory = $newParentDirectory;
|
||||
|
||||
if (0 !== strpos($parentDirectory, $this->baseDir)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$parentDirectories[] = $parentDirectory;
|
||||
}
|
||||
|
||||
return array_reverse($parentDirectories);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: string, 1: string}|null
|
||||
*/
|
||||
private function readGitignoreFile(string $path): ?array
|
||||
{
|
||||
if (\array_key_exists($path, $this->gitignoreFilesCache)) {
|
||||
return $this->gitignoreFilesCache[$path];
|
||||
}
|
||||
|
||||
if (!file_exists($path)) {
|
||||
return $this->gitignoreFilesCache[$path] = null;
|
||||
}
|
||||
|
||||
if (!is_file($path) || !is_readable($path)) {
|
||||
throw new \RuntimeException("The \"ignoreVCSIgnored\" option cannot be used by the Finder as the \"{$path}\" file is not readable.");
|
||||
}
|
||||
|
||||
$gitignoreFileContent = file_get_contents($path);
|
||||
|
||||
return $this->gitignoreFilesCache[$path] = [
|
||||
Gitignore::toRegex($gitignoreFileContent),
|
||||
Gitignore::toRegexMatchingNegatedPatterns($gitignoreFileContent),
|
||||
];
|
||||
}
|
||||
|
||||
private function normalizePath(string $path): string
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
return str_replace('\\', '/', $path);
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
}
|
19
vendor/symfony/finder/LICENSE
vendored
Normal file
19
vendor/symfony/finder/LICENSE
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2004-present 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
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
14
vendor/symfony/finder/README.md
vendored
Normal file
14
vendor/symfony/finder/README.md
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
Finder Component
|
||||
================
|
||||
|
||||
The Finder component finds files and directories via an intuitive fluent
|
||||
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)
|
88
vendor/symfony/finder/SplFileInfo.php
vendored
Normal file
88
vendor/symfony/finder/SplFileInfo.php
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?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;
|
||||
|
||||
/**
|
||||
* Extends \SplFileInfo to support relative paths.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class SplFileInfo extends \SplFileInfo
|
||||
{
|
||||
private $relativePath;
|
||||
private $relativePathname;
|
||||
|
||||
/**
|
||||
* @param string $file The file name
|
||||
* @param string $relativePath The relative path
|
||||
* @param string $relativePathname The relative path name
|
||||
*/
|
||||
public function __construct(string $file, string $relativePath, string $relativePathname)
|
||||
{
|
||||
parent::__construct($file);
|
||||
$this->relativePath = $relativePath;
|
||||
$this->relativePathname = $relativePathname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the relative path.
|
||||
*
|
||||
* This path does not contain the file name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRelativePath()
|
||||
{
|
||||
return $this->relativePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the relative path name.
|
||||
*
|
||||
* This path contains the file name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRelativePathname()
|
||||
{
|
||||
return $this->relativePathname;
|
||||
}
|
||||
|
||||
public function getFilenameWithoutExtension(): string
|
||||
{
|
||||
$filename = $this->getFilename();
|
||||
|
||||
return pathinfo($filename, \PATHINFO_FILENAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contents of the file.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getContents()
|
||||
{
|
||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
||||
try {
|
||||
$content = file_get_contents($this->getPathname());
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
if (false === $content) {
|
||||
throw new \RuntimeException($error);
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
30
vendor/symfony/finder/composer.json
vendored
Normal file
30
vendor/symfony/finder/composer.json
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "symfony/finder",
|
||||
"type": "library",
|
||||
"description": "Finds files and directories via an intuitive fluent interface",
|
||||
"keywords": [],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"symfony/deprecation-contracts": "^2.1|^3",
|
||||
"symfony/polyfill-php80": "^1.16"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\Finder\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue