Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 33f8a66

Browse filesBrowse files
committed
[Finder] Add types to private properties
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent 58801b9 commit 33f8a66
Copy full SHA for 33f8a66

12 files changed

+47
-55
lines changed

‎src/Symfony/Component/Finder/Comparator/Comparator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Comparator/Comparator.php
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
namespace Symfony\Component\Finder\Comparator;
1313

1414
/**
15-
* Comparator.
16-
*
1715
* @author Fabien Potencier <fabien@symfony.com>
1816
*/
1917
class Comparator
2018
{
21-
private $target;
22-
private $operator = '==';
19+
private string $target;
20+
private string $operator = '==';
2321

2422
/**
2523
* Gets the target value.

‎src/Symfony/Component/Finder/Finder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Finder.php
+21-21Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,27 @@ class Finder implements \IteratorAggregate, \Countable
4343
public const IGNORE_DOT_FILES = 2;
4444
public const IGNORE_VCS_IGNORED_FILES = 4;
4545

46-
private $mode = 0;
47-
private $names = [];
48-
private $notNames = [];
49-
private $exclude = [];
50-
private $filters = [];
51-
private $depths = [];
52-
private $sizes = [];
53-
private $followLinks = false;
54-
private $reverseSorting = false;
55-
private $sort = false;
56-
private $ignore = 0;
57-
private $dirs = [];
58-
private $dates = [];
59-
private $iterators = [];
60-
private $contains = [];
61-
private $notContains = [];
62-
private $paths = [];
63-
private $notPaths = [];
64-
private $ignoreUnreadableDirs = false;
65-
66-
private static $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
46+
private int $mode = 0;
47+
private array $names = [];
48+
private array $notNames = [];
49+
private array $exclude = [];
50+
private array $filters = [];
51+
private array $depths = [];
52+
private array $sizes = [];
53+
private bool $followLinks = false;
54+
private bool $reverseSorting = false;
55+
private \Closure|int|false $sort = false;
56+
private int $ignore = 0;
57+
private array $dirs = [];
58+
private array $dates = [];
59+
private array $iterators = [];
60+
private array $contains = [];
61+
private array $notContains = [];
62+
private array $paths = [];
63+
private array $notPaths = [];
64+
private bool $ignoreUnreadableDirs = false;
65+
66+
private static array $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
6767

6868
public function __construct()
6969
{

‎src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class CustomFilterIterator extends \FilterIterator
2323
{
24-
private $filters = [];
24+
private array $filters = [];
2525

2626
/**
2727
* @param \Iterator $iterator The Iterator to filter

‎src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class DateRangeFilterIterator extends \FilterIterator
2222
{
23-
private $comparators = [];
23+
private array $comparators = [];
2424

2525
/**
2626
* @param \Iterator $iterator The Iterator to filter

‎src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class DepthRangeFilterIterator extends \FilterIterator
2020
{
21-
private $minDepth = 0;
21+
private int $minDepth = 0;
2222

2323
/**
2424
* @param \RecursiveIteratorIterator $iterator The Iterator to filter

‎src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
*/
1919
class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator
2020
{
21-
private $iterator;
22-
private $isRecursive;
23-
private $excludedDirs = [];
24-
private $excludedPattern;
21+
private \Iterator $iterator;
22+
private bool $isRecursive;
23+
private array $excludedDirs = [];
24+
private ?string $excludedPattern = null;
2525

2626
/**
2727
* @param \Iterator $iterator The Iterator to filter

‎src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class FileTypeFilterIterator extends \FilterIterator
2121
public const ONLY_FILES = 1;
2222
public const ONLY_DIRECTORIES = 2;
2323

24-
private $mode;
24+
private int $mode;
2525

2626
/**
2727
* @param \Iterator $iterator The Iterator to filter

‎src/Symfony/Component/Finder/Iterator/LazyIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/LazyIterator.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
*/
1919
class LazyIterator implements \IteratorAggregate
2020
{
21-
private $iteratorFactory;
21+
private \Closure $iteratorFactory;
2222

2323
public function __construct(callable $iteratorFactory)
2424
{
25-
$this->iteratorFactory = $iteratorFactory;
25+
$this->iteratorFactory = $iteratorFactory instanceof \Closure ? $iteratorFactory : \Closure::fromCallable($iteratorFactory);
2626
}
2727

2828
public function getIterator(): \Traversable

‎src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php
+8-14Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,13 @@
2121
*/
2222
class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
2323
{
24-
/**
25-
* @var bool
26-
*/
27-
private $ignoreUnreadableDirs;
28-
29-
/**
30-
* @var bool
31-
*/
32-
private $rewindable;
24+
private bool $ignoreUnreadableDirs;
25+
private ?bool $rewindable = null;
3326

3427
// these 3 properties take part of the performance optimization to avoid redoing the same work in all iterations
35-
private $rootPath;
36-
private $subPath;
37-
private $directorySeparator = '/';
28+
private string $rootPath;
29+
private string $subPath;
30+
private string $directorySeparator = '/';
3831

3932
/**
4033
* @throws \RuntimeException
@@ -63,9 +56,10 @@ public function current()
6356
{
6457
// the logic here avoids redoing the same work in all iterations
6558

66-
if (null === $subPathname = $this->subPath) {
67-
$subPathname = $this->subPath = (string) $this->getSubPath();
59+
if (!isset($this->subPath)) {
60+
$this->subPath = (string) $this->getSubPath();
6861
}
62+
$subPathname = $this->subPath;
6963
if ('' !== $subPathname) {
7064
$subPathname .= $this->directorySeparator;
7165
}

‎src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class SizeRangeFilterIterator extends \FilterIterator
2222
{
23-
private $comparators = [];
23+
private array $comparators = [];
2424

2525
/**
2626
* @param \Iterator $iterator The Iterator to filter

‎src/Symfony/Component/Finder/Iterator/SortableIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/SortableIterator.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class SortableIterator implements \IteratorAggregate
2626
public const SORT_BY_MODIFIED_TIME = 5;
2727
public const SORT_BY_NAME_NATURAL = 6;
2828

29-
private $iterator;
30-
private $sort;
29+
private \Traversable $iterator;
30+
private \Closure|int $sort;
3131

3232
/**
3333
* @param int|callable $sort The sort type (SORT_BY_NAME, SORT_BY_TYPE, or a PHP callback)
@@ -72,7 +72,7 @@ public function __construct(\Traversable $iterator, int|callable $sort, bool $re
7272
} elseif (self::SORT_BY_NONE === $sort) {
7373
$this->sort = $order;
7474
} elseif (\is_callable($sort)) {
75-
$this->sort = $reverseOrder ? static function (\SplFileInfo $a, \SplFileInfo $b) use ($sort) { return -$sort($a, $b); } : $sort;
75+
$this->sort = $reverseOrder ? static function (\SplFileInfo $a, \SplFileInfo $b) use ($sort) { return -$sort($a, $b); } : \Closure::fromCallable($sort);
7676
} else {
7777
throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
7878
}

‎src/Symfony/Component/Finder/SplFileInfo.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/SplFileInfo.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
class SplFileInfo extends \SplFileInfo
2020
{
21-
private $relativePath;
22-
private $relativePathname;
21+
private string $relativePath;
22+
private string $relativePathname;
2323

2424
/**
2525
* @param string $file The file name

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.