Re: [RFC] Consistent null behaviour
| From: | lists@rhsoft.net | Date: | Wed, 20 Sep 2017 17:17:50 +0000 |
| Subject: | Re: [RFC] Consistent null behaviour | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-100723@lists.php.net to get a copy of this message | ||
Am 20.09.2017 um 19:06 schrieb ilija.tovilo@me.com:
Hi everybody! To my surprise, I noticed today that an array access on afunction GetSKatMaxSort(int $archive=0): int { return (int)mysqli_fetch_row($this->db->query("select SQL_NO_CACHE max(ssort) from {$this->db->table} where sarchive=$archive", 1))[0]; }nullvalue returnsnullwithout any warning whatsoever. Accessing the property of anullvalue gives you a notice, while calling a function on thatnullvalue gives you a fatal error. https://3v4l.org/ZSZHN This is pretty inconsistent. IMO all of these should be fatal errors, although I realize that might be a bit drastic for PHP 8. We should at least give the user a notice when using array access on anullvalue. Any thoughts? wouldn't that break code like below which is IMHO the best usecase of the PHP 5.6 feature that you can directly access a array field of a function result and the type-casting encsues that the return-type is always int