update patch 1
This commit is contained in:
+1
-1
@@ -23,7 +23,7 @@ class Comparator
|
||||
string $operator = '==',
|
||||
) {
|
||||
if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
|
||||
throw new \InvalidArgumentException(\sprintf('Invalid operator "%s".', $operator));
|
||||
}
|
||||
|
||||
$this->operator = $operator;
|
||||
|
||||
+2
-2
@@ -26,14 +26,14 @@ 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));
|
||||
throw new \InvalidArgumentException(\sprintf('Don\'t understand "%s" as a date test.', $test));
|
||||
}
|
||||
|
||||
try {
|
||||
$date = new \DateTimeImmutable($matches[2]);
|
||||
$target = $date->format('U');
|
||||
} catch (\Exception) {
|
||||
throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
|
||||
throw new \InvalidArgumentException(\sprintf('"%s" is not a valid date.', $matches[2]));
|
||||
}
|
||||
|
||||
$operator = $matches[1] ?? '==';
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ namespace Symfony\Component\Finder\Comparator;
|
||||
* magnitudes.
|
||||
*
|
||||
* The target value may use magnitudes of kilobytes (k, ki),
|
||||
* megabytes (m, mi), or gigabytes (g, gi). Those suffixed
|
||||
* 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
|
||||
*
|
||||
@@ -42,12 +42,12 @@ 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'));
|
||||
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));
|
||||
throw new \InvalidArgumentException(\sprintf('Invalid number "%s".', $target));
|
||||
}
|
||||
if (isset($matches[3])) {
|
||||
// magnitude
|
||||
|
||||
Vendored
+2
-6
@@ -643,7 +643,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
sort($glob);
|
||||
$resolvedDirs[] = array_map($this->normalizeDir(...), $glob);
|
||||
} else {
|
||||
throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
|
||||
throw new DirectoryNotFoundException(\sprintf('The "%s" directory does not exist.', $dir));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -699,8 +699,6 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
* 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): static
|
||||
{
|
||||
@@ -708,15 +706,13 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
$this->iterators[] = $iterator->getIterator();
|
||||
} elseif ($iterator instanceof \Iterator) {
|
||||
$this->iterators[] = $iterator;
|
||||
} elseif (is_iterable($iterator)) {
|
||||
} else {
|
||||
$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;
|
||||
|
||||
@@ -23,16 +23,14 @@ class FileTypeFilterIterator extends \FilterIterator
|
||||
public const ONLY_FILES = 1;
|
||||
public const ONLY_DIRECTORIES = 2;
|
||||
|
||||
private int $mode;
|
||||
|
||||
/**
|
||||
* @param \Iterator<string, \SplFileInfo> $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;
|
||||
|
||||
public function __construct(
|
||||
\Iterator $iterator,
|
||||
private int $mode,
|
||||
) {
|
||||
parent::__construct($iterator);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user