Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56768 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75674 invoked from network); 4 Dec 2011 16:55:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Dec 2011 16:55:55 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.211.66 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.211.66 config.schlueters.de Received: from [217.114.211.66] ([217.114.211.66:52806] helo=config.schlueters.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/B1-65129-816ABDE4 for ; Sun, 04 Dec 2011 11:55:54 -0500 Received: from [192.168.2.230] (ppp-93-104-32-135.dynamic.mnet-online.de [93.104.32.135]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by config.schlueters.de (Postfix) with ESMTPSA id 03DD35874D; Sun, 4 Dec 2011 17:55:48 +0100 (CET) To: Alan Knowles Cc: PHP Internals List In-Reply-To: <4EDA4989.2010702@akbkhome.com> References: <4EDA4989.2010702@akbkhome.com> Content-Type: text/plain; charset="UTF-8" Date: Sun, 04 Dec 2011 17:55:42 +0100 Message-ID: <1323017742.18817.3.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Fixing string offsets of strings. From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Sun, 2011-12-04 at 00:08 +0800, Alan Knowles wrote: > This patch is a start. > https://bugs.php.net/patch-display.php?bug_id=60362&patch=first_effort_to_fix_this&revision=latest > > It's been quite a while since I hacked on the engine, so the patch only > works reasonably well.. (see the FIXME on the tests at the bottom of the > patch.) > > The patch changes the following: > * $s = "string"; $s['offset'] -- produces a warning (and returns an > empty string) > * $s = "string"; $s['1'] -- works as before.. > * $s = "string"; $s[true] $s[false] $s[0.1] -- give a notice (cast it > to an int if you want to get rid of the notice) - however work as before. > * changes the warning on invalid indexes to say "Uninitialized or > invalid" rather than just "Uninitialized" > * fixes most of the related tests I think it's bad to add another set of casting rules to the language. I'd prefer splitting the string offset operator from array offset. $a = [0,1,2,3]; $s = "string"; $a{0}; // wrong $s{0}; // ok $a[0]; // ok $s[0]; // wrong Yes, something like this has been discussed before, back and forth and doing this is too late for 5.4, but let's look to 5.5. johannes