Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92223 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6671 invoked from network); 12 Apr 2016 13:01:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Apr 2016 13:01:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=ivan.enderlin@hoa-project.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ivan.enderlin@hoa-project.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hoa-project.net from 217.70.178.86 cause and error) X-PHP-List-Original-Sender: ivan.enderlin@hoa-project.net X-Host-Fingerprint: 217.70.178.86 slow1-d.mail.gandi.net Received: from [217.70.178.86] ([217.70.178.86:34316] helo=slow1-d.mail.gandi.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 16/AB-28094-FB1FC075 for ; Tue, 12 Apr 2016 09:01:52 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by slow1-d.mail.gandi.net (Postfix) with ESMTP id 3445C4961D5 for ; Tue, 12 Apr 2016 15:01:49 +0200 (CEST) X-Originating-IP: 46.14.238.241 Received: from [10.0.1.128] (241.238.14.46.static.wline.lns.sme.cust.swisscom.ch [46.14.238.241]) (Authenticated sender: ivan.enderlin@hoa-project.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 4CDCBFB91B for ; Tue, 12 Apr 2016 15:01:40 +0200 (CEST) To: internals@lists.php.net References: Message-ID: <570CF1B3.3070303@hoa-project.net> Date: Tue, 12 Apr 2016 15:01:39 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Array key access on non-array values - to be made illegal? From: ivan.enderlin@hoa-project.net (Ivan Enderlin) Hello Marco, Actually, you are trying to access to something that does not exist, so you get a null value. This part is logical. However, yes, a notice would be welcomed except it may be skipped for historical reasons I reckon. Probably to work well with `isset` or similar scenario. Cheers. On 12/04/16 14:59, Marco Pivetta wrote: > Hello, > > I just stumbled upon behavior that seems to "fail silently" regardless of > its very questionable validity: > > > $a = 1; > > var_dump($a[123]); // NULL, no notice > > https://3v4l.org/b3rDr > > Are there specific reasons why no notice is thrown? Is it by design? If so, > does anyone remember why? > > I haven't checked if this affects other types too. I know that an > assignment to an array key of a non-array would cause a cast of the value > to `array`, but a mere read operation should surely cause a notice to be > raised in the above scenario. > > Cheers, > > Marco Pivetta > > http://twitter.com/Ocramius > > http://ocramius.github.com/ >