[Finder] Fix iterator return types

Signed-off-by: Alexander M. Turek <me@derrabus.de>
This commit is contained in:
Alexander M. Turek 2021-07-15 01:28:32 +02:00
parent b8cbb93caa
commit 2ede10d762
5 changed files with 17 additions and 16 deletions

View File

@ -58,6 +58,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
*
* @return SplFileInfo File information
*/
#[\ReturnTypeWillChange]
public function current()
{
// the logic here avoids redoing the same work in all iterations
@ -82,6 +83,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
*
* @throws AccessDeniedException
*/
#[\ReturnTypeWillChange]
public function getChildren()
{
try {
@ -109,7 +111,10 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
/**
* Do nothing for non rewindable stream.
*
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
{
if (false === $this->isRewindable()) {

View File

@ -65,17 +65,17 @@ class FileTypeFilterIteratorTest extends RealIteratorTestCase
class InnerTypeIterator extends \ArrayIterator
{
public function current()
public function current(): \SplFileInfo
{
return new \SplFileInfo(parent::current());
}
public function isFile()
public function isFile(): bool
{
return $this->current()->isFile();
}
public function isDir()
public function isDir(): bool
{
return $this->current()->isDir();
}

View File

@ -42,7 +42,7 @@ class FilenameFilterIteratorTest extends IteratorTestCase
class InnerNameIterator extends \ArrayIterator
{
public function current()
public function current(): \SplFileInfo
{
return new \SplFileInfo(parent::current());
}

View File

@ -48,7 +48,7 @@ class MockSplFileInfo extends \SplFileInfo
}
}
public function isFile()
public function isFile(): bool
{
if (null === $this->type) {
return false !== strpos($this->getFilename(), 'file');
@ -57,7 +57,7 @@ class MockSplFileInfo extends \SplFileInfo
return self::TYPE_FILE === $this->type;
}
public function isDir()
public function isDir(): bool
{
if (null === $this->type) {
return false !== strpos($this->getFilename(), 'directory');
@ -66,13 +66,9 @@ class MockSplFileInfo extends \SplFileInfo
return self::TYPE_DIRECTORY === $this->type;
}
public function isReadable()
public function isReadable(): bool
{
if (null === $this->mode) {
return preg_match('/r\+/', $this->getFilename());
}
return preg_match('/r\+/', $this->mode);
return (bool) preg_match('/r\+/', $this->mode ?? $this->getFilename());
}
public function getContents()

View File

@ -48,22 +48,22 @@ class SizeRangeFilterIteratorTest extends RealIteratorTestCase
class InnerSizeIterator extends \ArrayIterator
{
public function current()
public function current(): \SplFileInfo
{
return new \SplFileInfo(parent::current());
}
public function getFilename()
public function getFilename(): string
{
return parent::current();
}
public function isFile()
public function isFile(): bool
{
return $this->current()->isFile();
}
public function getSize()
public function getSize(): int
{
return $this->current()->getSize();
}