From 78f640006c54c4e4ee2f676432acb78a853cc9f0 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Sun, 15 Jan 2023 18:57:26 +0100 Subject: [PATCH 1/6] [Tests] New iteration of removing `$this` occurrences in future static data providers --- Tests/Iterator/DateRangeFilterIteratorTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/Iterator/DateRangeFilterIteratorTest.php b/Tests/Iterator/DateRangeFilterIteratorTest.php index 2d8cfb30..5b237c9e 100644 --- a/Tests/Iterator/DateRangeFilterIteratorTest.php +++ b/Tests/Iterator/DateRangeFilterIteratorTest.php @@ -22,7 +22,7 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase public function testAccept($size, $expected) { $files = self::$files; - $files[] = self::toAbsolute('doesnotexist'); + $files[] = static::toAbsolute('doesnotexist'); $inner = new Iterator($files); $iterator = new DateRangeFilterIterator($inner, $size); @@ -84,9 +84,9 @@ public function getAcceptData() ]; return [ - [[new DateComparator('since 20 years ago')], $this->toAbsolute($since20YearsAgo)], - [[new DateComparator('since 2 months ago')], $this->toAbsolute($since2MonthsAgo)], - [[new DateComparator('until last month')], $this->toAbsolute($untilLastMonth)], + [[new DateComparator('since 20 years ago')], static::toAbsolute($since20YearsAgo)], + [[new DateComparator('since 2 months ago')], static::toAbsolute($since2MonthsAgo)], + [[new DateComparator('until last month')], static::toAbsolute($untilLastMonth)], ]; } } From 95bdff8d4bc61349c8d9b4b1dba02dadcb44a837 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 24 Jan 2023 15:02:24 +0100 Subject: [PATCH 2/6] Update license years (last time) --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 00837045..0138f8f0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +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 From c4b6c34ef83162cbfdc3bd18afd2d5a295af1fde Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Tue, 7 Feb 2023 21:09:05 +0100 Subject: [PATCH 3/6] [Tests] Migrate tests to static data providers --- Tests/Iterator/DepthRangeFilterIteratorTest.php | 8 ++++---- .../ExcludeDirectoryFilterIteratorTest.php | 6 +++--- Tests/Iterator/FileTypeFilterIteratorTest.php | 4 ++-- Tests/Iterator/SortableIteratorTest.php | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Tests/Iterator/DepthRangeFilterIteratorTest.php b/Tests/Iterator/DepthRangeFilterIteratorTest.php index a66e5028..c971ee9b 100644 --- a/Tests/Iterator/DepthRangeFilterIteratorTest.php +++ b/Tests/Iterator/DepthRangeFilterIteratorTest.php @@ -93,11 +93,11 @@ public function getAcceptData() ]; return [ - [0, 0, static::toAbsolute($lessThan1)], - [0, 1, static::toAbsolute($lessThanOrEqualTo1)], + [0, 0, self::toAbsolute($lessThan1)], + [0, 1, self::toAbsolute($lessThanOrEqualTo1)], [2, \PHP_INT_MAX, []], - [1, \PHP_INT_MAX, static::toAbsolute($graterThanOrEqualTo1)], - [1, 1, static::toAbsolute($equalTo1)], + [1, \PHP_INT_MAX, self::toAbsolute($graterThanOrEqualTo1)], + [1, 1, self::toAbsolute($equalTo1)], ]; } } diff --git a/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php b/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php index 572029a1..5299c93e 100644 --- a/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php +++ b/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php @@ -99,9 +99,9 @@ public function getAcceptData() ]; return [ - [['foo'], static::toAbsolute($foo)], - [['fo'], static::toAbsolute($fo)], - [['toto/'], static::toAbsolute($toto)], + [['foo'], self::toAbsolute($foo)], + [['fo'], self::toAbsolute($fo)], + [['toto/'], self::toAbsolute($toto)], ]; } } diff --git a/Tests/Iterator/FileTypeFilterIteratorTest.php b/Tests/Iterator/FileTypeFilterIteratorTest.php index be7beb1d..5a16774a 100644 --- a/Tests/Iterator/FileTypeFilterIteratorTest.php +++ b/Tests/Iterator/FileTypeFilterIteratorTest.php @@ -57,8 +57,8 @@ public function getAcceptData() ]; return [ - [FileTypeFilterIterator::ONLY_FILES, static::toAbsolute($onlyFiles)], - [FileTypeFilterIterator::ONLY_DIRECTORIES, static::toAbsolute($onlyDirectories)], + [FileTypeFilterIterator::ONLY_FILES, self::toAbsolute($onlyFiles)], + [FileTypeFilterIterator::ONLY_DIRECTORIES, self::toAbsolute($onlyDirectories)], ]; } } diff --git a/Tests/Iterator/SortableIteratorTest.php b/Tests/Iterator/SortableIteratorTest.php index 04996145..c6f8c307 100644 --- a/Tests/Iterator/SortableIteratorTest.php +++ b/Tests/Iterator/SortableIteratorTest.php @@ -247,13 +247,13 @@ public function getAcceptData() ]; return [ - [SortableIterator::SORT_BY_NAME, static::toAbsolute($sortByName)], - [SortableIterator::SORT_BY_TYPE, static::toAbsolute($sortByType)], - [SortableIterator::SORT_BY_ACCESSED_TIME, static::toAbsolute($sortByAccessedTime)], - [SortableIterator::SORT_BY_CHANGED_TIME, static::toAbsolute($sortByChangedTime)], - [SortableIterator::SORT_BY_MODIFIED_TIME, static::toAbsolute($sortByModifiedTime)], - [SortableIterator::SORT_BY_NAME_NATURAL, static::toAbsolute($sortByNameNatural)], - [function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, static::toAbsolute($customComparison)], + [SortableIterator::SORT_BY_NAME, self::toAbsolute($sortByName)], + [SortableIterator::SORT_BY_TYPE, self::toAbsolute($sortByType)], + [SortableIterator::SORT_BY_ACCESSED_TIME, self::toAbsolute($sortByAccessedTime)], + [SortableIterator::SORT_BY_CHANGED_TIME, self::toAbsolute($sortByChangedTime)], + [SortableIterator::SORT_BY_MODIFIED_TIME, self::toAbsolute($sortByModifiedTime)], + [SortableIterator::SORT_BY_NAME_NATURAL, self::toAbsolute($sortByNameNatural)], + [function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, self::toAbsolute($customComparison)], ]; } } From 144cb62b614fa73c3beb2b4cac542297bea5c66f Mon Sep 17 00:00:00 2001 From: Antoine Lamirault Date: Sat, 11 Feb 2023 19:34:13 +0100 Subject: [PATCH 4/6] Fix some phpdoc --- Comparator/NumberComparator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Comparator/NumberComparator.php b/Comparator/NumberComparator.php index ff85d967..dd308207 100644 --- a/Comparator/NumberComparator.php +++ b/Comparator/NumberComparator.php @@ -35,7 +35,7 @@ class NumberComparator extends Comparator { /** - * @param string|int $test A comparison string or an integer + * @param string|null $test A comparison string or null * * @throws \InvalidArgumentException If the test is not understood */ From e366fab251e6f45ca84c783ed35b2a6202068519 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 14 Dec 2022 15:42:16 +0100 Subject: [PATCH 5/6] Migrate to `static` data providers using `rector/rector` --- Tests/Comparator/ComparatorTest.php | 4 ++-- Tests/Comparator/DateComparatorTest.php | 2 +- Tests/Comparator/NumberComparatorTest.php | 4 ++-- Tests/FinderTest.php | 6 +++--- Tests/GitignoreTest.php | 4 ++-- Tests/Iterator/CustomFilterIteratorTest.php | 2 +- Tests/Iterator/DateRangeFilterIteratorTest.php | 2 +- Tests/Iterator/DepthRangeFilterIteratorTest.php | 2 +- Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php | 2 +- Tests/Iterator/FileTypeFilterIteratorTest.php | 2 +- Tests/Iterator/FilecontentFilterIteratorTest.php | 2 +- Tests/Iterator/FilenameFilterIteratorTest.php | 2 +- Tests/Iterator/MultiplePcreFilterIteratorTest.php | 2 +- Tests/Iterator/PathFilterIteratorTest.php | 2 +- Tests/Iterator/SizeRangeFilterIteratorTest.php | 2 +- Tests/Iterator/SortableIteratorTest.php | 2 +- Tests/Iterator/VcsIgnoredFilterIteratorTest.php | 2 +- 17 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Tests/Comparator/ComparatorTest.php b/Tests/Comparator/ComparatorTest.php index a04cc62f..aee59251 100644 --- a/Tests/Comparator/ComparatorTest.php +++ b/Tests/Comparator/ComparatorTest.php @@ -65,7 +65,7 @@ public function testTestSucceeds(string $operator, string $target, string $teste $this->assertTrue($c->test($testedValue)); } - public function provideMatches(): array + public static function provideMatches(): array { return [ ['<', '1000', '500'], @@ -91,7 +91,7 @@ public function testTestFails(string $operator, string $target, string $testedVa $this->assertFalse($c->test($testedValue)); } - public function provideNonMatches(): array + public static function provideNonMatches(): array { return [ ['>', '1000', '500'], diff --git a/Tests/Comparator/DateComparatorTest.php b/Tests/Comparator/DateComparatorTest.php index f89a1a28..47bcc483 100644 --- a/Tests/Comparator/DateComparatorTest.php +++ b/Tests/Comparator/DateComparatorTest.php @@ -49,7 +49,7 @@ public function testTest($test, $match, $noMatch) } } - public function getTestData() + public static function getTestData() { return [ ['< 2005-10-10', [strtotime('2005-10-09')], [strtotime('2005-10-15')]], diff --git a/Tests/Comparator/NumberComparatorTest.php b/Tests/Comparator/NumberComparatorTest.php index 6458133e..60c5f1c6 100644 --- a/Tests/Comparator/NumberComparatorTest.php +++ b/Tests/Comparator/NumberComparatorTest.php @@ -51,7 +51,7 @@ public function testTest($test, $match, $noMatch) } } - public function getTestData() + public static function getTestData() { return [ ['< 1000', ['500', '999'], ['1000', '1500']], @@ -81,7 +81,7 @@ public function getTestData() ]; } - public function getConstructorTestData() + public static function getConstructorTestData() { return [ [ diff --git a/Tests/FinderTest.php b/Tests/FinderTest.php index 7a79c5e8..183a09cf 100644 --- a/Tests/FinderTest.php +++ b/Tests/FinderTest.php @@ -1274,7 +1274,7 @@ public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartF $this->assertIterator($this->toAbsoluteFixtures($expected), $finder); } - public function getContainsTestData() + public static function getContainsTestData() { return [ ['', '', []], @@ -1292,7 +1292,7 @@ public function getContainsTestData() ]; } - public function getRegexNameTestData() + public static function getRegexNameTestData() { return [ ['~.*t\\.p.+~i'], @@ -1313,7 +1313,7 @@ public function testPath($matchPatterns, $noMatchPatterns, array $expected) $this->assertIterator($this->toAbsoluteFixtures($expected), $finder); } - public function getTestPathData() + public static function getTestPathData() { return [ ['', '', []], diff --git a/Tests/GitignoreTest.php b/Tests/GitignoreTest.php index 65b52057..574e9f32 100644 --- a/Tests/GitignoreTest.php +++ b/Tests/GitignoreTest.php @@ -392,7 +392,7 @@ public static function provider(): array return $cases; } - public function providerExtended(): array + public static function providerExtended(): array { $basicCases = self::provider(); @@ -479,7 +479,7 @@ public function testToRegexMatchingNegatedPatterns(array $gitignoreLines, array } } - public function provideNegatedPatternsCases(): iterable + public static function provideNegatedPatternsCases(): iterable { yield [ [''], diff --git a/Tests/Iterator/CustomFilterIteratorTest.php b/Tests/Iterator/CustomFilterIteratorTest.php index 7c3c65ce..3b1f662e 100644 --- a/Tests/Iterator/CustomFilterIteratorTest.php +++ b/Tests/Iterator/CustomFilterIteratorTest.php @@ -33,7 +33,7 @@ public function testAccept($filters, $expected) $this->assertIterator($expected, $iterator); } - public function getAcceptData() + public static function getAcceptData() { return [ [[function (\SplFileInfo $fileinfo) { return false; }], []], diff --git a/Tests/Iterator/DateRangeFilterIteratorTest.php b/Tests/Iterator/DateRangeFilterIteratorTest.php index 5b237c9e..b02d8f4f 100644 --- a/Tests/Iterator/DateRangeFilterIteratorTest.php +++ b/Tests/Iterator/DateRangeFilterIteratorTest.php @@ -30,7 +30,7 @@ public function testAccept($size, $expected) $this->assertIterator($expected, $iterator); } - public function getAcceptData() + public static function getAcceptData() { $since20YearsAgo = [ '.git', diff --git a/Tests/Iterator/DepthRangeFilterIteratorTest.php b/Tests/Iterator/DepthRangeFilterIteratorTest.php index c971ee9b..c90df8ec 100644 --- a/Tests/Iterator/DepthRangeFilterIteratorTest.php +++ b/Tests/Iterator/DepthRangeFilterIteratorTest.php @@ -30,7 +30,7 @@ public function testAccept($minDepth, $maxDepth, $expected) $this->assertEquals($expected, $actual); } - public function getAcceptData() + public static function getAcceptData() { $lessThan1 = [ '.git', diff --git a/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php b/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php index 5299c93e..9b5ed98a 100644 --- a/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php +++ b/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php @@ -28,7 +28,7 @@ public function testAccept($directories, $expected) $this->assertIterator($expected, $iterator); } - public function getAcceptData() + public static function getAcceptData() { $foo = [ '.bar', diff --git a/Tests/Iterator/FileTypeFilterIteratorTest.php b/Tests/Iterator/FileTypeFilterIteratorTest.php index 5a16774a..3ed1cc06 100644 --- a/Tests/Iterator/FileTypeFilterIteratorTest.php +++ b/Tests/Iterator/FileTypeFilterIteratorTest.php @@ -27,7 +27,7 @@ public function testAccept($mode, $expected) $this->assertIterator($expected, $iterator); } - public function getAcceptData() + public static function getAcceptData() { $onlyFiles = [ 'test.py', diff --git a/Tests/Iterator/FilecontentFilterIteratorTest.php b/Tests/Iterator/FilecontentFilterIteratorTest.php index f4f70c8e..34ba50dd 100644 --- a/Tests/Iterator/FilecontentFilterIteratorTest.php +++ b/Tests/Iterator/FilecontentFilterIteratorTest.php @@ -45,7 +45,7 @@ public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatc $this->assertIterator($resultArray, $iterator); } - public function getTestFilterData() + public static function getTestFilterData() { $inner = new MockFileListIterator(); diff --git a/Tests/Iterator/FilenameFilterIteratorTest.php b/Tests/Iterator/FilenameFilterIteratorTest.php index a12072c6..db4eb2b9 100644 --- a/Tests/Iterator/FilenameFilterIteratorTest.php +++ b/Tests/Iterator/FilenameFilterIteratorTest.php @@ -27,7 +27,7 @@ public function testAccept($matchPatterns, $noMatchPatterns, $expected) $this->assertIterator($expected, $iterator); } - public function getAcceptData() + public static function getAcceptData() { return [ [['test.*'], [], ['test.php', 'test.py']], diff --git a/Tests/Iterator/MultiplePcreFilterIteratorTest.php b/Tests/Iterator/MultiplePcreFilterIteratorTest.php index e1bd835b..e6abf944 100644 --- a/Tests/Iterator/MultiplePcreFilterIteratorTest.php +++ b/Tests/Iterator/MultiplePcreFilterIteratorTest.php @@ -25,7 +25,7 @@ public function testIsRegex($string, $isRegex, $message) $this->assertEquals($isRegex, $testIterator->isRegex($string), $message); } - public function getIsRegexFixtures() + public static function getIsRegexFixtures() { yield ['foo', false, 'string']; yield [' foo ', false, '" " is not a valid delimiter']; diff --git a/Tests/Iterator/PathFilterIteratorTest.php b/Tests/Iterator/PathFilterIteratorTest.php index e2c13252..5c0663e5 100644 --- a/Tests/Iterator/PathFilterIteratorTest.php +++ b/Tests/Iterator/PathFilterIteratorTest.php @@ -24,7 +24,7 @@ public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatc $this->assertIterator($resultArray, $iterator); } - public function getTestFilterData() + public static function getTestFilterData() { $inner = new MockFileListIterator(); diff --git a/Tests/Iterator/SizeRangeFilterIteratorTest.php b/Tests/Iterator/SizeRangeFilterIteratorTest.php index 25a6b8a2..e5f3b6a1 100644 --- a/Tests/Iterator/SizeRangeFilterIteratorTest.php +++ b/Tests/Iterator/SizeRangeFilterIteratorTest.php @@ -28,7 +28,7 @@ public function testAccept($size, $expected) $this->assertIterator($expected, $iterator); } - public function getAcceptData() + public static function getAcceptData() { $lessThan1KGreaterThan05K = [ '.foo', diff --git a/Tests/Iterator/SortableIteratorTest.php b/Tests/Iterator/SortableIteratorTest.php index c6f8c307..a4f13fee 100644 --- a/Tests/Iterator/SortableIteratorTest.php +++ b/Tests/Iterator/SortableIteratorTest.php @@ -68,7 +68,7 @@ public function testAccept($mode, $expected) } } - public function getAcceptData() + public static function getAcceptData() { $sortByName = [ '.bar', diff --git a/Tests/Iterator/VcsIgnoredFilterIteratorTest.php b/Tests/Iterator/VcsIgnoredFilterIteratorTest.php index 14cb3c44..61da148d 100644 --- a/Tests/Iterator/VcsIgnoredFilterIteratorTest.php +++ b/Tests/Iterator/VcsIgnoredFilterIteratorTest.php @@ -59,7 +59,7 @@ public function testAccept(array $gitIgnoreFiles, array $otherFileNames, array $ $this->assertIterator($this->toAbsolute($expectedResult), $iterator); } - public function getAcceptData(): iterable + public static function getAcceptData(): iterable { yield 'simple file' => [ [ From 078e9a5e1871fcfe6a5ce421b539344c21afef19 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 16 Feb 2023 10:33:00 +0100 Subject: [PATCH 6/6] CS fix --- Iterator/ExcludeDirectoryFilterIterator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Iterator/ExcludeDirectoryFilterIterator.php b/Iterator/ExcludeDirectoryFilterIterator.php index d9e182c1..39797c82 100644 --- a/Iterator/ExcludeDirectoryFilterIterator.php +++ b/Iterator/ExcludeDirectoryFilterIterator.php @@ -17,6 +17,7 @@ * @author Fabien Potencier * * @extends \FilterIterator + * * @implements \RecursiveIterator */ class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator