note 128190 added to language.oop5.iterations

From: Date: Sun, 05 Feb 2023 08:32:30 +0000
Subject: note 128190 added to language.oop5.iterations
Groups: php.notes 
Request: Send a blank email to php-notes+get-220147@lists.php.net to get a copy of this message
The days of lovely care-to-the-wind typecasting are coming to close. Finding this devilish bug took us entirely too long. PHP-8.2.1 was throwing errors seemingly uncaught (they were eventually seen amassing in / var / log / apache / DOMAIN-ssl-err.log ) due to mismatch between return types of the necessary interface methods in our 'implements \Iterator' class (which had worked fine for many years, until our leap up to 8.2.1) versus the interface methods required by PHP. Particularly: next() ===== ours: public function next() {...} PHP-8.2.1's public function next() : void {...} valid() ====== ours: public function valid() {...} PHP-8.2.1's: public function valid() : bool {...} key() ==== ours: public function key() {...} PHP-8.2.1's: public function key() : mixed {...} rewind() ======== ours: public function rewind() {...} PHP-8.2.1's: public function rewind() : void {...} current() ======= ours: public function current() {...} PHP-8.2.1's: public function current() : mixed {...} We added the missing / now all-important return types to our function/method declarations and everything instantly worked again. This extreme stringency is not made clear enough, IMHO, in the Iterator manual page. ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.158.213 (proxied: 138.88.64.2) ---- Manual Page -- https://php.net/manual/en/language.oop5.iterations.php Edit -- https://main.php.net/note/edit/128190 Del: integrated -- https://main.php.net/note/delete/128190/integrated Del: useless -- https://main.php.net/note/delete/128190/useless Del: bad code -- https://main.php.net/note/delete/128190/bad+code Del: spam -- https://main.php.net/note/delete/128190/spam Del: non-english -- https://main.php.net/note/delete/128190/non-english Del: in docs -- https://main.php.net/note/delete/128190/in+docs Del: other reasons-- https://main.php.net/note/delete/128190 Reject -- https://main.php.net/note/reject/128190 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220147) next »