Skip to content

Commit

Permalink
Merge branch '4.4' into 5.3
Browse files Browse the repository at this point in the history
* 4.4:
  Fix return types for PHP 8.1
  • Loading branch information
derrabus committed Aug 4, 2021
2 parents 17f50e0 + 70362f1 commit a10000a
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ public function in($dirs)
*
* @throws \LogicException if the in() method has not been called
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
Expand Down Expand Up @@ -687,6 +688,7 @@ public function hasResults()
*
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
{
return iterator_count($this->getIterator());
Expand Down
1 change: 1 addition & 0 deletions Iterator/CustomFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function __construct(\Iterator $iterator, array $filters)
*
* @return bool true if the value should be kept, false otherwise
*/
#[\ReturnTypeWillChange]
public function accept()
{
$fileinfo = $this->current();
Expand Down
1 change: 1 addition & 0 deletions Iterator/DateRangeFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function __construct(\Iterator $iterator, array $comparators)
*
* @return bool true if the value should be kept, false otherwise
*/
#[\ReturnTypeWillChange]
public function accept()
{
$fileinfo = $this->current();
Expand Down
1 change: 1 addition & 0 deletions Iterator/DepthRangeFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth
*
* @return bool true if the value should be kept, false otherwise
*/
#[\ReturnTypeWillChange]
public function accept()
{
return $this->getInnerIterator()->getDepth() >= $this->minDepth;
Expand Down
3 changes: 3 additions & 0 deletions Iterator/ExcludeDirectoryFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function __construct(\Iterator $iterator, array $directories)
*
* @return bool True if the value should be kept, false otherwise
*/
#[\ReturnTypeWillChange]
public function accept()
{
if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
Expand All @@ -71,6 +72,7 @@ public function accept()
/**
* @return bool
*/
#[\ReturnTypeWillChange]
public function hasChildren()
{
return $this->isRecursive && $this->iterator->hasChildren();
Expand All @@ -79,6 +81,7 @@ public function hasChildren()
/**
* @return self
*/
#[\ReturnTypeWillChange]
public function getChildren()
{
$children = new self($this->iterator->getChildren(), []);
Expand Down
1 change: 1 addition & 0 deletions Iterator/FileTypeFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function __construct(\Iterator $iterator, int $mode)
*
* @return bool true if the value should be kept, false otherwise
*/
#[\ReturnTypeWillChange]
public function accept()
{
$fileinfo = $this->current();
Expand Down
1 change: 1 addition & 0 deletions Iterator/FilecontentFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class FilecontentFilterIterator extends MultiplePcreFilterIterator
*
* @return bool true if the value should be kept, false otherwise
*/
#[\ReturnTypeWillChange]
public function accept()
{
if (!$this->matchRegexps && !$this->noMatchRegexps) {
Expand Down
1 change: 1 addition & 0 deletions Iterator/FilenameFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class FilenameFilterIterator extends MultiplePcreFilterIterator
*
* @return bool true if the value should be kept, false otherwise
*/
#[\ReturnTypeWillChange]
public function accept()
{
return $this->isAccepted($this->current()->getFilename());
Expand Down
1 change: 1 addition & 0 deletions Iterator/PathFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator
*
* @return bool true if the value should be kept, false otherwise
*/
#[\ReturnTypeWillChange]
public function accept()
{
$filename = $this->current()->getRelativePathname();
Expand Down
1 change: 1 addition & 0 deletions Iterator/SizeRangeFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function __construct(\Iterator $iterator, array $comparators)
*
* @return bool true if the value should be kept, false otherwise
*/
#[\ReturnTypeWillChange]
public function accept()
{
$fileinfo = $this->current();
Expand Down
1 change: 1 addition & 0 deletions Iterator/SortableIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function __construct(\Traversable $iterator, $sort, bool $reverseOrder =
/**
* @return \Traversable
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
if (1 === $this->sort) {
Expand Down
14 changes: 11 additions & 3 deletions Tests/Iterator/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public function __construct(array $values = [])
$this->rewind();
}

public function attach(\SplFileInfo $fileinfo)
public function attach(\SplFileInfo $fileinfo): void
{
$this->values[] = $fileinfo;
}

public function rewind()
public function rewind(): void
{
reset($this->values);
}
Expand All @@ -38,16 +38,24 @@ public function valid(): bool
return false !== $this->current();
}

public function next()
public function next(): void
{
next($this->values);
}

/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
{
return current($this->values);
}

/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function key()
{
return key($this->values);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Iterator/MultiplePcreFilterIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct()
{
}

public function accept()
public function accept(): bool
{
throw new \BadFunctionCallException('Not implemented');
}
Expand Down

0 comments on commit a10000a

Please sign in to comment.