mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 08:28:54 +00:00
Fix Iterator example for PHP 8.1+
The newly introduced tentative return types require us to specify return types for the method implementation. Since `mixed` is only available as of PHP 8.0.0, we use the `ReturnTypeWillChange` attribute to suppress the deprecation for now. This includes user note 127109 (well, at least the actionable part of it).
This commit is contained in:
parent
cfaa7659da
commit
214335df7e
1 changed files with 5 additions and 3 deletions
|
@ -77,27 +77,29 @@ class myIterator implements Iterator {
|
|||
$this->position = 0;
|
||||
}
|
||||
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
var_dump(__METHOD__);
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
var_dump(__METHOD__);
|
||||
return $this->array[$this->position];
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
var_dump(__METHOD__);
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
var_dump(__METHOD__);
|
||||
++$this->position;
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
var_dump(__METHOD__);
|
||||
return isset($this->array[$this->position]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue