Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86631 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75251 invoked from network); 14 Jun 2015 03:34:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jun 2015 03:34:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.179 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.160.179 mail-yk0-f179.google.com Received: from [209.85.160.179] ([209.85.160.179:35310] helo=mail-yk0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5E/15-07883-826FC755 for ; Sat, 13 Jun 2015 23:34:01 -0400 Received: by ykar6 with SMTP id r6so9041367yka.2 for ; Sat, 13 Jun 2015 20:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=bCRdBxYgqelwfsTgmPs4Ay5cF29aGvEB0akWY6mlvaY=; b=bhyHFfeomnaOO+voRXUmOWaUudYL/GXeg9pcsYA6wuex+hkL994BB9tLzXoUiC0Lst l42mgkhnXSjh1O3lQB4qbGyES3op+3g5PcFx2pRtd4qSadd83XKTqgnpvzELYcYdKXZx /Eel1AJtKQP+9N8HjVSFidpD6V1ynB7Gpptrb+7YIfu6nTCWkY9mDyHWPq2YWeSugsHi hs2gRVvV7ton0cFowH1R8n8SoPgvRTaB6yVAz5gIk2tlkNtapDCbfYyEk7GI1A2ZlwOo /nNhhkiwgMyoeSrE9XTUtW06LAzYwkssYv2TVMZDW8aSXJp1cwo3u75DoDC1vlKd0kNL 3zdw== X-Received: by 10.170.57.198 with SMTP id 189mr27289537ykz.35.1434252837235; Sat, 13 Jun 2015 20:33:57 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.13.246.2 with HTTP; Sat, 13 Jun 2015 20:33:16 -0700 (PDT) In-Reply-To: <55794DE2.2080602@gmail.com> References: <5576051A.3040800@gmx.de> <55760771.6020802@gmail.com> <778F345F9918474AB8CAAB03082ECBF7@pc1> <5577DEE4.8030205@gmail.com> <55794DE2.2080602@gmail.com> Date: Sun, 14 Jun 2015 12:33:16 +0900 X-Google-Sender-Auth: NiiUybNWnu_2nV0Jc1AGuJXkwLg Message-ID: To: Rowan Collins Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1139441ee1b134051872025c Subject: Re: [PHP-DEV] Array dereferencing of scalars From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1139441ee1b134051872025c Content-Type: text/plain; charset=UTF-8 Hi Rowan, On Thu, Jun 11, 2015 at 5:59 PM, Rowan Collins wrote: > Yasuo Ohgaki wrote on 11/06/2015 00:50: > >> If PHP should return NULL always against NULL variables, we may be better >> to >> reconsider these behavior. >> >> [yohgaki@dev Download]$ php >> > $v = NULL; >> $$v; >> >> >> PHP Notice: Undefined variable: in - on line 3 >> > > This is not complaining that $v is NULL, it is warning you the same as if > you wrote $v = 'some_name_you_never_assigned_to'; $$v; > > Somewhat surprisingly, you can actually assign to the variable whose name > is NULL: http://3v4l.org/5pXJg > > > [yohgaki@dev Download]$ php >> > $v = NULL; >> $v(); >> >> PHP Fatal error: Uncaught EngineException: Function name must be a string >> in -:3 >> Stack trace: >> #0 {main} >> thrown in - on line 3 >> > > This one has given a different message because of it being a non-string > value, but would be equally fatal if you tried to call any undefined > function. Would coercing NULL to an imaginary function which returns NULL > actually be useful for anything? For example, getting NULL handler as the default. This is useful like $v=NULL;$v[1][2][3]; > I don't care much whether these yield NULL always or raise >> error/exception, >> but there should be consistency. >> > > I see no reason why these cases need to be consistent, just because they > both involve NULLs. It's all about the action you invoke, not just the > value something's interpreted as. I think those who are familiar with NULL in RDBMS might make sense returning NULL for all. NULL is special value and how it should be behaved is debatable. Raising some kind of error for all would be nicer including $v=NULL;$v[1][2][3]; IMO. Less exceptions are better. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a1139441ee1b134051872025c--