From 4d2580c0dd97c775fbc5c1f399b60a44992b9d67 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Thu, 10 Jun 2021 09:06:30 +0200 Subject: [PATCH 01/13] [Finder] Add support of no-capture regex modifier in MultiplePcreFilterIterator (available from PHP 8.2) [Finder] Add support of no-capture regex modifier in MultiplePcreFilterIterator (available from PHP 8.2) --- Iterator/MultiplePcreFilterIterator.php | 8 +++- .../MultiplePcreFilterIteratorTest.php | 38 ++++++++++--------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Iterator/MultiplePcreFilterIterator.php b/Iterator/MultiplePcreFilterIterator.php index 18b082ec..e185d130 100644 --- a/Iterator/MultiplePcreFilterIterator.php +++ b/Iterator/MultiplePcreFilterIterator.php @@ -83,7 +83,13 @@ protected function isAccepted($string) */ protected function isRegex($str) { - if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) { + $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); diff --git a/Tests/Iterator/MultiplePcreFilterIteratorTest.php b/Tests/Iterator/MultiplePcreFilterIteratorTest.php index 590aea21..157c647e 100644 --- a/Tests/Iterator/MultiplePcreFilterIteratorTest.php +++ b/Tests/Iterator/MultiplePcreFilterIteratorTest.php @@ -27,24 +27,26 @@ public function testIsRegex($string, $isRegex, $message) public function getIsRegexFixtures() { - return [ - ['foo', false, 'string'], - [' foo ', false, '" " is not a valid delimiter'], - ['\\foo\\', false, '"\\" is not a valid delimiter'], - ['afooa', false, '"a" is not a valid delimiter'], - ['//', false, 'the pattern should contain at least 1 character'], - ['/a/', true, 'valid regex'], - ['/foo/', true, 'valid regex'], - ['/foo/i', true, 'valid regex with a single modifier'], - ['/foo/imsxu', true, 'valid regex with multiple modifiers'], - ['#foo#', true, '"#" is a valid delimiter'], - ['{foo}', true, '"{,}" is a valid delimiter pair'], - ['[foo]', true, '"[,]" is a valid delimiter pair'], - ['(foo)', true, '"(,)" is a valid delimiter pair'], - ['', true, '"<,>" is a valid delimiter pair'], - ['*foo.*', false, '"*" is not considered as a valid delimiter'], - ['?foo.?', false, '"?" is not considered as a valid delimiter'], - ]; + yield ['foo', false, 'string']; + yield [' foo ', false, '" " is not a valid delimiter']; + yield ['\\foo\\', false, '"\\" is not a valid delimiter']; + yield ['afooa', false, '"a" is not a valid delimiter']; + yield ['//', false, 'the pattern should contain at least 1 character']; + yield ['/a/', true, 'valid regex']; + yield ['/foo/', true, 'valid regex']; + yield ['/foo/i', true, 'valid regex with a single modifier']; + yield ['/foo/imsxu', true, 'valid regex with multiple modifiers']; + yield ['#foo#', true, '"#" is a valid delimiter']; + yield ['{foo}', true, '"{,}" is a valid delimiter pair']; + yield ['[foo]', true, '"[,]" is a valid delimiter pair']; + yield ['(foo)', true, '"(,)" is a valid delimiter pair']; + yield ['', true, '"<,>" is a valid delimiter pair']; + yield ['*foo.*', false, '"*" is not considered as a valid delimiter']; + yield ['?foo.?', false, '"?" is not considered as a valid delimiter']; + + if (\PHP_VERSION_ID >= 80200) { + yield ['/foo/n', true, 'valid regex with the no-capture modifier']; + } } } From 029e52c3f963d126231be67a213312a05652665e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Tue, 12 Apr 2022 17:18:48 +0200 Subject: [PATCH 02/13] Add missing license header --- Tests/GitignoreTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/GitignoreTest.php b/Tests/GitignoreTest.php index 3fa01048..0297bc0c 100644 --- a/Tests/GitignoreTest.php +++ b/Tests/GitignoreTest.php @@ -1,4 +1,5 @@ Date: Mon, 27 Jun 2022 15:16:42 +0200 Subject: [PATCH 03/13] CS fixes --- Tests/FinderTest.php | 4 ++-- Tests/GitignoreTest.php | 2 +- Tests/Iterator/PathFilterIteratorTest.php | 12 ++++++------ Tests/Iterator/RealIteratorTestCase.php | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tests/FinderTest.php b/Tests/FinderTest.php index 4fb1cb4d..562dce70 100644 --- a/Tests/FinderTest.php +++ b/Tests/FinderTest.php @@ -1344,12 +1344,12 @@ public function getTestPathData() ], ['A/B', 'foobar', [ - //dirs + // dirs 'A'.\DIRECTORY_SEPARATOR.'B', 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C', 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'B', 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C', - //files + // files 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat', 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C'.\DIRECTORY_SEPARATOR.'abc.dat', 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat.copy', diff --git a/Tests/GitignoreTest.php b/Tests/GitignoreTest.php index 0297bc0c..b05663c3 100644 --- a/Tests/GitignoreTest.php +++ b/Tests/GitignoreTest.php @@ -349,7 +349,7 @@ public function provider(): array 'logs/', '!logs/important.log', ], - ['logs/debug.log'/* must be pruned on traversal 'logs/important.log'*/], + ['logs/debug.log'/* must be pruned on traversal 'logs/important.log' */], [], ], [ diff --git a/Tests/Iterator/PathFilterIteratorTest.php b/Tests/Iterator/PathFilterIteratorTest.php index 9040ee04..e2c13252 100644 --- a/Tests/Iterator/PathFilterIteratorTest.php +++ b/Tests/Iterator/PathFilterIteratorTest.php @@ -28,37 +28,37 @@ public function getTestFilterData() { $inner = new MockFileListIterator(); - //PATH: A/B/C/abc.dat + // PATH: A/B/C/abc.dat $inner[] = new MockSplFileInfo([ 'name' => 'abc.dat', 'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C'.\DIRECTORY_SEPARATOR.'abc.dat', ]); - //PATH: A/B/ab.dat + // PATH: A/B/ab.dat $inner[] = new MockSplFileInfo([ 'name' => 'ab.dat', 'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat', ]); - //PATH: A/a.dat + // PATH: A/a.dat $inner[] = new MockSplFileInfo([ 'name' => 'a.dat', 'relativePathname' => 'A'.\DIRECTORY_SEPARATOR.'a.dat', ]); - //PATH: copy/A/B/C/abc.dat.copy + // PATH: copy/A/B/C/abc.dat.copy $inner[] = new MockSplFileInfo([ 'name' => 'abc.dat.copy', 'relativePathname' => 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C'.\DIRECTORY_SEPARATOR.'abc.dat', ]); - //PATH: copy/A/B/ab.dat.copy + // PATH: copy/A/B/ab.dat.copy $inner[] = new MockSplFileInfo([ 'name' => 'ab.dat.copy', 'relativePathname' => 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat', ]); - //PATH: copy/A/a.dat.copy + // PATH: copy/A/a.dat.copy $inner[] = new MockSplFileInfo([ 'name' => 'a.dat.copy', 'relativePathname' => 'copy'.\DIRECTORY_SEPARATOR.'A'.\DIRECTORY_SEPARATOR.'a.dat', diff --git a/Tests/Iterator/RealIteratorTestCase.php b/Tests/Iterator/RealIteratorTestCase.php index b43f900c..d92a11dc 100644 --- a/Tests/Iterator/RealIteratorTestCase.php +++ b/Tests/Iterator/RealIteratorTestCase.php @@ -72,9 +72,9 @@ public static function setUpBeforeClass(): void public static function tearDownAfterClass(): void { $paths = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator(self::$tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS), - \RecursiveIteratorIterator::CHILD_FIRST - ); + new \RecursiveDirectoryIterator(self::$tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS), + \RecursiveIteratorIterator::CHILD_FIRST + ); foreach ($paths as $path) { if ($path->isDir()) { From 66bd787edb5e42ff59d3523f623895af05043e4f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 29 Jul 2022 09:35:46 +0200 Subject: [PATCH 04/13] [HttpKernel] Fix test sensitivity on xdebug.file_link_format --- Tests/Fixtures/gitignore/search_root/a.txt | 0 Tests/Fixtures/gitignore/search_root/c.txt | 0 Tests/Fixtures/gitignore/search_root/dir/b.txt | 0 Tests/Fixtures/gitignore/search_root/dir/c.txt | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Tests/Fixtures/gitignore/search_root/a.txt create mode 100644 Tests/Fixtures/gitignore/search_root/c.txt create mode 100644 Tests/Fixtures/gitignore/search_root/dir/b.txt create mode 100644 Tests/Fixtures/gitignore/search_root/dir/c.txt diff --git a/Tests/Fixtures/gitignore/search_root/a.txt b/Tests/Fixtures/gitignore/search_root/a.txt new file mode 100644 index 00000000..e69de29b diff --git a/Tests/Fixtures/gitignore/search_root/c.txt b/Tests/Fixtures/gitignore/search_root/c.txt new file mode 100644 index 00000000..e69de29b diff --git a/Tests/Fixtures/gitignore/search_root/dir/b.txt b/Tests/Fixtures/gitignore/search_root/dir/b.txt new file mode 100644 index 00000000..e69de29b diff --git a/Tests/Fixtures/gitignore/search_root/dir/c.txt b/Tests/Fixtures/gitignore/search_root/dir/c.txt new file mode 100644 index 00000000..e69de29b From 40c08632019838dfb3350f18cf5563b8080055fc Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 20 Dec 2022 09:01:19 +0100 Subject: [PATCH 05/13] Use static methods inside data providers --- Tests/GitignoreTest.php | 4 ++-- Tests/Iterator/SizeRangeFilterIteratorTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/GitignoreTest.php b/Tests/GitignoreTest.php index 63f3b76c..65b52057 100644 --- a/Tests/GitignoreTest.php +++ b/Tests/GitignoreTest.php @@ -55,7 +55,7 @@ public function testToRegex(array $gitignoreLines, array $matchingCases, array $ } } - public function provider(): array + public static function provider(): array { $cases = [ [ @@ -394,7 +394,7 @@ public function provider(): array public function providerExtended(): array { - $basicCases = $this->provider(); + $basicCases = self::provider(); $cases = []; foreach ($basicCases as $case) { diff --git a/Tests/Iterator/SizeRangeFilterIteratorTest.php b/Tests/Iterator/SizeRangeFilterIteratorTest.php index 129d565d..25a6b8a2 100644 --- a/Tests/Iterator/SizeRangeFilterIteratorTest.php +++ b/Tests/Iterator/SizeRangeFilterIteratorTest.php @@ -41,7 +41,7 @@ public function getAcceptData() ]; return [ - [[new NumberComparator('< 1K'), new NumberComparator('> 0.5K')], $this->toAbsolute($lessThan1KGreaterThan05K)], + [[new NumberComparator('< 1K'), new NumberComparator('> 0.5K')], self::toAbsolute($lessThan1KGreaterThan05K)], ]; } } From 73bde8847fb5fda460eef5d13a82afd425d36b24 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 1 Jan 2023 09:32:19 +0100 Subject: [PATCH 06/13] Bump license year to 2023 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 88bf75bb..00837045 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2022 Fabien Potencier +Copyright (c) 2004-2023 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 6071aebf810ad13fe8200c224f36103abb37cf1f Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Sat, 14 Jan 2023 17:44:03 +0100 Subject: [PATCH 07/13] [Tests] Remove `$this` occurrences in future 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 b2a5303b..a66e5028 100644 --- a/Tests/Iterator/DepthRangeFilterIteratorTest.php +++ b/Tests/Iterator/DepthRangeFilterIteratorTest.php @@ -93,11 +93,11 @@ public function getAcceptData() ]; return [ - [0, 0, $this->toAbsolute($lessThan1)], - [0, 1, $this->toAbsolute($lessThanOrEqualTo1)], + [0, 0, static::toAbsolute($lessThan1)], + [0, 1, static::toAbsolute($lessThanOrEqualTo1)], [2, \PHP_INT_MAX, []], - [1, \PHP_INT_MAX, $this->toAbsolute($graterThanOrEqualTo1)], - [1, 1, $this->toAbsolute($equalTo1)], + [1, \PHP_INT_MAX, static::toAbsolute($graterThanOrEqualTo1)], + [1, 1, static::toAbsolute($equalTo1)], ]; } } diff --git a/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php b/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php index 1729766f..572029a1 100644 --- a/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php +++ b/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php @@ -99,9 +99,9 @@ public function getAcceptData() ]; return [ - [['foo'], $this->toAbsolute($foo)], - [['fo'], $this->toAbsolute($fo)], - [['toto/'], $this->toAbsolute($toto)], + [['foo'], static::toAbsolute($foo)], + [['fo'], static::toAbsolute($fo)], + [['toto/'], static::toAbsolute($toto)], ]; } } diff --git a/Tests/Iterator/FileTypeFilterIteratorTest.php b/Tests/Iterator/FileTypeFilterIteratorTest.php index e15c0352..be7beb1d 100644 --- a/Tests/Iterator/FileTypeFilterIteratorTest.php +++ b/Tests/Iterator/FileTypeFilterIteratorTest.php @@ -57,8 +57,8 @@ public function getAcceptData() ]; return [ - [FileTypeFilterIterator::ONLY_FILES, $this->toAbsolute($onlyFiles)], - [FileTypeFilterIterator::ONLY_DIRECTORIES, $this->toAbsolute($onlyDirectories)], + [FileTypeFilterIterator::ONLY_FILES, static::toAbsolute($onlyFiles)], + [FileTypeFilterIterator::ONLY_DIRECTORIES, static::toAbsolute($onlyDirectories)], ]; } } diff --git a/Tests/Iterator/SortableIteratorTest.php b/Tests/Iterator/SortableIteratorTest.php index 098cd756..04996145 100644 --- a/Tests/Iterator/SortableIteratorTest.php +++ b/Tests/Iterator/SortableIteratorTest.php @@ -247,13 +247,13 @@ public function getAcceptData() ]; return [ - [SortableIterator::SORT_BY_NAME, $this->toAbsolute($sortByName)], - [SortableIterator::SORT_BY_TYPE, $this->toAbsolute($sortByType)], - [SortableIterator::SORT_BY_ACCESSED_TIME, $this->toAbsolute($sortByAccessedTime)], - [SortableIterator::SORT_BY_CHANGED_TIME, $this->toAbsolute($sortByChangedTime)], - [SortableIterator::SORT_BY_MODIFIED_TIME, $this->toAbsolute($sortByModifiedTime)], - [SortableIterator::SORT_BY_NAME_NATURAL, $this->toAbsolute($sortByNameNatural)], - [function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, $this->toAbsolute($customComparison)], + [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)], ]; } } From 78f640006c54c4e4ee2f676432acb78a853cc9f0 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Sun, 15 Jan 2023 18:57:26 +0100 Subject: [PATCH 08/13] [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 09/13] 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 10/13] [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 11/13] 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 12/13] 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 13/13] 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