Skip to content

Commit c6357b8

Browse files
authored
Declare tentative return types for ext/spl - part 1 (#7115)
1 parent a2845e3 commit c6357b8

Some content is hidden

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

64 files changed

+583
-575
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
@@ -31,31 +31,31 @@ class MyDirectoryIterator extends DirectoryIterator
3131
parent::__construct($dir);
3232
}
3333

34-
function rewind()
34+
function rewind(): void
3535
{
3636
echo __METHOD__ . "\n";
3737
parent::rewind();
3838
}
3939

40-
function valid()
40+
function valid(): bool
4141
{
4242
echo __METHOD__ . "\n";
4343
return parent::valid();
4444
}
4545

46-
function key()
46+
function key(): mixed
4747
{
4848
echo __METHOD__ . "\n";
4949
return parent::key();
5050
}
5151

52-
function current()
52+
function current(): mixed
5353
{
5454
echo __METHOD__ . "\n";
5555
return parent::current();
5656
}
5757

58-
function next()
58+
function next(): void
5959
{
6060
echo __METHOD__ . "\n";
6161
parent::next();

ext/phar/tests/phar_oo_008.phpt

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

3232
class MyCSVFile extends SplFileObject
3333
{
34-
function current()
34+
function current(): array|false
3535
{
3636
return parent::fgetcsv(',', '"');
3737
}
3838
}
3939

4040
$phar->setInfoClass('MyCSVFile');
41+
/** @var MyCSVFile $v */
4142
$v = $phar['a.csv'];
4243

4344
echo "===3===\n";
4445
while(!$v->eof())
4546
{
46-
echo $v->key() . "=>" . join('|',$v->fgetcsv()) . "\n";
47+
echo $v->key() . "=>" . join('|', $v->fgetcsv()) . "\n";
4748
}
4849

4950
echo "===4===\n";
5051
$v->rewind();
5152
while(!$v->eof())
5253
{
5354
$l = $v->fgetcsv();
54-
echo $v->key() . "=>" . join('|',$l) . "\n";
55+
echo $v->key() . "=>" . join('|', $l) . "\n";
5556
}
5657

5758
echo "===5===\n";
5859
foreach($v as $k => $d)
5960
{
60-
echo "$k=>" . join('|',$d) . "\n";
61+
echo "$k=>" . join('|', $d) . "\n";
6162
}
6263

6364
class MyCSVFile2 extends SplFileObject
6465
{
65-
function getCurrentLine()
66+
function getCurrentLine(): string
6667
{
6768
echo __METHOD__ . "\n";
6869
return implode('|', parent::fgetcsv(',', '"'));
6970
}
7071
}
7172

7273
$phar->setInfoClass('MyCSVFile2');
74+
/** @var MyCSVFile2 $v */
7375
$v = $phar['a.csv'];
7476

7577
echo "===6===\n";

0 commit comments

Comments
 (0)