Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88007 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73054 invoked from network); 2 Sep 2015 12:32:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2015 12:32:28 -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 209.85.212.178 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.178 mail-wi0-f178.google.com Received: from [209.85.212.178] ([209.85.212.178:32962] helo=mail-wi0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/91-57033-B5CE6E55 for ; Wed, 02 Sep 2015 08:32:28 -0400 Received: by wicmc4 with SMTP id mc4so64542665wic.0 for ; Wed, 02 Sep 2015 05:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=WmPMfc0Rom0rbpWnn356Zxku6vZvk9v9dEIkW1UYCVs=; b=HUEHuzef/H/Pqd/oWu7EnUV66t2TLiXhNj4YI00hVJOXtVpOmEexADXzcvvaxvMw9W zWjsNsULHMKyx+EKlC5jfvIxVVHL6ibkFpWX2PxjV8tLd9ls20aDtmR0MRBoL1LWPf4o nNzMSi6/RVOhGe0hkCfdP8DnCk3a4YGhoaD1aECGS14d+WMaKH+ZDjbjCTC7Z1YRUXdP DqewN9aHKSr/db0S50DaB3P2KsQbl7bh+68+p0GWq+PcVPZhfyK+7uhavzyfZM+RmDCX TlBm4XB5d6am0gKZXADyJ0pyLM8n0wCWDjtRJfIFTU6k/KzucUEzsLOa163ELYsGQK6J RDlw== X-Received: by 10.194.103.103 with SMTP id fv7mr36407985wjb.152.1441197144902; Wed, 02 Sep 2015 05:32:24 -0700 (PDT) Received: from [192.168.0.152] ([62.189.198.114]) by smtp.googlemail.com with ESMTPSA id bq7sm32176043wjc.31.2015.09.02.05.32.23 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 02 Sep 2015 05:32:23 -0700 (PDT) To: Craig Francis , internals@lists.php.net References: <55DD4269.4090402@gmail.com> <6348DFA7-04BD-41BB-A500-17A8A531B56C@craigfrancis.co.uk> <55DDA4C9.9040603@gmail.com> <3C69BF4B-52E6-4D04-8601-8D23DFCC538E@craigfrancis.co.uk> <55DDD60F.5090509@gmail.com> <8C74463E-DBA2-4015-8159-0B44D973387F@craigfrancis.co.uk> <55DE0907.6040904@gmail.com> <1F615BCD-1B9B-4C51-A210-869F1AA1F6E3@craigfrancis.co.uk> <55E5EBBF.6020803@gmail.com> <0BA3A129-D356-4781-B6DE-E2B5A7924AE2@craigfrancis.co.uk> Message-ID: <55E6EC36.6090301@gmail.com> Date: Wed, 2 Sep 2015 13:31:50 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <0BA3A129-D356-4781-B6DE-E2B5A7924AE2@craigfrancis.co.uk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28? From: rowan.collins@gmail.com (Rowan Collins) Craig Francis wrote on 02/09/2015 10:06: > On 1 Sep 2015, at 19:17, Rowan Collins wrote: > >> I'm still not sure how exists() would be anything other than an alias for array_key_exists(). > > I think that is the case as well (ish). > > But considering that isset() seems to be the function that is used most of the time, I want to consider why that is the case. > > Before last week, if someone asked me to write some code to see if a variable (or key) exists, Again, you insist on drawing a false equivalence to the different concepts of variable and array key. This makes the following sentence really easy to dismiss: > I would have simply used isset() without thinking (this being a problem if the variable was set to NULL). No, it wouldn't be a problem if a VARIABLE was set to null, because there is no practical difference between an unset variable and one set to null, so you never need to ask which you have. It *would* be a problem if you were testing for the existence of an array key. There should probably be a prominent link to array_key_exists() and property_exists() on the isset() manual page > The second one does also represent the variable in a different way (grep for "$_GET['q']", where it only appears 3 times in that code). This is a more reasonable point, and I was pondering whether it would be possible to allow a more natural syntax. It would probably require a lot of "magic" in the engine, though, because it would have to parse exists($foo['bar']['baz']) in some special way to know that it needed to first find the value of $foo['bar'], and then do an existence check for key 'baz', rather than just treating the whole thing as an expression to resolve before exists() was called. Evaluating things like exists(foo()[ bar() ]) correctly might get messy, as would giving a meaningful result or error if you wrote exists($foo['bar'] + 1). > And the second one does not really check for the existence of $_GET, which in this case is probably ok. I'm not really sure what you mean by this. In summary, I don't think any language change is needed here, but documentation needs to be improved. I will have a go at drafting a new intro for the isset() page when/if I get time. Regards, -- Rowan Collins [IMSoP]