Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86603 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27420 invoked from network); 11 Jun 2015 23:36:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jun 2015 23:36:17 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.66 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.66 mail-wg0-f66.google.com Received: from [74.125.82.66] ([74.125.82.66:33362] helo=mail-wg0-f66.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/55-31453-B5B1A755 for ; Thu, 11 Jun 2015 19:35:56 -0400 Received: by wggy19 with SMTP id y19so5537609wgg.0 for ; Thu, 11 Jun 2015 16:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=3kbbj0LaK8tA9CZuRce4543BiievCstY5Uok4FuikTw=; b=uCsYJ1Jn1Run9LSfRXCJ9jxt3l77yHjJQdrqULlKsk6C7EmtNaSDtYjwOYt581CzHW C1faQaI1Y8xGjCj5FOTcYRjW8DN+6WB9OkZvIbmKJWmMOApEjgGR9tihJiIUmTtBNxlu 2OMg/CW8yi46lU2oY2P5kTDq1ErDdl9tFr+SFOI1uiNblAjtAWunpJcjKKM7u4VyviD4 jAXeGZVtqMrCtdb6oNApfx7ckSpLbaYe6dXLtWFno01sHhLWNPICDyh8IPF+LGYg+cc2 SmpR23OJaOlQKczks13LVzUAeWokhUIwDibGV9C5f7W268wEJeuL7IRl8bmMwm82v7PQ V+cw== X-Received: by 10.181.13.172 with SMTP id ez12mr1161802wid.91.1434065753118; Thu, 11 Jun 2015 16:35:53 -0700 (PDT) Received: from [192.168.0.5] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id gz3sm869284wib.0.2015.06.11.16.35.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jun 2015 16:35:52 -0700 (PDT) Message-ID: <557A1B52.1050501@gmail.com> Date: Fri, 12 Jun 2015 00:35:46 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: PHP Internals List References: <5576051A.3040800@gmx.de> <55760771.6020802@gmail.com> <778F345F9918474AB8CAAB03082ECBF7@pc1> <5577DEE4.8030205@gmail.com> <55794DE2.2080602@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Array dereferencing of scalars From: rowan.collins@gmail.com (Rowan Collins) On 11/06/2015 21:22, Chris Wright wrote: > I'm inclined to agree that we should have consistency here, and that > the current behaviour in a function context is the correct one. A > couple of (IMO) good arguments for this: > > - The function behaviour gives a more explanatory and useful error message > - This is definitely a programming error, there is no valid reason to > use NULL as a variable name in this manner. It amounts to what > many/most other languages would consider to be a "null pointer > exception" or equivalent, and the more useful error message may help > track down the error quicker (one might look for a case where the > empty string was assigned, instead of looking for a case where it may > be NULL). Well, if you were to model it precisely on the function case, the *consistent* behaviour would be to error on any non-string value (e.g. $v = 42; $$v;) but not a string which is an illegal variable name ($v = '42'; $v(); just complains that function 42 doesn't exist, not that it never could). A more useful approach would perhaps be to look at what should be a valid function name, and what should be a valid variable name, and throw an error if dynamic access is used to by-pass either restriction. For instance, this doesn't currently complain about the fact that @ is clearly nonsensical as either a function or a variable: $foo = '@'; var_dump($$foo); $foo(); And nor does the empty string, which seems no less obvious a bug than a NULL: $foo = ''; var_dump($$foo); $foo(); -- Rowan Collins [IMSoP]