Skip to content

Declare tentative return types in ext/spl - part 3 #7239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
364 changes: 182 additions & 182 deletions ext/spl/spl_iterators.stub.php

Large diffs are not rendered by default.

207 changes: 116 additions & 91 deletions ext/spl/spl_iterators_arginfo.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ext/spl/tests/array_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class StudentIdFilter extends FilterIterator
$this->id = $other->getId();
}

public function accept()
public function accept(): bool
{
echo "ACCEPT ".$this->current()->getId()." == ".$this->id."\n";
return $this->current()->getId() == $this->id;
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/tests/array_009a.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MyRecursiveArrayIterator extends ArrayIterator implements RecursiveIterato
return is_array($this->current());
}

function getChildren()
function getChildren(): MyRecursiveArrayIterator
{
return new MyRecursiveArrayIterator($this->current());
}
Expand Down
10 changes: 5 additions & 5 deletions ext/spl/tests/bug37457.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ class Collection implements Iterator
$this->array = $a;
}

public function current()
public function current(): mixed
{
echo __METHOD__ . "\n";
return current($this->array);
}

public function key()
public function key(): mixed
{
echo __METHOD__ . "\n";
return key($this->array);
}

public function next()
public function next(): void
{
echo __METHOD__ . "\n";
$this->valid = (false !== next($this->array));
}

