Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86513 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70135 invoked from network); 9 Jun 2015 10:04:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jun 2015 10:04:51 -0000 Authentication-Results: pb1.pair.com header.from=php_lists@realplain.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php_lists@realplain.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain realplain.com from 216.33.127.80 cause and error) X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 216.33.127.80 mta11.charter.net Solaris 10 1203 Received: from [216.33.127.80] ([216.33.127.80:48891] helo=mta11.charter.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/60-00828-24AB6755 for ; Tue, 09 Jun 2015 06:04:50 -0400 Received: from imp11 ([10.20.200.11]) by mta11.charter.net (InterMail vM.8.01.05.09 201-2260-151-124-20120717) with ESMTP id <20150609100447.NUCO5815.mta11.charter.net@imp11>; Tue, 9 Jun 2015 06:04:47 -0400 Received: from mtaout001.msg.strl.va.charter.net ([68.114.190.26]) by imp11 with smtp.charter.net id eA4n1q0050adFl805A4nsF; Tue, 09 Jun 2015 06:04:47 -0400 Received: from impout003 ([68.114.189.18]) by mtaout001.msg.strl.va.charter.net (InterMail vM.9.00.018.00 201-2473-151) with ESMTP id <20150609100447.BXMT7015.mtaout001.msg.strl.va.charter.net@impout003>; Tue, 9 Jun 2015 05:04:47 -0500 Received: from pc1 ([96.35.251.86]) by impout003 with charter.net id eA4m1q0081sc0so01A4mZx; Tue, 09 Jun 2015 05:04:47 -0500 X-Authority-Analysis: v=2.1 cv=f4/GBYCM c=1 sm=1 tr=0 a=Is5gsZaFXO8aPum+t7Tz+g==:117 a=Is5gsZaFXO8aPum+t7Tz+g==:17 a=hOpmn2quAAAA:8 a=N659UExz7-8A:10 a=BCPeO_TGAAAA:8 a=pGLkceISAAAA:8 a=-jIKvPZ-j2xWKeoxGMgA:9 a=pILNOxqGKmIA:10 Message-ID: <778F345F9918474AB8CAAB03082ECBF7@pc1> To: "Yasuo Ohgaki" , "Stanislav Malyshev" Cc: "Christoph Becker" , References: <5576051A.3040800@gmx.de> <55760771.6020802@gmail.com> Date: Tue, 9 Jun 2015 05:04:46 -0500 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Subject: Re: [PHP-DEV] Array dereferencing of scalars From: php_lists@realplain.com ("Matt Wilmas") Hi all, ----- Original Message ----- From: "Yasuo Ohgaki" Sent: Tuesday, June 09, 2015 > Hi all, > > On Tue, Jun 9, 2015 at 6:21 AM, Stanislav Malyshev > wrote: > >> > Would throwing a notice or a warning on array deferencing scalars >> > be acceptable for PHP 7.0, or does this need an RFC? >> >> I think this does need an RFC, and for 7.0, pretty much no new language >> changes are acceptable anymore, since we're past the timeframe. > > > $foo = 42; > $foo['bar']; // => NULL > > This code cannot be right. > How about fix this as a simple bug? I just realized this behavior a couple months ago, after being annoyed by "needing" to use isset() to avoid a Notice in rare cases. (I've always hate, hate, hated the isset() mess just trying to assign stuff -- I wanted a value-returning IFset() instead! Now we have ??, but still can't do var_dump($var ??).) Anyway, I realized after checking the code that this is actually intentional and always has been, it seems. Really glad that I could rely on this and it makes things simpler and cleaner! :-) Note that I'm referring to accessing NULL as an array (that I'd like to rely on). The other bool/int scalar without-a-notice case did/does seem a bit odd. So if there's a change, how about only changing it for non-NULL values? Otherwise, this: $v = NULL; $v[0][1][2][3][4][5][6][7][8][9]; is supposed to give 10 Notices?! That's dumb, and ugly, and looks like what the Pull Request is doing with the updated tests. Even worse in the case where the variable is undefined... > Regards, > > -- > Yasuo Ohgaki Thanks, Matt