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 1f6c68c

Browse filesBrowse files
author
smoench
committed
[5.0][Finder] add parameter type-hints
1 parent a25848b commit 1f6c68c
Copy full SHA for 1f6c68c

File tree

Expand file treeCollapse file tree

10 files changed

+27
-27
lines changed
Filter options
Expand file treeCollapse file tree

10 files changed

+27
-27
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Comparator/Comparator.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function getTarget()
3636
*
3737
* @param string $target The target value
3838
*/
39-
public function setTarget($target)
39+
public function setTarget(string $target)
4040
{
4141
$this->target = $target;
4242
}
@@ -58,9 +58,9 @@ public function getOperator()
5858
*
5959
* @throws \InvalidArgumentException
6060
*/
61-
public function setOperator($operator)
61+
public function setOperator(string $operator)
6262
{
63-
if (!$operator) {
63+
if ('' === $operator) {
6464
$operator = '==';
6565
}
6666

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Finder.php
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public function exclude($dirs)
342342
*
343343
* @see ExcludeDirectoryFilterIterator
344344
*/
345-
public function ignoreDotFiles($ignoreDotFiles)
345+
public function ignoreDotFiles(bool $ignoreDotFiles)
346346
{
347347
if ($ignoreDotFiles) {
348348
$this->ignore |= static::IGNORE_DOT_FILES;
@@ -364,7 +364,7 @@ public function ignoreDotFiles($ignoreDotFiles)
364364
*
365365
* @see ExcludeDirectoryFilterIterator
366366
*/
367-
public function ignoreVCS($ignoreVCS)
367+
public function ignoreVCS(bool $ignoreVCS)
368368
{
369369
if ($ignoreVCS) {
370370
$this->ignore |= static::IGNORE_VCS_FILES;
@@ -567,17 +567,17 @@ public function followLinks()
567567
*
568568
* @return $this
569569
*/
570-
public function ignoreUnreadableDirs($ignore = true)
570+
public function ignoreUnreadableDirs(bool $ignore = true)
571571
{
572-
$this->ignoreUnreadableDirs = (bool) $ignore;
572+
$this->ignoreUnreadableDirs = $ignore;
573573

574574
return $this;
575575
}
576576

577577
/**
578578
* Searches files and directories which match defined rules.
579579
*
580-
* @param string|array $dirs A directory path or an array of directories
580+
* @param string|string[] $dirs A directory path or an array of directories
581581
*
582582
* @return $this
583583
*
@@ -644,7 +644,7 @@ public function getIterator()
644644
*
645645
* @throws \InvalidArgumentException when the given argument is not iterable
646646
*/
647-
public function append($iterator)
647+
public function append(iterable $iterator)
648648
{
649649
if ($iterator instanceof \IteratorAggregate) {
650650
$this->iterators[] = $iterator->getIterator();
@@ -793,7 +793,7 @@ private function searchInDirectory(string $dir): \Iterator
793793
*
794794
* @return string
795795
*/
796-
private function normalizeDir($dir)
796+
private function normalizeDir(string $dir)
797797
{
798798
$dir = rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
799799

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Glob.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Glob
4545
*
4646
* @return string regex The regexp
4747
*/
48-
public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true, $delimiter = '#')
48+
public static function toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#')
4949
{
5050
$firstByte = true;
5151
$escaping = false;

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ExcludeDirectoryFilterIterator extends \FilterIterator implements \Recursi
2525

2626
/**
2727
* @param \Iterator $iterator The Iterator to filter
28-
* @param array $directories An array of directories to exclude
28+
* @param string[] $directories An array of directories to exclude
2929
*/
3030
public function __construct(\Iterator $iterator, array $directories)
3131
{

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function accept()
5151
*
5252
* @return string regexp corresponding to a given string or regexp
5353
*/
54-
protected function toRegex($str)
54+
protected function toRegex(string $str)
5555
{
5656
return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
5757
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function accept()
4040
*
4141
* @return string regexp corresponding to a given glob or regexp
4242
*/
43-
protected function toRegex($str)
43+
protected function toRegex(string $str)
4444
{
4545
return $this->isRegex($str) ? $str : Glob::toRegex($str);
4646
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct(\Iterator $iterator, array $matchPatterns, array $no
5050
*
5151
* @return bool
5252
*/
53-
protected function isAccepted($string)
53+
protected function isAccepted(string $string)
5454
{
5555
// should at least not match one rule to exclude
5656
foreach ($this->noMatchRegexps as $regex) {
@@ -81,7 +81,7 @@ protected function isAccepted($string)
8181
*
8282
* @return bool Whether the given string is a regex
8383
*/
84-
protected function isRegex($str)
84+
protected function isRegex(string $str)
8585
{
8686
if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
8787
$start = substr($m[1], 0, 1);
@@ -108,5 +108,5 @@ protected function isRegex($str)
108108
*
109109
* @return string regexp corresponding to a given string
110110
*/
111-
abstract protected function toRegex($str);
111+
abstract protected function toRegex(string $str);
112112
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/PathFilterIterator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function accept()
4949
*
5050
* @return string regexp corresponding to a given string or regexp
5151
*/
52-
protected function toRegex($str)
52+
protected function toRegex(string $str)
5353
{
5454
return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
5555
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/SortableIterator.php
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ public function __construct(\Traversable $iterator, $sort, bool $reverseOrder =
4141
$order = $reverseOrder ? -1 : 1;
4242

4343
if (self::SORT_BY_NAME === $sort) {
44-
$this->sort = function ($a, $b) use ($order) {
44+
$this->sort = function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
4545
return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
4646
};
4747
} elseif (self::SORT_BY_NAME_NATURAL === $sort) {
48-
$this->sort = function ($a, $b) use ($order) {
48+
$this->sort = function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
4949
return $order * strnatcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
5050
};
5151
} elseif (self::SORT_BY_TYPE === $sort) {
52-
$this->sort = function ($a, $b) use ($order) {
52+
$this->sort = function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
5353
if ($a->isDir() && $b->isFile()) {
5454
return -$order;
5555
} elseif ($a->isFile() && $b->isDir()) {
@@ -59,21 +59,21 @@ public function __construct(\Traversable $iterator, $sort, bool $reverseOrder =
5959
return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
6060
};
6161
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
62-
$this->sort = function ($a, $b) use ($order) {
62+
$this->sort = function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
6363
return $order * ($a->getATime() - $b->getATime());
6464
};
6565
} elseif (self::SORT_BY_CHANGED_TIME === $sort) {
66-
$this->sort = function ($a, $b) use ($order) {
66+
$this->sort = function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
6767
return $order * ($a->getCTime() - $b->getCTime());
6868
};
6969
} elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
70-
$this->sort = function ($a, $b) use ($order) {
70+
$this->sort = function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
7171
return $order * ($a->getMTime() - $b->getMTime());
7272
};
7373
} elseif (self::SORT_BY_NONE === $sort) {
7474
$this->sort = $order;
7575
} elseif (\is_callable($sort)) {
76-
$this->sort = $reverseOrder ? function ($a, $b) use ($sort) { return -$sort($a, $b); }
76+
$this->sort = $reverseOrder ? function (\SplFileInfo $a, \SplFileInfo $b) use ($sort) { return -$sort($a, $b); }
7777
: $sort;
7878
} else {
7979
throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ public function accept()
5959
throw new \BadFunctionCallException('Not implemented');
6060
}
6161

62-
public function isRegex($str)
62+
public function isRegex(string $str)
6363
{
6464
return parent::isRegex($str);
6565
}
6666

67-
public function toRegex($str)
67+
public function toRegex(string $str)
6868
{
6969
throw new \BadFunctionCallException('Not implemented');
7070
}

0 commit comments

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