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 2ede10d

Browse filesBrowse files
committed
[Finder] Fix iterator return types
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent b8cbb93 commit 2ede10d
Copy full SHA for 2ede10d

File tree

Expand file treeCollapse file tree

5 files changed

+17
-16
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+17
-16
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function __construct(string $path, int $flags, bool $ignoreUnreadableDirs
5858
*
5959
* @return SplFileInfo File information
6060
*/
61+
#[\ReturnTypeWillChange]
6162
public function current()
6263
{
6364
// the logic here avoids redoing the same work in all iterations
@@ -82,6 +83,7 @@ public function current()
8283
*
8384
* @throws AccessDeniedException
8485
*/
86+
#[\ReturnTypeWillChange]
8587
public function getChildren()
8688
{
8789
try {
@@ -109,7 +111,10 @@ public function getChildren()
109111

110112
/**
111113
* Do nothing for non rewindable stream.
114+
*
115+
* @return void
112116
*/
117+
#[\ReturnTypeWillChange]
113118
public function rewind()
114119
{
115120
if (false === $this->isRewindable()) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Tests/Iterator/FileTypeFilterIteratorTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ public function getAcceptData()
6565

6666
class InnerTypeIterator extends \ArrayIterator
6767
{
68-
public function current()
68+
public function current(): \SplFileInfo
6969
{
7070
return new \SplFileInfo(parent::current());
7171
}
7272

73-
public function isFile()
73+
public function isFile(): bool
7474
{
7575
return $this->current()->isFile();
7676
}
7777

78-
public function isDir()
78+
public function isDir(): bool
7979
{
8080
return $this->current()->isDir();
8181
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Tests/Iterator/FilenameFilterIteratorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function getAcceptData()
4242

4343
class InnerNameIterator extends \ArrayIterator
4444
{
45-
public function current()
45+
public function current(): \SplFileInfo
4646
{
4747
return new \SplFileInfo(parent::current());
4848
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php
+4-8Lines changed: 4 additions & 8 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,13 +66,9 @@ public function isDir()
6666
return self::TYPE_DIRECTORY === $this->type;
6767
}
6868

69-
public function isReadable()
69+
public function isReadable(): bool
7070
{
71-
if (null === $this->mode) {
72-
return preg_match('/r\+/', $this->getFilename());
73-
}
74-
75-
return preg_match('/r\+/', $this->mode);
71+
return (bool) preg_match('/r\+/', $this->mode ?? $this->getFilename());
7672
}
7773

7874
public function getContents()

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Tests/Iterator/SizeRangeFilterIteratorTest.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@ public function getAcceptData()
4848

4949
class InnerSizeIterator extends \ArrayIterator
5050
{
51-
public function current()
51+
public function current(): \SplFileInfo
5252
{
5353
return new \SplFileInfo(parent::current());
5454
}
5555

56-
public function getFilename()
56+
public function getFilename(): string
5757
{
5858
return parent::current();
5959
}
6060

61-
public function isFile()
61+
public function isFile(): bool
6262
{
6363
return $this->current()->isFile();
6464
}
6565

66-
public function getSize()
66+
public function getSize(): int
6767
{
6868
return $this->current()->getSize();
6969
}

0 commit comments

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