8000 [Finder] Add types to constructors and private/final/internal methods. · symfony/symfony@59a58b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 59a58b1

Browse files
committed
[Finder] Add types to constructors and private/final/internal methods.
1 parent febb0b5 commit 59a58b1

18 files changed

+48
-48
lines changed

src/Symfony/Component/Finder/Tests/Comparator/ComparatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testGetSetTarget()
4141
/**
4242
* @dataProvider getTestData
4343
*/
44-
public function testTest($operator, $target, $match, $noMatch)
44+
public function testTest(string $operator, string $target, array $match, array $noMatch)
4545
{
4646
$c = new Comparator();
4747
$c->setOperator($operator);
@@ -56,7 +56,7 @@ public function testTest($operator, $target, $match, $noMatch)
5656
}
5757
}
5858

59-
public function getTestData()
59+
public function getTestData(): array
6060
{
6161
return [
6262
['<', '1000', ['500', '999'], ['1000', '1500']],

src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testConstructor()
3636
/**
3737
* @dataProvider getTestData
3838
*/
39-
public function testTest($test, $match, $noMatch)
39+
public function testTest(string $test, array $match, array $noMatch)
4040
{
4141
$c = new DateComparator($test);
4242

@@ -49,7 +49,7 @@ public function testTest($test, $match, $noMatch)
4949
}
5050
}
5151

52-
public function getTestData()
52+
public function getTestData(): array
5353
{
5454
return [
5555
['< 2005-10-10', [strtotime('2005-10-09')], [strtotime('2005-10-15')]],

src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class NumberComparatorTest extends TestCase
1919
/**
2020
* @dataProvider getConstructorTestData
2121
*/
22-
public function testConstructor($successes, $failures)
22+
public function testConstructor(array $successes, array $failures)
2323
{
2424
foreach ($successes as $s) {
2525
new NumberComparator($s);
@@ -38,7 +38,7 @@ public function testConstructor($successes, $failures)
3838
/**
3939
* @dataProvider getTestData
4040
*/
41-
public function testTest($test, $match, $noMatch)
41+
public function testTest(string $test, array $match, array $noMatch)
4242
{
4343
$c = new NumberComparator($test);
4444

@@ -51,7 +51,7 @@ public function testTest($test, $match, $noMatch)
5151
}
5252
}
5353

54-
public function getTestData()
54+
public function getTestData(): array
5555
{
5656
return [
5757
['< 1000', ['500', '999'], ['1000', '1500']],
@@ -81,7 +81,7 @@ public function getTestData()
8181
];
8282
}
8383

84-
public function getConstructorTestData()
84+
public function getConstructorTestData(): array
8585
{
8686
return [
8787
[

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public function testNotNameWithArrayParam()
283283
/**
284284
* @dataProvider getRegexNameTestData
285285
*/
286-
public function testRegexName($regex)
286+
public function testRegexName(string $regex)
287287
{
288288
$finder = $this->buildFinder();
289289
$finder->name($regex);
@@ -1133,7 +1133,7 @@ public function testNoResults()
11331133
/**
11341134
* @dataProvider getContainsTestData
11351135
*/
1136-
public function testContains($matchPatterns, $noMatchPatterns, $expected)
1136+
public function testContains($matchPatterns, $noMatchPatterns, array $expected)
11371137
{
11381138
$finder = $this->buildFinder();
11391139
$finder->in(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures')
@@ -1235,7 +1235,7 @@ public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartF
12351235
$this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
12361236
}
12371237

1238-
public function getContainsTestData()
1238+
public function getContainsTestData(): array
12391239
{
12401240
return [
12411241
['', '', []],
@@ -1253,7 +1253,7 @@ public function getContainsTestData()
12531253
];
12541254
}
12551255

1256-
public function getRegexNameTestData()
1256+
public function getRegexNameTestData(): array
12571257
{
12581258
return [
12591259
['~.*t\\.p.+~i'],
@@ -1274,7 +1274,7 @@ public function testPath($matchPatterns, $noMatchPatterns, array $expected)
12741274
$this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
12751275
}
12761276

1277-
public function getTestPathData()
1277+
public function getTestPathData(): array
12781278
{
12791279
return [
12801280
['', '', []],
@@ -1431,7 +1431,7 @@ public function testInheritedClassCallSortByNameWithNoArguments()
14311431
$finderChild->sortByName();
14321432
}
14331433

1434-
protected function buildFinder()
1434+
private function buildFinder(): Finder
14351435
{
14361436
return Finder::create();
14371437
}

src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testWithInvalidFilter()
2424
/**
2525
* @dataProvider getAcceptData
2626
*/
27-
public function testAccept($filters, $expected)
27+
public function testAccept(array $filters, array $expected)
2828
{
2929
$inner = new Iterator(['test.php', 'test.py', 'foo.php']);
3030

@@ -33,7 +33,7 @@ public function testAccept($filters, $expected)
3333
$this->assertIterator($expected, $iterator);
3434
}
3535

36-
public function getAcceptData()
36+
public function getAcceptData(): array
3737
{
3838
return [
3939
[[function (\SplFileInfo $fileinfo) { return false; }], []],

src/Symfony/Component/Finder/Tests/Iterator/DateRangeFilterIteratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase
1919
/**
2020
* @dataProvider getAcceptData
2121
*/
22-
public function testAccept($size, $expected)
22+
public function testAccept(array $size, array $expected)
2323
{
2424
$files = self::$files;
2525
$files[] = self::toAbsolute('doesnotexist');
@@ -30,7 +30,7 @@ public function testAccept($size, $expected)
3030
$this->assertIterator($expected, $iterator);
3131
}
3232

33-
public function getAcceptData()
33+
public function getAcceptData(): array
3434
{
3535
$since20YearsAgo = [
3636
'.git',

src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
1818
/**
1919
* @dataProvider getAcceptData
2020
*/
21-
public function testAccept($minDepth, $maxDepth, $expected)
21+
public function testAccept(int $minDepth, int $maxDepth, array $expected)
2222
{
2323
$inner = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
2424

@@ -30,7 +30,7 @@ public function testAccept($minDepth, $maxDepth, $expected)
3030
$this->assertEquals($expected, $actual);
3131
}
3232

33-
public function getAcceptData()
33+
public function getAcceptData(): array
3434
{
3535
$lessThan1 = [
3636
'.gitignore',

src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
1919
/**
2020
* @dataProvider getAcceptData
2121
*/
22-
public function testAccept($directories, $expected)
22+
public function testAccept(array $directories, array $expected)
2323
{
2424
$inner = new \RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
2525

@@ -28,7 +28,7 @@ public function testAccept($directories, $expected)
2828
$this->assertIterator($expected, $iterator);
2929
}
3030

31-
public function getAcceptData()
31+
public function getAcceptData(): array
3232
{
3333
$foo = [
3434
'.gitignore',

src/Symfony/Component/Finder/Tests/Iterator/FileTypeFilterIteratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class FileTypeFilterIteratorTest extends RealIteratorTestCase
1818
/**
1919
* @dataProvider getAcceptData
2020
*/
21-
public function testAccept($mode, $expected)
21+
public function testAccept(int $mode, array $expected)
2222
{
2323
$inner = new InnerTypeIterator(self::$files);
2424

@@ -27,7 +27,7 @@ public function testAccept($mode, $expected)
2727
$this->assertIterator($expected, $iterator);
2828
}
2929

30-
public function getAcceptData()
30+
public function getAcceptData(): array
3131
{
3232
$onlyFiles = [
3333
'test.py',

src/Symfony/Component/Finder/Tests/Iterator/FilecontentFilterIteratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatc
4545
$this->assertIterator($resultArray, $iterator);
4646
}
4747

48-
public function getTestFilterData()
48+
public function getTestFilterData(): array
4949
{
5050
$inner = new MockFileListIterator();
5151

src/Symfony/Component/Finder/Tests/Iterator/FilenameFilterIteratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class FilenameFilterIteratorTest extends IteratorTestCase
1818
/**
1919
* @dataProvider getAcceptData
2020
*/
21-
public function testAccept($matchPatterns, $noMatchPatterns, $expected)
21+
public function testAccept(array $matchPatterns, array $noMatchPatterns, array $expected)
2222
{
2323
$inner = new InnerNameIterator(['test.php', 'test.py', 'foo.php']);
2424

@@ -27,7 +27,7 @@ public function testAccept($matchPatterns, $noMatchPatterns, $expected)
2727
$this->assertIterator($expected, $iterator);
2828
}
2929

30-
public function getAcceptData()
30+
public function getAcceptData(): array
3131
{
3232
return [
3333
[['test.*'], [], ['test.php', 'test.py']],

src/Symfony/Component/Finder/Tests/Iterator/IteratorTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
abstract class IteratorTestCase extends TestCase
1717
{
18-
protected function assertIterator($expected, \Traversable $iterator)
18+
protected function assertIterator(array $expected, \Traversable $iterator)
1919
{
2020
// set iterator_to_array $use_key to false to avoid values merge
2121
// this made FinderTest::testAppendWithAnArray() fail with GnuFinderAdapter
@@ -29,7 +29,7 @@ protected function assertIterator($expected, \Traversable $iterator)
2929
$this->assertEquals($expected, array_values($values));
3030
}
3131

32-
protected function assertOrderedIterator($expected, \Traversable $iterator)
32+
protected function assertOrderedIterator(array $expected, \Traversable $iterator)
3333
{
3434
$values = array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator));
3535

src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct($param)
4848
}
4949
}
5050

51-
public function isFile()
51+
public function isFile(): bool
5252
{
5353
if (null === $this->type) {
5454
return false !== strpos($this->getFilename(), 'file');
@@ -57,7 +57,7 @@ public function isFile()
5757
return self::TYPE_FILE === $this->type;
5858
}
5959

60-
public function isDir()
60+
public function isDir(): bool
6161
{
6262
if (null === $this->type) {
6363
return false !== strpos($this->getFilename(), 'directory');
@@ -66,7 +66,7 @@ public function isDir()
6666
return self::TYPE_DIRECTORY === $this->type;
6767
}
6868

69-
public function isReadable()
69+
public function isReadable(): bool
7070
{
7171
if (null === $this->mode) {
7272
return preg_match('/r\+/', $this->getFilename());
@@ -75,22 +75,22 @@ public function isReadable()
7575
return preg_match('/r\+/', $this->mode);
7676
}
7777

78-
public function getContents()
78+
public function getContents(): ?string
7979
{
8080
return $this->contents;
8181
}
8282

83-
public function setContents($contents)
83+
public function setContents(?string $contents)
8484
{
8585
$this->contents = $contents;
8686
}
8787

88-
public function setMode($mode)
88+
public function setMode(?string $mode)
8989
{
9090
$this->mode = $mode;
9191
}
9292

93-
public function setType($type)
93+
public function setType(?string $type)
9494
{
9595
if (\is_string($type)) {
9696
switch ($type) {
@@ -110,22 +110,22 @@ public function setType($type)
110110
}
111111
}
112112

113-
public function setRelativePath($relativePath)
113+
public function setRelativePath(?string $relativePath)
114114
{
115115
$this->relativePath = $relativePath;
116116
}
117117

118-
public function setRelativePathname($relativePathname)
118+
public function setRelativePathname(?string $relativePathname)
119119
{
120120
$this->relativePathname = $relativePathname;
121121
}
122122

123-
public function getRelativePath()
123+
public function getRelativePath(): ?string
124124
{
125125
return $this->relativePath;
126126
}
127127

128-
public function getRelativePathname()
128+
public function getRelativePathname(): ?string
129129
{
130130
return $this->relativePathname;
131131
}

src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ class MultiplePcreFilterIteratorTest extends TestCase
1919
/**
2020
* @dataProvider getIsRegexFixtures
2121
*/
22-
public function testIsRegex($string, $isRegex, $message)
22+
public function testIsRegex(string $string, bool $isRegex, string $message)
2323
{
2424
$testIterator = new TestMultiplePcreFilterIterator();
2525
$this->assertEquals($isRegex, $testIterator->isRegex($string), $message);
2626
}
2727

28-
public function getIsRegexFixtures()
28+
public function getIsRegexFixtures(): array
2929
{
3030
return [
3131
['foo', false, 'string'],

src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatc
2424
$this->assertIterator($resultArray, $iterator);
2525
}
2626

27-
public function getTestFilterData()
27+
public function getTestFilterData(): array
2828
{
2929
$inner = new MockFileListIterator();
3030

src/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ protected static function toAbsolute($files = null)
118118
return self::$tmpDir;
119119
}
120120

121-
protected static function toAbsoluteFixtures($files)
121+
protected static function toAbsoluteFixtures(array $files): array
122122
{
123123
$f = [];
124124
foreach ($files as $file) {

src/Symfony/Component/Finder/Tests/Iterator/SizeRangeFilterIteratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SizeRangeFilterIteratorTest extends RealIteratorTestCase
1919
/**
2020
* @dataProvider getAcceptData
2121
*/
22-
public function testAccept($size, $expected)
22+
public function testAccept(array $size, array $expected)
2323
{
2424
$inner = new InnerSizeIterator(self::$files);
2525

@@ -28,7 +28,7 @@ public function testAccept($size, $expected)
2828
$this->assertIterator($expected, $iterator);
2929
}
3030

31-
public function getAcceptData()
31+
public function getAcceptData(): array
3232
{
3333
$lessThan1KGreaterThan05K = [
3434
'.foo',

0 commit comments

Comments
 (0)
0