Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56525 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75081 invoked from network); 23 Nov 2011 19:10:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Nov 2011 19:10:48 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:42155] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 56/74-47904-7354DCE4 for ; Wed, 23 Nov 2011 14:10:47 -0500 Received: by qabg40 with SMTP id g40so3024869qab.8 for ; Wed, 23 Nov 2011 11:10:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=jG+ZkyopQ5PVF1Z0uuViq6QAMKlZ3+LW8TJcd/D1ivY=; b=kxYiLwnRvFwzYOnjBkb5cWH4K4j5ABhj0rmrh9UrYzPe7QuKkgGUbF3XJhJw8BFZyK Rmo6jSp0agpZZkwa76lN2YigN1MIlsacmepAfZSbEiSVoEH7OCcEmVsOoWJ1s1060Z6K 0Tn3pIIpW2kVuxCJktBS5o9DlJvOg8pXmOeMs= MIME-Version: 1.0 Received: by 10.224.52.81 with SMTP id h17mr11818739qag.9.1322075444134; Wed, 23 Nov 2011 11:10:44 -0800 (PST) Received: by 10.229.38.134 with HTTP; Wed, 23 Nov 2011 11:10:43 -0800 (PST) In-Reply-To: <4ECD40E2.1000601@sugarcrm.com> References: <20111123015008.GA12933@panix.com> <20111123023108.GA172@panix.com> <4ECCB549.904@lsces.co.uk> <4ECCBC56.3050602@sugarcrm.com> <20111123141408.GA11940@panix.com> <4ECD40E2.1000601@sugarcrm.com> Date: Wed, 23 Nov 2011 20:10:43 +0100 Message-ID: To: Stas Malyshev Cc: Daniel Convissor , Lester Caine , PHP internals Content-Type: multipart/alternative; boundary=20cf3074b93c36c42204b26bad52 Subject: Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values From: tyra3l@gmail.com (Ferenc Kovacs) --20cf3074b93c36c42204b26bad52 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, Nov 23, 2011 at 7:52 PM, Stas Malyshev wrot= e: > Hi! > > > On 11/23/11 6:14 AM, Daniel Convissor wrote: > >> To me, this is the bug. $a['blah'] does not exist. An undefined index >> > > If it's a bug, this bug was in PHP since forever, nothing new here. > > > notice should be raised. The key "blah" should not be converted to 0. >> The following two things should behave the same: >> >> $b =3D array('exists' =3D> 'foo'); >> echo $b['blah'] . "\n"; >> >> $a =3D 'foo'; >> echo $a['blah'] . "\n"; >> > > No they should not. First is array access, second is string offset access= , > totally different ops. That's like saying + on arrays should calculate th= e > sum of all array elements because + on numbers calculates the sum. > Operators have different meanings for different types, it has always been > so in all languages. > One could argue that string access with non-string should produce a > notice, but probably if we added that a lot of people would come out to > complain we broke their perfectly working code ;) I think that it would make sense. I mean using $foo['asd'] where $foo is a string is as likely to be a hidden application bug as the array() =3D> 'Array' conversion that we patched recently to trigger a warning. More clarification for the others who seems to be miss how specific this change is: The only case where the 5.4 branch works differently as before if you reference a string type(int, float, etc. won't trigger this) variable using an associative index and you expect it that to be undefined variable even though that the documentation explicitly states that the index will be converted to an integer in this case. for example: $foo =3D 'string'; echo isset($foo['bar']); will return true (as $foo['bar'] will converted to $foo[0] which returns 's' in this case) in 5.4 while it returned false previously. ps: on a sidenote: the same change also introduces that using the following: $foo[0][0][0]... on a non-empty string will be always valid, before this change it produced a "PHP Fatal error: Cannot use string offset as an array" --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --20cf3074b93c36c42204b26bad52--