note 127109 deleted from class.iterator by cmb
| From: | cmb@php.net | Date: | Tue, 17 May 2022 12:03:16 +0000 |
| Subject: | note 127109 deleted from class.iterator by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218483@lists.php.net to get a copy of this message | ||
Note Submitter: Zeomni
----
WARNING : due to new PhP 8 feature, "internal method return type"
Example of the documentation and All comment before 2022 on this page are raising some Deprecated
warning, or fatal error on PhP 9.0
You now have to type all your return implementation:
Example for key() you must add ": mixed", else it will raise on PhP8.1 :
Return type of myIterator::key() should either be compatible with Iterator::key(): mixed, or the
#[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice.
<?php
public function key(): mixed {
var_dump(__METHOD__);
return $this->position;
}
?>
Please note the adding the [#\ReturnTypeWillChange] is not a long term solution, as PhP 9.0 will
raise a fatal and not a warning.