public function valid()
public function valid(): bool
{
echo __METHOD__ . "\n";
return $this->valid;
Expand All @@ -46,7 +46,7 @@ class Collection implements Iterator

class TestFilter extends FilterIterator
{
public function accept()
public function accept(): bool
{
echo __METHOD__ . "\n";
throw new Exception("Failure in Accept");
Expand Down
8 changes: 4 additions & 4 deletions ext/spl/tests/bug42703.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ class BlaIterator implements Iterator
{
public function rewind(): void { }

public function next() { }
public function next(): void { }

public function valid() {
public function valid(): bool {
return true;
}

public function current()
public function current(): mixed
{
throw new Exception('boo');
}

public function key() { }
public function key(): mixed { return null; }
}

$it = new BlaIterator();
Expand Down
4 changes: 2 additions & 2 deletions ext/spl/tests/bug54384.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test( function() {
echo "FilterIterator... ";
class FilterIteratorTest extends FilterIterator {
function __construct(){}
function accept(){}
function accept(): bool {}
}
test( function() {
$o = new FilterIteratorTest;
Expand All @@ -34,7 +34,7 @@ test( function() {
echo "RecursiveFilterIterator... ";
class RecursiveFilterIteratorTest extends RecursiveFilterIterator {
function __construct(){}
function accept(){}
function accept(): bool {}
}
test( function() {
$o = new RecursiveFilterIteratorTest;
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/tests/bug69970.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator {
function rewind(): void {
echo "dummy\n";
}
function endChildren() {
function endChildren(): void {
global $count;
echo $this->getDepth();
if (--$count > 0) {
Expand Down
18 changes: 9 additions & 9 deletions ext/spl/tests/bug73423.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@ class foo implements \RecursiveIterator
{
public $foo = [];

public Function current ()
public Function current(): mixed
{
return current ($this->foo);
}

public Function key ()
public Function key(): mixed
{
return key ($this->foo);
}

public Function next ()
public Function next(): void
{
next ($this->foo);
}

public Function rewind ()
public Function rewind(): void
{
reset ($this->foo);
}

public Function valid ()
public Function valid(): bool
{
return current ($this->foo) !== false;
}

public Function getChildren ()
public Function getChildren(): ?RecursiveIterator
{
return current ($this->foo);
}

public Function hasChildren ()
public Function hasChildren(): bool
{
return (bool) count ($this->foo);
return (bool) count($this->foo);
}
}

Expand All @@ -53,7 +53,7 @@ class fooIterator extends \RecursiveFilterIterator
/* CRASH */
}

public Function accept ()
public Function accept(): bool
{
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions ext/spl/tests/bug74669.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ class Container implements Iterator
$this->container->append($element);
}

public function current()
public function current(): mixed
{
return $this->iterator->current();
}

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

public function key()
public function key(): mixed
{
return $this->iterator->key();
}

public function valid()
public function valid(): bool
{
return $this->iterator->valid();
}
Expand Down
4 changes: 2 additions & 2 deletions ext/spl/tests/bug77263.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ touch("$dir/file1");
touch("$dir/subdir/file2");

class Filter1 extends RecursiveFilterIterator {
public function accept() { return $this->getInnerIterator()->getSubPathname() != ''; }
public function accept(): bool { return $this->getInnerIterator()->getSubPathname() != ''; }
}

class Filter2 extends RecursiveFilterIterator {
public function accept() { return $this->getInnerIterator()->getSubPathname() != ' '; }
public function accept(): bool { return $this->getInnerIterator()->getSubPathname() != ' '; }
}

$iterator = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS );
Expand Down
10 changes: 5 additions & 5 deletions ext/spl/tests/iterator_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ class NumericArrayIterator implements Iterator
$this->i = 0;
}

public function valid()
public function valid(): bool
{
$ret = $this->i < count($this->a);
echo __METHOD__ . '(' . ($ret ? 'true' : 'false') . ")\n";
return $ret;
}

public function key()
public function key(): mixed
{
echo __METHOD__ . "\n";
return $this->i;
}

public function current()
public function current(): mixed
{
echo __METHOD__ . "\n";
return $this->a[$this->i];
}

public function next()
public function next(): void
{
echo __METHOD__ . "\n";
$this->i++;
Expand All @@ -54,7 +54,7 @@ class NumericArrayIterator implements Iterator

class SeekableNumericArrayIterator extends NumericArrayIterator implements SeekableIterator
{
public function seek($index)
public function seek($index): void
{
if ($index < count($this->a)) {
$this->i = $index;
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/tests/iterator_003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class StudentIdFilter extends FilterIterator
$this->id = $other->getId();
}

public function accept()
public function accept(): bool
{
echo "ACCEPT ".$this->current()->getId()." == ".$this->id."\n";
return $this->current()->getId() == $this->id;
Expand Down
10 changes: 5 additions & 5 deletions ext/spl/tests/iterator_004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ class NumericArrayIterator implements Iterator
$this->i = 0;
}

public function valid()
public function valid(): bool
{
$ret = $this->i < count($this->a);
echo __METHOD__ . '(' . ($ret ? 'true' : 'false') . ")\n";
return $ret;
}

public function key()
public function key(): mixed
{
echo __METHOD__ . "\n";
return $this->i;
}

public function current()
public function current(): mixed
{
echo __METHOD__ . "\n";
return $this->a[$this->i];
}

public function next()
public function next(): void
{
echo __METHOD__ . "\n";
$this->i++;
Expand All @@ -48,7 +48,7 @@ class NumericArrayIterator implements Iterator

class SeekableNumericArrayIterator extends NumericArrayIterator implements SeekableIterator
{
public function seek($index)
public function seek($index): void
{
if ($index < count($this->a)) {
$this->i = $index;
Expand Down
8 changes: 4 additions & 4 deletions ext/spl/tests/iterator_007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ class NoRewindIteratorEx extends NoRewindIterator
echo __METHOD__ . "\n";
parent::rewind();
}
function valid()
function valid(): bool
{
echo __METHOD__ . "\n";
return parent::valid();
}
function current()
function current(): mixed
{
echo __METHOD__ . "\n";
return parent::current();
}
function key()
function key(): mixed
{
echo __METHOD__ . "\n";
return parent::key();
}
function next()
function next(): void
{
echo __METHOD__ . "\n";
parent::next();
Expand Down
14 changes: 7 additions & 7 deletions ext/spl/tests/iterator_009.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ SPL: EmptyIterator

class EmptyIteratorEx extends EmptyIterator
{
function rewind()
function rewind(): void
{
echo __METHOD__ . "\n";
parent::rewind();
}
function valid()
function valid(): bool
{
echo __METHOD__ . "\n";
return parent::valid();
}
function current()
function current(): never
{
echo __METHOD__ . "\n";
return parent::current();
parent::current();
}
function key()
function key(): never
{
echo __METHOD__ . "\n";
return parent::key();
parent::key();
}
function next()
function next(): void
{
echo __METHOD__ . "\n";
parent::next();
Expand Down
Loading