Skip to content

Declare tentative return types for ext/spl - part 1 #7115

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 5 commits into from
Jul 13, 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
8 changes: 4 additions & 4 deletions Zend/tests/foreach_004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class IT extends ArrayIterator {
}
}

function rewind() {$this->trap(__FUNCTION__); return parent::rewind();}
function valid() {$this->trap(__FUNCTION__); return parent::valid();}
function key() {$this->trap(__FUNCTION__); return parent::key();}
function next() {$this->trap(__FUNCTION__); return parent::next();}
function rewind(): void {$this->trap(__FUNCTION__); parent::rewind();}
function valid(): bool {$this->trap(__FUNCTION__); return parent::valid();}
function key(): mixed {$this->trap(__FUNCTION__); return parent::key();}
function next(): void {$this->trap(__FUNCTION__); parent::next();}
}

foreach(['rewind', 'valid', 'key', 'next'] as $trap) {
Expand Down
1 change: 1 addition & 0 deletions Zend/tests/iterator_key_by_ref.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Iterator::key() with by-ref return
--FILE--
<?php
class Test extends ArrayIterator {
#[ReturnTypeWillChange]
function &key() {
return $foo;
}
Expand Down
10 changes: 5 additions & 5 deletions ext/phar/tests/phar_oo_004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,31 @@ class MyDirectoryIterator extends DirectoryIterator
parent::__construct($dir);
}

function rewind()
function rewind(): void
{
echo __METHOD__ . "\n";
parent::rewind();
}

function valid()
function valid(): bool
{
echo __METHOD__ . "\n";
return parent::valid();
}

function key()
function key(): mixed
{
echo __METHOD__ . "\n";
return parent::key();
}

function current()
function current(): mixed
{
echo __METHOD__ . "\n";
return parent::current();
}

function next()
function next(): void
{
echo __METHOD__ . "\n";
parent::next();
Expand Down
12 changes: 7 additions & 5 deletions ext/phar/tests/phar_oo_008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,47 @@ foreach($f as $k => $v)

class MyCSVFile extends SplFileObject
{
function current()
function current(): array|false
{
return parent::fgetcsv(',', '"');
}
}

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

echo "===3===\n";
while(!$v->eof())
{
echo $v->key() . "=>" . join('|',$v->fgetcsv()) . "\n";
echo $v->key() . "=>" . join('|', $v->fgetcsv()) . "\n";
}

echo "===4===\n";
$v->rewind();
while(!$v->eof())
{
$l = $v->fgetcsv();
echo $v->key() . "=>" . join('|',$l) . "\n";
echo $v->key() . "=>" . join('|', $l) . "\n";
}

echo "===5===\n";
foreach($v as $k => $d)
{
echo "$k=>" . join('|',$d) . "\n";
echo "$k=>" . join('|', $d) . "\n";
}

class MyCSVFile2 extends SplFileObject
{
function getCurrentLine()
function getCurrentLine(): string
{
echo __METHOD__ . "\n";
return implode('|', parent::fgetcsv(',', '"'));
}
}

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

echo "===6===\n";
Expand Down
Loading