Skip to content

Commit d1d1360

Browse files
CS fixes
1 parent 1d0e826 commit d1d1360

10 files changed

+39
-39
lines changed

Comparator/Comparator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Comparator
2222
public function __construct(string $target, string $operator = '==')
2323
{
2424
if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
25-
throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
25+
throw new \InvalidArgumentException(\sprintf('Invalid operator "%s".', $operator));
2626
}
2727

2828
$this->target = $target;

Comparator/DateComparator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ class DateComparator extends Comparator
2626
public function __construct(string $test)
2727
{
2828
if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
29-
throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
29+
throw new \InvalidArgumentException(\sprintf('Don\'t understand "%s" as a date test.', $test));
3030
}
3131

3232
try {
3333
$date = new \DateTimeImmutable($matches[2]);
3434
$target = $date->format('U');
3535
} catch (\Exception) {
36-
throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
36+
throw new \InvalidArgumentException(\sprintf('"%s" is not a valid date.', $matches[2]));
3737
}
3838

3939
$operator = $matches[1] ?: '==';

Comparator/NumberComparator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ class NumberComparator extends Comparator
4242
public function __construct(?string $test)
4343
{
4444
if (null === $test || !preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
45-
throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test ?? 'null'));
45+
throw new \InvalidArgumentException(\sprintf('Don\'t understand "%s" as a number test.', $test ?? 'null'));
4646
}
4747

