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

[Finder] Add types to private properties #42106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Finder] Add types to private properties
Signed-off-by: Alexander M. Turek <me@derrabus.de>
  • Loading branch information
derrabus committed Jul 16, 2021
commit 33f8a66f6460aac47f3487c1b6c622e29debac1a
6 changes: 2 additions & 4 deletions 6 src/Symfony/Component/Finder/Comparator/Comparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
namespace Symfony\Component\Finder\Comparator;

/**
* Comparator.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Comparator
{
private $target;
private $operator = '==';
private string $target;
private string $operator = '==';

/**
* Gets the target value.
Expand Down
42 changes: 21 additions & 21 deletions 42 src/Symfony/Component/Finder/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,27 @@ class Finder implements \IteratorAggregate, \Countable
public const IGNORE_DOT_FILES = 2;
public const IGNORE_VCS_IGNORED_FILES = 4;

private $mode = 0;
private $names = [];
private $notNames = [];
private $exclude = [];
private $filters = [];
private $depths = [];
private $sizes = [];
private $followLinks = false;
private $reverseSorting = false;
private $sort = false;
private $ignore = 0;
private $dirs = [];
private $dates = [];
private $iterators = [];
private $contains = [];
private $notContains = [];
private $paths = [];
private $notPaths = [];
private $ignoreUnreadableDirs = false;

private static $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
private int $mode = 0;
private array $names = [];
private array $notNames = [];
private array $exclude = [];
private array $filters = [];
private array $depths = [];
private array $sizes = [];
private bool $followLinks = false;
private bool $reverseSorting = false;
private \Closure|int|false $sort = false;
private int $ignore = 0;
private array $dirs = [];
private array $dates = [];
private array $iterators = [];
private array $contains = [];
private array $notContains = [];
private array $paths = [];
private array $notPaths = [];
private bool $ignoreUnreadableDirs = false;

private static array $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];

public function __construct()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
class CustomFilterIterator extends \FilterIterator
{
private $filters = [];
private array $filters = [];

/**
* @param \Iterator $iterator The Iterator to filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class DateRangeFilterIterator extends \FilterIterator
{
private $comparators = [];
private array $comparators = [];

/**
* @param \Iterator $iterator The Iterator to filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class DepthRangeFilterIterator extends \FilterIterator
{
private $minDepth = 0;
private int $minDepth = 0;

/**
* @param \RecursiveIteratorIterator $iterator The Iterator to filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/
class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator
{
private $iterator;
private $isRecursive;
private $excludedDirs = [];
private $excludedPattern;
private \Iterator $iterator;
private bool $isRecursive;
private array $excludedDirs = [];
private ?string $excludedPattern = null;

/**
* @param \Iterator $iterator The Iterator to filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FileTypeFilterIterator extends \FilterIterator
public const ONLY_FILES = 1;
public const ONLY_DIRECTORIES = 2;

private $mode;
private int $mode;

/**
* @param \Iterator $iterator The Iterator to filter
Expand Down
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Finder/Iterator/LazyIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/
class LazyIterator implements \IteratorAggregate
{
private $iteratorFactory;
private \Closure $iteratorFactory;

public function __construct(callable $iteratorFactory)
{
$this->iteratorFactory = $iteratorFactory;
$this->iteratorFactory = $iteratorFactory instanceof \Closure ? $iteratorFactory : \Closure::fromCallable($iteratorFactory);
}

public function getIterator(): \Traversable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,13 @@
*/
class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
{
/**
* @var bool
*/
private $ignoreUnreadableDirs;

/**
* @var bool
*/
private $rewindable;
private bool $ignoreUnreadableDirs;
private ?bool $rewindable = null;

// these 3 properties take part of the performance optimization to avoid redoing the same work in all iterations
private $rootPath;
private $subPath;
private $directorySeparator = '/';
private string $rootPath;
private string $subPath;
private string $directorySeparator = '/';

/**
* @throws \RuntimeException
Expand Down Expand Up @@ -63,9 +56,10 @@ public function current()
{
// the logic here avoids redoing the same work in all iterations

if (null === $subPathname = $this->subPath) {
$subPathname = $this->subPath = (string) $this->getSubPath();
if (!isset($this->subPath)) {
$this->subPath = (string) $this->getSubPath();
}
$subPathname = $this->subPath;
if ('' !== $subPathname) {
$subPathname .= $this->directorySeparator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class SizeRangeFilterIterator extends \FilterIterator
{
private $comparators = [];
private array $comparators = [];

/**
* @param \Iterator $iterator The Iterator to filter
Expand Down
6 changes: 3 additions & 3 deletions 6 src/Symfony/Component/Finder/Iterator/SortableIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class SortableIterator implements \IteratorAggregate
public const SORT_BY_MODIFIED_TIME = 5;
public const SORT_BY_NAME_NATURAL = 6;

private $iterator;
private $sort;
private \Traversable $iterator;
private \Closure|int $sort;

/**
* @param int|callable $sort The sort type (SORT_BY_NAME, SORT_BY_TYPE, or a PHP callback)
Expand Down Expand Up @@ -72,7 +72,7 @@ public function __construct(\Traversable $iterator, int|callable $sort, bool $re
} elseif (self::SORT_BY_NONE === $sort) {
$this->sort = $order;
} elseif (\is_callable($sort)) {
$this->sort = $reverseOrder ? static function (\SplFileInfo $a, \SplFileInfo $b) use ($sort) { return -$sort($a, $b); } : $sort;
$this->sort = $reverseOrder ? static function (\SplFileInfo $a, \SplFileInfo $b) use ($sort) { return -$sort($a, $b); } : \Closure::fromCallable($sort);
} else {
throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
}
Expand Down
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Finder/SplFileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
class SplFileInfo extends \SplFileInfo
{
private $relativePath;
private $relativePathname;
private string $relativePath;
private string $relativePathname;

/**
* @param string $file The file name
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.