Skip to content

Commit 50d8809

Browse files
committed
Declare tentative return types for ext/spl - part 1
1 parent b8e380a commit 50d8809

Some content is hidden

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

62 files changed

+567
-564
lines changed

Zend/tests/foreach_004.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class IT extends ArrayIterator {
1616
}
1717
}
1818

19-
function rewind() {$this->trap(__FUNCTION__); return parent::rewind();}
20-
function valid() {$this->trap(__FUNCTION__); return parent::valid();}
21-
function key() {$this->trap(__FUNCTION__); return parent::key();}
22-
function next() {$this->trap(__FUNCTION__); return parent::next();}
19+
function rewind(): void {$this->trap(__FUNCTION__); parent::rewind();}
20+
function valid(): bool {$this->trap(__FUNCTION__); return parent::valid();}
21+
function key(): mixed {$this->trap(__FUNCTION__); return parent::key();}
22+
function next(): void {$this->trap(__FUNCTION__); parent::next();}
2323
}
2424

2525
foreach(['rewind', 'valid', 'key', 'next'] as $trap) {

Zend/tests/iterator_key_by_ref.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Iterator::key() with by-ref return
33
--FILE--
44
<?php
55
class Test extends ArrayIterator {
6+
#[ReturnTypeWillChange]
67
function &key() {
78
return $foo;
89
}

ext/phar/tests/phar_oo_004.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,31 @@ class MyDirectoryIterator extends DirectoryIterator
3333
parent::__construct($dir);
3434
}
3535

36-
function rewind()
36+
function rewind(): void
3737
{
3838
echo __METHOD__ . "\n";
3939
parent::rewind();
4040
}
4141

42-
function valid()
42+
function valid(): bool
4343
{
4444
echo __METHOD__ . "\n";
4545
return parent::valid();
4646
}
4747

48-
function key()
48+
function key(): mixed
4949
{
5050
echo __METHOD__ . "\n";
5151
return parent::key();
5252
}
5353

54-
function current()
54+
function current(): mixed
5555
{
5656
echo __METHOD__ . "\n";
5757
return parent::current();
5858
}
5959

60-
function next()
60+
function next(): void
6161
{
6262
echo __METHOD__ . "\n";
6363
parent::next();

ext/phar/tests/phar_oo_008.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ foreach($f as $k => $v)
3131

3232
class MyCSVFile extends SplFileObject
3333
{
34-
function current()
34+
function current(): string|array|false
3535
{
3636
return parent::fgetcsv(',', '"');
3737
}
@@ -62,10 +62,10 @@ foreach($v as $k => $d)
6262

6363
class MyCSVFile2 extends SplFileObject
6464
{
65-
function getCurrentLine()
65+
function getCurrentLine(): string
6666
{
6767
echo __METHOD__ . "\n";
68-
return parent::fgetcsv(',', '"');
68+
return (string) parent::fgetcsv(',', '"');
6969
}
7070
}
7171

0 commit comments

Comments
 (0)