Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100723 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65823 invoked from network); 20 Sep 2017 17:17:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Sep 2017 17:17:55 -0000 Authentication-Results: pb1.pair.com header.from=lists@rhsoft.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=lists@rhsoft.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain rhsoft.net designates 91.118.73.15 as permitted sender) X-PHP-List-Original-Sender: lists@rhsoft.net X-Host-Fingerprint: 91.118.73.15 mail.thelounge.net Received: from [91.118.73.15] ([91.118.73.15:48053] helo=mail.thelounge.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/E9-62331-3C2A2C95 for ; Wed, 20 Sep 2017 13:17:55 -0400 Received: from srv-rhsoft.rhsoft.net (Authenticated sender: h.reindl@thelounge.net) by mail.thelounge.net (THELOUNGE MTA) with ESMTPSA id 3xy5zM23XzzXMf for ; Wed, 20 Sep 2017 19:17:51 +0200 (CEST) To: internals@lists.php.net References: <0040eda1-f2d4-408e-a3e1-fe3daf756dfd@Spark> Message-ID: Date: Wed, 20 Sep 2017 19:17:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <0040eda1-f2d4-408e-a3e1-fe3daf756dfd@Spark> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-CH Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Consistent null behaviour From: lists@rhsoft.net ("lists@rhsoft.net") 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 a `null` value returns `null` without any warning whatsoever. > Accessing the property of a `null` value gives you a notice, while calling a function on that `null` value 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 a `null` value. > > 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 function 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]; }