4848
$target = $matches[2];
4949
if (!is_numeric($target)) {
50-
throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
50+
throw new \InvalidArgumentException(\sprintf('Invalid number "%s".', $target));
5151
}
5252
if (isset($matches[3])) {
5353
// magnitude

Finder.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function files(): static
124124
public function depth(string|int|array $levels): static
125125
{
126126
foreach ((array) $levels as $level) {
127-
$this->depths[] = new Comparator\NumberComparator($level);
127+
$this->depths[] = new NumberComparator($level);
128128
}
129129

130130
return $this;
@@ -152,7 +152,7 @@ public function depth(string|int|array $levels): static
152152
public function date(string|array $dates): static
153153
{
154154
foreach ((array) $dates as $date) {
155-
$this->dates[] = new Comparator\DateComparator($date);
155+
$this->dates[] = new DateComparator($date);
156156
}
157157

158158
return $this;
@@ -307,7 +307,7 @@ public function notPath(string|array $patterns): static
307307
public function size(string|int|array $sizes): static
308308
{
309309
foreach ((array) $sizes as $size) {
310-
$this->sizes[] = new Comparator\NumberComparator($size);
310+
$this->sizes[] = new NumberComparator($size);
311311
}
312312

313313
return $this;
@@ -438,7 +438,7 @@ public function sort(\Closure $closure): static
438438
*/
439439
public function sortByExtension(): static
440440
{
441-
$this->sort = Iterator\SortableIterator::SORT_BY_EXTENSION;
441+
$this->sort = SortableIterator::SORT_BY_EXTENSION;
442442

443443
return $this;
444444
}
@@ -454,7 +454,7 @@ public function sortByExtension(): static
454454
*/
455455
public function sortByName(bool $useNaturalSort = false): static
456456
{
457-
$this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL : Iterator\SortableIterator::SORT_BY_NAME;
457+
$this->sort = $useNaturalSort ? SortableIterator::SORT_BY_NAME_NATURAL : SortableIterator::SORT_BY_NAME;
458458

459459
return $this;
460460
}
@@ -470,7 +470,7 @@ public function sortByName(bool $useNaturalSort = false): static
470470
*/
471471
public function sortByCaseInsensitiveName(bool $useNaturalSort = false): static
472472
{
473-
$this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL_CASE_INSENSITIVE : Iterator\SortableIterator::SORT_BY_NAME_CASE_INSENSITIVE;
473+
$this->sort = $useNaturalSort ? SortableIterator::SORT_BY_NAME_NATURAL_CASE_INSENSITIVE : SortableIterator::SORT_BY_NAME_CASE_INSENSITIVE;
474474

475475
return $this;
476476
}
@@ -486,7 +486,7 @@ public function sortByCaseInsensitiveName(bool $useNaturalSort = false): static
486486
*/
487487
public function sortBySize(): static
488488
{
489-
$this->sort = Iterator\SortableIterator::SORT_BY_SIZE;
489+
$this->sort = SortableIterator::SORT_BY_SIZE;
490490

491491
return $this;
492492
}
@@ -502,7 +502,7 @@ public function sortBySize(): static
502502
*/
503503
public function sortByType(): static
504504
{
505-
$this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
505+
$this->sort = SortableIterator::SORT_BY_TYPE;
506506

507507
return $this;
508508
}
@@ -520,7 +520,7 @@ public function sortByType(): static
520520
*/
521521
public function sortByAccessedTime(): static
522522
{
523-
$this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
523+
$this->sort = SortableIterator::SORT_BY_ACCESSED_TIME;
524524

525525
return $this;
526526
}
@@ -552,7 +552,7 @@ public function reverseSorting(): static
552552
*/
553553
public function sortByChangedTime(): static
554554
{
555-
$this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
555+
$this->sort = SortableIterator::SORT_BY_CHANGED_TIME;
556556

557557
return $this;
558558
}
@@ -570,7 +570,7 @@ public function sortByChangedTime(): static
570570
*/
571571
public function sortByModifiedTime(): static
572572
{
573-
$this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
573+
$this->sort = SortableIterator::SORT_BY_MODIFIED_TIME;
574574

575575
return $this;
576576
}
@@ -646,7 +646,7 @@ public function in(string|array $dirs): static
646646
sort($glob);
647647
$resolvedDirs[] = array_map($this->normalizeDir(...), $glob);
648648
} else {
649-
throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
649+
throw new DirectoryNotFoundException(\sprintf('The "%s" directory does not exist.', $dir));
650650
}
651651
}
652652

@@ -674,7 +674,7 @@ public function getIterator(): \Iterator
674674
$iterator = $this->searchInDirectory($this->dirs[0]);
675675

676676
if ($this->sort || $this->reverseSorting) {
677-
$iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
677+
$iterator = (new SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
678678
}
679679

680680
return $iterator;
@@ -690,7 +690,7 @@ public function getIterator(): \Iterator
690690
}
691691

692692
if ($this->sort || $this->reverseSorting) {
693-
$iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
693+
$iterator = (new SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
694694
}
695695

696696
return $iterator;
@@ -793,37 +793,37 @@ private function searchInDirectory(string $dir): \Iterator
793793
$iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
794794

795795
if ($exclude) {
796-
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $exclude);
796+
$iterator = new ExcludeDirectoryFilterIterator($iterator, $exclude);
797797
}
798798

799799
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
800800

801801
if ($minDepth > 0 || $maxDepth < \PHP_INT_MAX) {
802-
$iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
802+
$iterator = new DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
803803
}
804804

805805
if ($this->mode) {
806806
$iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
807807
}
808808

809809
if ($this->names || $this->notNames) {
810-
$iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
810+
$iterator = new FilenameFilterIterator($iterator, $this->names, $this->notNames);
811811
}
812812

813813
if ($this->contains || $this->notContains) {
814-
$iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
814+
$iterator = new FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
815815
}
816816

817817
if ($this->sizes) {
818-
$iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
818+
$iterator = new SizeRangeFilterIterator($iterator, $this->sizes);
819819
}
820820

821821
if ($this->dates) {
822-
$iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
822+
$iterator = new DateRangeFilterIterator($iterator, $this->dates);
823823
}
824824

825825
if ($this->filters) {
826-
$iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
826+
$iterator = new CustomFilterIterator($iterator, $this->filters);
827827
}
828828

829829
if ($this->paths || $notPaths) {

Tests/FinderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@ public function testAccessDeniedException()
16031603
} catch (\Exception $e) {
16041604
$expectedExceptionClass = 'Symfony\\Component\\Finder\\Exception\\AccessDeniedException';
16051605
if ($e instanceof \PHPUnit\Framework\ExpectationFailedException) {
1606-
$this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, 'PHPUnit\Framework\ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
1606+
$this->fail(\sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, 'PHPUnit\Framework\ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
16071607
}
16081608

16091609
$this->assertInstanceOf($expectedExceptionClass, $e);
@@ -1647,7 +1647,7 @@ public function testIgnoredAccessDeniedException()
16471647
'qux_10_2.php',
16481648
'qux_12_0.php',
16491649
'qux_2_0.php',
1650-
]
1650+
]
16511651
), $finder->getIterator());
16521652
}
16531653

