Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56943 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24292 invoked from network); 18 Dec 2011 03:32:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Dec 2011 03:32:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:48069] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 98/23-33228-7CE5DEE4 for ; Sat, 17 Dec 2011 22:32:24 -0500 Received: by vcdn13 with SMTP id n13so2532849vcd.29 for ; Sat, 17 Dec 2011 19:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=30uYGdjzgJKN2VL4NGjuMzDf0dVQMt/9Ts1Pfa6VHGI=; b=k9B2TtrDeeFzKrFR/V91Jlrl6GihnIpv41XBYLXK7RRKpa/P52tHaRFqjK2Q0956zn hHD9p66O8VdxYKad8M6ExLFCGjxgITokIhI5015YSCGOvNZpTA/vJ3A8p8r55lFCylzG KuK70pw5K2d7f3cm3tqwNGcIzrAcRDspVp+Qc= Received: by 10.220.108.66 with SMTP id e2mr7012207vcp.9.1324179140234; Sat, 17 Dec 2011 19:32:20 -0800 (PST) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.220.3.14 with HTTP; Sat, 17 Dec 2011 19:31:59 -0800 (PST) In-Reply-To: <4EED2BD0.7080903@sugarcrm.com> References: <4EDA4989.2010702@akbkhome.com> <4EDC015C.3080701@akbkhome.com> <4EED2BD0.7080903@sugarcrm.com> Date: Sun, 18 Dec 2011 11:31:59 +0800 X-Google-Sender-Auth: 22bPKXv3LQfqn8ecOKRFSlovJP8 Message-ID: To: Stas Malyshev Cc: Alan Knowles , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Fixing string offsets of strings. From: laruence@php.net (Laruence) On Sun, Dec 18, 2011 at 7:54 AM, Stas Malyshev wro= te: > Hi! > > I think the idea behind this patch is good. I'll do final checks and appl= y > it tomorrow if no objections heard until then. > > Some notes: > > >> $s =3D "string"; =C2=A0isset($s['offset']) returns false >> This is pretty critical, as it's the only way to detect this situation, >> and ensure that array tests do not return positive results for strings. >> It also catches an obvious, but previously hidden and probably serious >> bugs in the PHP code.. > > > This change concerns me a bit since it's a behavior change and provided t= hat > most of the people aren't actually aware that $s['offset'] means $s[0] it > may lead to subtle code breakage. Then again, doing $s['offset'] leads to > code breakage right now - I just encountered another bug caused by this i= n > production code mere days ago, code was checking that $s['offset'] is set > without actually checking that $s is an array, and it happened to be not.= .. > > >> $s =3D "string"; =C2=A0$s[' =C2=A02 =C2=A0']; and $s['2foo'] both emit e= rrors, and return >> false from isset() - the code pretty much uses is_numeric() internally. >> - I'm pretty sure these would be un-intentional bugs, so behaving as >> such seems consistent. > > > Agreed, I think is_numeric is the right way. > > >> I do not mind either way if $s['offset'] returns the first char or an >> empty string, however it seemed a little inconstant to return false on > > > Here I am conflicted. The right thing would be to return empty but it may > cause some breakage. Then again, doing what we do now causes breakage rig= ht > now too (not new in 5.4, same breakage happening in 5.3 too) so I'm incli= ned > to go with false here unless somebody gives me a use case where it's usef= ul > for anything. > > >> isset(), yet actually return a string. (although technically an empty >> string does kind of indicate it is 'isset') - it at least leaves the >> engine in a consistent state. Perhaps that change can wait's until 5.5.. >> thoughts... >> >> As for dropping the syntax for Strings eventually.. It would be nice, >> but I'm not sure it is feasible anymore unfortunately. > > > We tried to move to {} syntax but that didn't work, and probably isn't > possible anymore without massive breakage. > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > Hi: I think only trigger notice when a convertion of string to number index is a good way (trivial bc break). :) thanks > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --=20 Laruence =C2=A0Xinchen Hui http://www.laruence.com/