Skip to content

Commit b3e0888

Browse files
authored
Declare tentative return types in ext/spl - part 3 (#7239)
1 parent f2e374c commit b3e0888

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+431
-406
lines changed

ext/spl/spl_iterators.stub.php

Lines changed: 182 additions & 182 deletions
Large diffs are not rendered by default.

ext/spl/spl_iterators_arginfo.h

Lines changed: 116 additions & 91 deletions
Large diffs are not rendered by default.

ext/spl/tests/array_005.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class StudentIdFilter extends FilterIterator
3535
$this->id = $other->getId();
3636
}
3737

38-
public function accept()
38+
public function accept(): bool
3939
{
4040
echo "ACCEPT ".$this->current()->getId()." == ".$this->id."\n";
4141
return $this->current()->getId() == $this->id;

ext/spl/tests/array_009a.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class MyRecursiveArrayIterator extends ArrayIterator implements RecursiveIterato
1010
return is_array($this->current());
1111
}
1212

13-
function getChildren()
13+
function getChildren(): MyRecursiveArrayIterator
1414
{
1515
return new MyRecursiveArrayIterator($this->current());
1616
}

ext/spl/tests/bug37457.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@ class Collection implements Iterator
1313
$this->array = $a;
1414
}
1515

16-
public function current()
16+
public function current(): mixed
1717
{
1818
echo __METHOD__ . "\n";
1919
return current($this->array);
2020
}
2121

22-
public function key()
22+
public function key(): mixed
2323
{
2424
echo __METHOD__ . "\n";
2525
return key($this->array);
2626
}
2727

28-
public function next()
28+
public function next(): void
2929
{
3030
echo __METHOD__ . "\n";
3131
$this->valid = (false !== next($this->array));
3232
}
3333

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

4747
class TestFilter extends FilterIterator
4848
{
49-
public function accept()
49+
public function accept(): bool
5050
{
5151
echo __METHOD__ . "\n";
5252
throw new Exception("Failure in Accept");

ext/spl/tests/bug42703.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ class BlaIterator implements Iterator
66
{
77
public function rewind(): void { }
88

9-
public function next() { }
9+
public function next(): void { }
1010

11-
public function valid() {
11+
public function valid(): bool {
1212
return true;
1313
}
1414

15-
public function current()
15+
public function current(): mixed
1616
{
1717
throw new Exception('boo');
1818
}
1919

20-
public function key() { }
20+
public function key(): mixed { return null; }
2121
}
2222

2323
$it = new BlaIterator();

ext/spl/tests/bug54384.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test( function() {
2424
echo "FilterIterator... ";
2525
class FilterIteratorTest extends FilterIterator {
2626
function __construct(){}
27-
function accept(){}
27+
function accept(): bool {}
2828
}
2929
test( function() {
3030
$o = new FilterIteratorTest;
@@ -34,7 +34,7 @@ test( function() {
3434
echo "RecursiveFilterIterator... ";
3535
class RecursiveFilterIteratorTest extends RecursiveFilterIterator {
3636
function __construct(){}
37-
function accept(){}
37+
function accept(): bool {}
3838
}
3939
test( function() {
4040
$o = new RecursiveFilterIteratorTest;

ext/spl/tests/bug69970.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator {
99
function rewind(): void {
1010
echo "dummy\n";
1111
}
12-
function endChildren() {
12+
function endChildren(): void {
1313
global $count;
1414
echo $this->getDepth();
1515
if (--$count > 0) {

ext/spl/tests/bug73423.phpt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,39 @@ class foo implements \RecursiveIterator
77
{
88
public $foo = [];
99

10-
public Function current ()
10+
public Function current(): mixed
1111
{
1212
return current ($this->foo);
1313
}
1414

15-
public Function key ()
15+
public Function key(): mixed
1616
{
1717
return key ($this->foo);
1818
}
1919

20-
public Function next ()
20+
public Function next(): void
2121
{
2222
next ($this->foo);
2323
}
2424

25-
public Function rewind ()
25+
public Function rewind(): void
2626
{
2727
reset ($this->foo);
2828
}
2929

30-
public Function valid ()
30+
public Function valid(): bool
3131
{
3232
return current ($this->foo) !== false;
3333
}
3434

35-
public Function getChildren ()
35+
public Function getChildren(): ?RecursiveIterator
3636
{
3737
return current ($this->foo);
3838
}
3939

40-
public Function hasChildren ()
40+
public Function hasChildren(): bool
4141
{
42-
return (bool) count ($this->foo);
42+
return (bool) count($this->foo);
4343
}
4444
}
4545

@@ -53,7 +53,7 @@ class fooIterator extends \RecursiveFilterIterator
5353
/* CRASH */
5454
}
5555

56-
public Function accept ()
56+
public Function accept(): bool
5757
{
5858
return true;
5959
}

ext/spl/tests/bug74669.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ class Container implements Iterator
1919
$this->container->append($element);
2020
}
2121

22-
public function current()
22+
public function current(): mixed
2323
{
2424
return $this->iterator->current();
2525
}
2626

27-
public function next()
27+
public function next(): void
2828
{
2929
$this->iterator->next();
3030
}
3131

32-
public function key()
32+
public function key(): mixed
3333
{
3434
return $this->iterator->key();
3535
}
3636

37-
public function valid()
37+
public function valid(): bool
3838
{
3939
return $this->iterator->valid();
4040
}

0 commit comments

Comments
 (0)