Tests/GitignoreTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testToRegex(array $gitignoreLines, array $matchingCases, array $
3535
$this->assertMatchesRegularExpression(
3636
$regex,
3737
$matchingCase,
38-
sprintf(
38+
\sprintf(
3939
"Failed asserting path:\n%s\nmatches gitignore patterns:\n%s",
4040
preg_replace('~^~m', ' ', $matchingCase),
4141
preg_replace('~^~m', ' ', $patterns)
@@ -47,7 +47,7 @@ public function testToRegex(array $gitignoreLines, array $matchingCases, array $
4747
$this->assertDoesNotMatchRegularExpression(
4848
$regex,
4949
$nonMatchingCase,
50-
sprintf("Failed asserting path:\n%s\nNOT matching gitignore patterns:\n%s",
50+
\sprintf("Failed asserting path:\n%s\nNOT matching gitignore patterns:\n%s",
5151
preg_replace('~^~m', ' ', $nonMatchingCase),
5252
preg_replace('~^~m', ' ', $patterns)
5353
)
@@ -459,7 +459,7 @@ public function testToRegexMatchingNegatedPatterns(array $gitignoreLines, array
459459
$this->assertMatchesRegularExpression(
460460
$regex,
461461
$matchingCase,
462-
sprintf(
462+
\sprintf(
463463
"Failed asserting path:\n%s\nmatches gitignore negated patterns:\n%s",
464464
preg_replace('~^~m', ' ', $matchingCase),
465465
preg_replace('~^~m', ' ', $patterns)
@@ -471,7 +471,7 @@ public function testToRegexMatchingNegatedPatterns(array $gitignoreLines, array
471471
$this->assertDoesNotMatchRegularExpression(
472472
$regex,
473473
$nonMatchingCase,
474-
sprintf("Failed asserting path:\n%s\nNOT matching gitignore negated patterns:\n%s",
474+
\sprintf("Failed asserting path:\n%s\nNOT matching gitignore negated patterns:\n%s",
475475
preg_replace('~^~m', ' ', $nonMatchingCase),
476476
preg_replace('~^~m', ' ', $patterns)
477477
)

Tests/Iterator/IteratorTestCase.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ protected function assertOrderedIterator($expected, \Traversable $iterator)
4141
* Same as assertOrderedIterator, but checks the order of groups of
4242
* array elements.
4343
*
44-
* @param array $expected - an array of arrays. For any two subarrays
45-
* $a and $b such that $a goes before $b in $expected, the method
46-
* asserts that any element of $a goes before any element of $b
47-
* in the sequence generated by $iterator
44+
* @param array $expected - an array of arrays. For any two subarrays
45+
* $a and $b such that $a goes before $b in $expected, the method
46+
* asserts that any element of $a goes before any element of $b
47+
* in the sequence generated by $iterator
4848
*/
4949
protected function assertOrderedIteratorForGroups(array $expected, \Traversable $iterator)
5050
{

Tests/Iterator/MockSplFileInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct($param)
4444
$this->setRelativePath($defaults['relativePath']);
4545
$this->setRelativePathname($defaults['relativePathname']);
4646
} else {
47-
throw new \RuntimeException(sprintf('Incorrect parameter "%s"', $param));
47+
throw new \RuntimeException(\sprintf('Incorrect parameter "%s"', $param));
4848
}
4949
}
5050

Tests/Iterator/RecursiveDirectoryIteratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function testSeekOnFtp()
7070

7171
public function testTrailingDirectorySeparatorIsStripped()
7272
{
73-
$fixturesDirectory = __DIR__ . '/../Fixtures/';
73+
$fixturesDirectory = __DIR__.'/../Fixtures/';
7474
$actual = [];
7575

7676
foreach (new RecursiveDirectoryIterator($fixturesDirectory, RecursiveDirectoryIterator::SKIP_DOTS) as $file) {

Tests/Iterator/VfsIteratorTestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function setUp(): void
2929

3030
$this->vfsScheme = 'symfony-finder-vfs-test-'.++self::$vfsNextSchemeIndex;
3131

32-
$vfsWrapperClass = \get_class(new class() {
32+
$vfsWrapperClass = \get_class(new class {
3333
/** @var array<string, \Closure(string, 'list_dir_open'|'list_dir_rewind'|'is_dir'): (list<string>|bool)> */
3434
public static array $vfsProviders = [];
3535

0 commit comments

Comments
 (0)