[Finder] Fix iterator return types
Signed-off-by: Alexander M. Turek <me@derrabus.de>
This commit is contained in:
parent
b8cbb93caa
commit
2ede10d762
@ -58,6 +58,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|||||||
*
|
*
|
||||||
* @return SplFileInfo File information
|
* @return SplFileInfo File information
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function current()
|
public function current()
|
||||||
{
|
{
|
||||||
// the logic here avoids redoing the same work in all iterations
|
// the logic here avoids redoing the same work in all iterations
|
||||||
@ -82,6 +83,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|||||||
*
|
*
|
||||||
* @throws AccessDeniedException
|
* @throws AccessDeniedException
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function getChildren()
|
public function getChildren()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -109,7 +111,10 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Do nothing for non rewindable stream.
|
* Do nothing for non rewindable stream.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function rewind()
|
public function rewind()
|
||||||
{
|
{
|
||||||
if (false === $this->isRewindable()) {
|
if (false === $this->isRewindable()) {
|
||||||
|
@ -65,17 +65,17 @@ class FileTypeFilterIteratorTest extends RealIteratorTestCase
|
|||||||
|
|
||||||
class InnerTypeIterator extends \ArrayIterator
|
class InnerTypeIterator extends \ArrayIterator
|
||||||
{
|
{
|
||||||
public function current()
|
public function current(): \SplFileInfo
|
||||||
{
|
{
|
||||||
return new \SplFileInfo(parent::current());
|
return new \SplFileInfo(parent::current());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isFile()
|
public function isFile(): bool
|
||||||
{
|
{
|
||||||
return $this->current()->isFile();
|
return $this->current()->isFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isDir()
|
public function isDir(): bool
|
||||||
{
|
{
|
||||||
return $this->current()->isDir();
|
return $this->current()->isDir();
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class FilenameFilterIteratorTest extends IteratorTestCase
|
|||||||
|
|
||||||
class InnerNameIterator extends \ArrayIterator
|
class InnerNameIterator extends \ArrayIterator
|
||||||
{
|
{
|
||||||
public function current()
|
public function current(): \SplFileInfo
|
||||||
{
|
{
|
||||||
return new \SplFileInfo(parent::current());
|
return new \SplFileInfo(parent::current());
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class MockSplFileInfo extends \SplFileInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isFile()
|
public function isFile(): bool
|
||||||
{
|
{
|
||||||
if (null === $this->type) {
|
if (null === $this->type) {
|
||||||
return false !== strpos($this->getFilename(), 'file');
|
return false !== strpos($this->getFilename(), 'file');
|
||||||
@ -57,7 +57,7 @@ class MockSplFileInfo extends \SplFileInfo
|
|||||||
return self::TYPE_FILE === $this->type;
|
return self::TYPE_FILE === $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isDir()
|
public function isDir(): bool
|
||||||
{
|
{
|
||||||
if (null === $this->type) {
|
if (null === $this->type) {
|
||||||
return false !== strpos($this->getFilename(), 'directory');
|
return false !== strpos($this->getFilename(), 'directory');
|
||||||
@ -66,13 +66,9 @@ class MockSplFileInfo extends \SplFileInfo
|
|||||||
return self::TYPE_DIRECTORY === $this->type;
|
return self::TYPE_DIRECTORY === $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isReadable()
|
public function isReadable(): bool
|
||||||
{
|
{
|
||||||
if (null === $this->mode) {
|
return (bool) preg_match('/r\+/', $this->mode ?? $this->getFilename());
|
||||||
return preg_match('/r\+/', $this->getFilename());
|
|
||||||
}
|
|
||||||
|
|
||||||
return preg_match('/r\+/', $this->mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContents()
|
public function getContents()
|
||||||
|
@ -48,22 +48,22 @@ class SizeRangeFilterIteratorTest extends RealIteratorTestCase
|
|||||||
|
|
||||||
class InnerSizeIterator extends \ArrayIterator
|
class InnerSizeIterator extends \ArrayIterator
|
||||||
{
|
{
|
||||||
public function current()
|
public function current(): \SplFileInfo
|
||||||
{
|
{
|
||||||
return new \SplFileInfo(parent::current());
|
return new \SplFileInfo(parent::current());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilename()
|
public function getFilename(): string
|
||||||
{
|
{
|
||||||
return parent::current();
|
return parent::current();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isFile()
|
public function isFile(): bool
|
||||||
{
|
{
|
||||||
return $this->current()->isFile();
|
return $this->current()->isFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSize()
|
public function getSize(): int
|
||||||
{
|
{
|
||||||
return $this->current()->getSize();
|
return $this->current()->getSize();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user