init
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Comparator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class Comparator
|
||||
{
|
||||
private $target;
|
||||
private $operator = '==';
|
||||
public function getTarget()
|
||||
{
|
||||
return $this->target;
|
||||
}
|
||||
public function setTarget($target)
|
||||
{
|
||||
$this->target = $target;
|
||||
}
|
||||
public function getOperator()
|
||||
{
|
||||
return $this->operator;
|
||||
}
|
||||
public function setOperator($operator)
|
||||
{
|
||||
if (!$operator) {
|
||||
$operator = '==';
|
||||
}
|
||||
if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
|
||||
throw new \InvalidArgumentException(\sprintf('Invalid operator "%s".', $operator));
|
||||
}
|
||||
$this->operator = $operator;
|
||||
}
|
||||
public function test($test)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Comparator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class DateComparator extends Comparator
|
||||
{
|
||||
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 = '<';
|
||||
}
|
||||
$this->setOperator($operator);
|
||||
$this->setTarget($target);
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Comparator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class NumberComparator extends Comparator
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
$this->setTarget($target);
|
||||
$this->setOperator($matches[1] ?? '==');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Exception;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class AccessDeniedException extends \UnexpectedValueException
|
||||
{
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Exception;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class DirectoryNotFoundException extends \InvalidArgumentException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
@@ -0,0 +1,359 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Comparator\DateComparator;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Comparator\NumberComparator;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Exception\DirectoryNotFoundException;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Iterator\CustomFilterIterator;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Iterator\FilenameFilterIterator;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Iterator\LazyIterator;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Iterator\SortableIterator;
|
||||
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;
|
||||
}
|
||||
public static function create()
|
||||
{
|
||||
return new static();
|
||||
}
|
||||
public function directories()
|
||||
{
|
||||
$this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
|
||||
return $this;
|
||||
}
|
||||
public function files()
|
||||
{
|
||||
$this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
|
||||
return $this;
|
||||
}
|
||||
public function depth($levels)
|
||||
{
|
||||
foreach ((array) $levels as $level) {
|
||||
$this->depths[] = new Comparator\NumberComparator($level);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function date($dates)
|
||||
{
|
||||
foreach ((array) $dates as $date) {
|
||||
$this->dates[] = new Comparator\DateComparator($date);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function name($patterns)
|
||||
{
|
||||
$this->names = \array_merge($this->names, (array) $patterns);
|
||||
return $this;
|
||||
}
|
||||
public function notName($patterns)
|
||||
{
|
||||
$this->notNames = \array_merge($this->notNames, (array) $patterns);
|
||||
return $this;
|
||||
}
|
||||
public function contains($patterns)
|
||||
{
|
||||
$this->contains = \array_merge($this->contains, (array) $patterns);
|
||||
return $this;
|
||||
}
|
||||
public function notContains($patterns)
|
||||
{
|
||||
$this->notContains = \array_merge($this->notContains, (array) $patterns);
|
||||
return $this;
|
||||
}
|
||||
public function path($patterns)
|
||||
{
|
||||
$this->paths = \array_merge($this->paths, (array) $patterns);
|
||||
return $this;
|
||||
}
|
||||
public function notPath($patterns)
|
||||
{
|
||||
$this->notPaths = \array_merge($this->notPaths, (array) $patterns);
|
||||
return $this;
|
||||
}
|
||||
public function size($sizes)
|
||||
{
|
||||
foreach ((array) $sizes as $size) {
|
||||
$this->sizes[] = new Comparator\NumberComparator($size);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function exclude($dirs)
|
||||
{
|
||||
$this->exclude = \array_merge($this->exclude, (array) $dirs);
|
||||
return $this;
|
||||
}
|
||||
public function ignoreDotFiles($ignoreDotFiles)
|
||||
{
|
||||
if ($ignoreDotFiles) {
|
||||
$this->ignore |= static::IGNORE_DOT_FILES;
|
||||
} else {
|
||||
$this->ignore &= ~static::IGNORE_DOT_FILES;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function ignoreVCS($ignoreVCS)
|
||||
{
|
||||
if ($ignoreVCS) {
|
||||
$this->ignore |= static::IGNORE_VCS_FILES;
|
||||
} else {
|
||||
$this->ignore &= ~static::IGNORE_VCS_FILES;
|
||||
}
|
||||
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;
|
||||
}
|
||||
public static function addVCSPattern($pattern)
|
||||
{
|
||||
foreach ((array) $pattern as $p) {
|
||||
self::$vcsPatterns[] = $p;
|
||||
}
|
||||
self::$vcsPatterns = \array_unique(self::$vcsPatterns);
|
||||
}
|
||||
public function sort(\Closure $closure)
|
||||
{
|
||||
$this->sort = $closure;
|
||||
return $this;
|
||||
}
|
||||
public function sortByName()
|
||||
{
|
||||
if (\func_num_args() < 1 && __CLASS__ !== static::class && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \MailPoetVendor\PHPUnit\Framework\MockObject\MockObject && !$this instanceof \MailPoetVendor\Prophecy\Prophecy\ProphecySubjectInterface && !$this instanceof \MailPoetVendor\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);
|
||||
$this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL : Iterator\SortableIterator::SORT_BY_NAME;
|
||||
return $this;
|
||||
}
|
||||
public function sortByType()
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
|
||||
return $this;
|
||||
}
|
||||
public function sortByAccessedTime()
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
|
||||
return $this;
|
||||
}
|
||||
public function reverseSorting()
|
||||
{
|
||||
$this->reverseSorting = \true;
|
||||
return $this;
|
||||
}
|
||||
public function sortByChangedTime()
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
|
||||
return $this;
|
||||
}
|
||||
public function sortByModifiedTime()
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
|
||||
return $this;
|
||||
}
|
||||
public function filter(\Closure $closure)
|
||||
{
|
||||
$this->filters[] = $closure;
|
||||
return $this;
|
||||
}
|
||||
public function followLinks()
|
||||
{
|
||||
$this->followLinks = \true;
|
||||
return $this;
|
||||
}
|
||||
public function ignoreUnreadableDirs($ignore = \true)
|
||||
{
|
||||
$this->ignoreUnreadableDirs = (bool) $ignore;
|
||||
return $this;
|
||||
}
|
||||
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_merge($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;
|
||||
}
|
||||
#[\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;
|
||||
}
|
||||
public function append($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;
|
||||
}
|
||||
public function hasResults()
|
||||
{
|
||||
foreach ($this->getIterator() as $_) {
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
#[\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[] = '#(^|/)\\..+(/|$)#';
|
||||
}
|
||||
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;
|
||||
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);
|
||||
}
|
||||
return $iterator;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class Gitignore
|
||||
{
|
||||
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, '/') ? '(?:$|/)' : '');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class Glob
|
||||
{
|
||||
public static function toRegex($glob, $strictLeadingDot = \true, $strictWildcardSlash = \true, $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;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class CustomFilterIterator extends \FilterIterator
|
||||
{
|
||||
private $filters = [];
|
||||
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);
|
||||
}
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
$fileinfo = $this->current();
|
||||
foreach ($this->filters as $filter) {
|
||||
if (\false === $filter($fileinfo)) {
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Comparator\DateComparator;
|
||||
class DateRangeFilterIterator extends \FilterIterator
|
||||
{
|
||||
private $comparators = [];
|
||||
public function __construct(\Iterator $iterator, array $comparators)
|
||||
{
|
||||
$this->comparators = $comparators;
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
#[\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;
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class DepthRangeFilterIterator extends \FilterIterator
|
||||
{
|
||||
private $minDepth = 0;
|
||||
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);
|
||||
}
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
return $this->getInnerIterator()->getDepth() >= $this->minDepth;
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator
|
||||
{
|
||||
private $iterator;
|
||||
private $isRecursive;
|
||||
private $excludedDirs = [];
|
||||
private $excludedPattern;
|
||||
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);
|
||||
}
|
||||
#[\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;
|
||||
}
|
||||
#[\ReturnTypeWillChange]
|
||||
public function hasChildren()
|
||||
{
|
||||
return $this->isRecursive && $this->iterator->hasChildren();
|
||||
}
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getChildren()
|
||||
{
|
||||
$children = new self($this->iterator->getChildren(), []);
|
||||
$children->excludedDirs = $this->excludedDirs;
|
||||
$children->excludedPattern = $this->excludedPattern;
|
||||
return $children;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class FileTypeFilterIterator extends \FilterIterator
|
||||
{
|
||||
public const ONLY_FILES = 1;
|
||||
public const ONLY_DIRECTORIES = 2;
|
||||
private $mode;
|
||||
public function __construct(\Iterator $iterator, int $mode)
|
||||
{
|
||||
$this->mode = $mode;
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
#[\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;
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class FilecontentFilterIterator extends MultiplePcreFilterIterator
|
||||
{
|
||||
#[\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);
|
||||
}
|
||||
protected function toRegex($str)
|
||||
{
|
||||
return $this->isRegex($str) ? $str : '/' . \preg_quote($str, '/') . '/';
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Glob;
|
||||
class FilenameFilterIterator extends MultiplePcreFilterIterator
|
||||
{
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
return $this->isAccepted($this->current()->getFilename());
|
||||
}
|
||||
protected function toRegex($str)
|
||||
{
|
||||
return $this->isRegex($str) ? $str : Glob::toRegex($str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class LazyIterator implements \IteratorAggregate
|
||||
{
|
||||
private $iteratorFactory;
|
||||
public function __construct(callable $iteratorFactory)
|
||||
{
|
||||
$this->iteratorFactory = $iteratorFactory;
|
||||
}
|
||||
public function getIterator() : \Traversable
|
||||
{
|
||||
yield from ($this->iteratorFactory)();
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
abstract class MultiplePcreFilterIterator extends \FilterIterator
|
||||
{
|
||||
protected $matchRegexps = [];
|
||||
protected $noMatchRegexps = [];
|
||||
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);
|
||||
}
|
||||
protected function isAccepted($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;
|
||||
}
|
||||
protected function isRegex($str)
|
||||
{
|
||||
if (\preg_match('/^(.{3,}?)[imsxuADU]*$/', $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;
|
||||
}
|
||||
protected abstract function toRegex($str);
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class PathFilterIterator extends MultiplePcreFilterIterator
|
||||
{
|
||||
#[\ReturnTypeWillChange]
|
||||
public function accept()
|
||||
{
|
||||
$filename = $this->current()->getRelativePathname();
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$filename = \str_replace('\\', '/', $filename);
|
||||
}
|
||||
return $this->isAccepted($filename);
|
||||
}
|
||||
protected function toRegex($str)
|
||||
{
|
||||
return $this->isRegex($str) ? $str : '/' . \preg_quote($str, '/') . '/';
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Exception\AccessDeniedException;
|
||||
use MailPoetVendor\Symfony\Component\Finder\SplFileInfo;
|
||||
class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
||||
{
|
||||
private $ignoreUnreadableDirs;
|
||||
private $rewindable;
|
||||
// these 3 properties take part of the performance optimization to avoid redoing the same work in all iterations
|
||||
private $rootPath;
|
||||
private $subPath;
|
||||
private $directorySeparator = '/';
|
||||
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;
|
||||
}
|
||||
}
|
||||
#[\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();
|
||||
if ('/' !== ($basePath = $this->rootPath)) {
|
||||
$basePath .= $this->directorySeparator;
|
||||
}
|
||||
return new SplFileInfo($basePath . $subPathname, $this->subPath, $subPathname);
|
||||
}
|
||||
#[\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->rewindable =& $this->rewindable;
|
||||
$children->rootPath = $this->rootPath;
|
||||
}
|
||||
return $children;
|
||||
} 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([]);
|
||||
} else {
|
||||
throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
#[\ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
if (\false === $this->isRewindable()) {
|
||||
return;
|
||||
}
|
||||
parent::rewind();
|
||||
}
|
||||
public function isRewindable()
|
||||
{
|
||||
if (null !== $this->rewindable) {
|
||||
return $this->rewindable;
|
||||
}
|
||||
if (\false !== ($stream = @\opendir($this->getPath()))) {
|
||||
$infos = \stream_get_meta_data($stream);
|
||||
\closedir($stream);
|
||||
if ($infos['seekable']) {
|
||||
return $this->rewindable = \true;
|
||||
}
|
||||
}
|
||||
return $this->rewindable = \false;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
use MailPoetVendor\Symfony\Component\Finder\Comparator\NumberComparator;
|
||||
class SizeRangeFilterIterator extends \FilterIterator
|
||||
{
|
||||
private $comparators = [];
|
||||
public function __construct(\Iterator $iterator, array $comparators)
|
||||
{
|
||||
$this->comparators = $comparators;
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
#[\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;
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder\Iterator;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
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;
|
||||
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 ($a, $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 ($a, $b) use($order) {
|
||||
return $order * \strnatcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_TYPE === $sort) {
|
||||
$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());
|
||||
};
|
||||
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
|
||||
$this->sort = static function ($a, $b) use($order) {
|
||||
return $order * ($a->getATime() - $b->getATime());
|
||||
};
|
||||
} elseif (self::SORT_BY_CHANGED_TIME === $sort) {
|
||||
$this->sort = static function ($a, $b) use($order) {
|
||||
return $order * ($a->getCTime() - $b->getCTime());
|
||||
};
|
||||
} elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
|
||||
$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 ? 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.');
|
||||
}
|
||||
}
|
||||
#[\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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace MailPoetVendor\Symfony\Component\Finder;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
class SplFileInfo extends \SplFileInfo
|
||||
{
|
||||
private $relativePath;
|
||||
private $relativePathname;
|
||||
public function __construct(string $file, string $relativePath, string $relativePathname)
|
||||
{
|
||||
parent::__construct($file);
|
||||
$this->relativePath = $relativePath;
|
||||
$this->relativePathname = $relativePathname;
|
||||
}
|
||||
public function getRelativePath()
|
||||
{
|
||||
return $this->relativePath;
|
||||
}
|
||||
public function getRelativePathname()
|
||||
{
|
||||
return $this->relativePathname;
|
||||
}
|
||||
public function getFilenameWithoutExtension() : string
|
||||
{
|
||||
$filename = $this->getFilename();
|
||||
return \pathinfo($filename, \PATHINFO_FILENAME);
|
||||
}
|
||||
public function getContents()
|
||||
{
|
||||
\set_error_handler(function ($type, $msg) use(&$error) {
|
||||
$error = $msg;
|
||||
});
|
||||
$content = \file_get_contents($this->getPathname());
|
||||
\restore_error_handler();
|
||||
if (\false === $content) {
|
||||
throw new \RuntimeException($error);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
Reference in New Issue
Block a user