Skip to content

Commit 5dea01e

Browse files
committed
Declare tentative return types in ext/spl - part 3
1 parent 5535741 commit 5dea01e

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

+430
-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: 115 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
}

ext/spl/tests/bug77263.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ touch("$dir/file1");
99
touch("$dir/subdir/file2");
1010

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

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

1919
$iterator = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS );

ext/spl/tests/iterator_001.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@ class NumericArrayIterator implements Iterator
2020
$this->i = 0;
2121
}
2222

23-
public function valid()
23+
public function valid(): bool
2424
{
2525
$ret = $this->i < count($this->a);
2626
echo __METHOD__ . '(' . ($ret ? 'true' : 'false') . ")\n";
2727
return $ret;
2828
}
2929

30-
public function key()
30+
public function key(): mixed
3131
{
3232
echo __METHOD__ . "\n";
3333
return $this->i;
3434
}
3535

36-
public function current()
36+
public function current(): mixed
3737
{
3838
echo __METHOD__ . "\n";
3939
return $this->a[$this->i];
4040
}
4141

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

5555
class SeekableNumericArrayIterator extends NumericArrayIterator implements SeekableIterator
5656
{
57-
public function seek($index)
57+
public function seek($index): void
5858
{
5959
if ($index < count($this->a)) {
6060
$this->i = $index;

ext/spl/tests/iterator_003.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/iterator_004.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@ class NumericArrayIterator implements Iterator
2020
$this->i = 0;
2121
}
2222

23-
public function valid()
23+
public function valid(): bool
2424
{
2525
$ret = $this->i < count($this->a);
2626
echo __METHOD__ . '(' . ($ret ? 'true' : 'false') . ")\n";
2727
return $ret;
2828
}
2929

30-
public function key()
30+
public function key(): mixed
3131
{
3232
echo __METHOD__ . "\n";
3333
return $this->i;
3434
}
3535

36-
public function current()
36+
public function current(): mixed
3737
{
3838
echo __METHOD__ . "\n";
3939
return $this->a[$this->i];
4040
}
4141

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

4949
class SeekableNumericArrayIterator extends NumericArrayIterator implements SeekableIterator
5050
{
51-
public function seek($index)
51+
public function seek($index): void
5252
{
5353
if ($index < count($this->a)) {
5454
$this->i = $index;

ext/spl/tests/iterator_007.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ class NoRewindIteratorEx extends NoRewindIterator
3939
echo __METHOD__ . "\n";
4040
parent::rewind();
4141
}
42-
function valid()
42+
function valid(): bool
4343
{
4444
echo __METHOD__ . "\n";
4545
return parent::valid();
4646
}
47-
function current()
47+
function current(): mixed
4848
{
4949
echo __METHOD__ . "\n";
5050
return parent::current();
5151
}
52-
function key()
52+
function key(): mixed
5353
{
5454
echo __METHOD__ . "\n";
5555
return parent::key();
5656
}
57-
function next()
57+
function next(): void
5858
{
5959
echo __METHOD__ . "\n";
6060
parent::next();

ext/spl/tests/iterator_009.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ SPL: EmptyIterator
55

66
class EmptyIteratorEx extends EmptyIterator
77
{
8-
function rewind()
8+
function rewind(): void
99
{
1010
echo __METHOD__ . "\n";
1111
parent::rewind();
1212
}
13-
function valid()
13+
function valid(): bool
1414
{
1515
echo __METHOD__ . "\n";
1616
return parent::valid();
1717
}
18-
function current()
18+
function current(): never
1919
{
2020
echo __METHOD__ . "\n";
21-
return parent::current();
21+
parent::current();
2222
}
23-
function key()
23+
function key(): never
2424
{
2525
echo __METHOD__ . "\n";
26-
return parent::key();
26+
parent::key();
2727
}
28-
function next()
28+
function next(): void
2929
{
3030
echo __METHOD__ . "\n";
3131
parent::next();

0 commit comments

Comments
 (0)