Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88094 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11162 invoked from network); 7 Sep 2015 13:11:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Sep 2015 13:11:12 -0000 Authentication-Results: pb1.pair.com header.from=craig@craigfrancis.co.uk; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=craig@craigfrancis.co.uk; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain craigfrancis.co.uk designates 209.85.212.174 as permitted sender) X-PHP-List-Original-Sender: craig@craigfrancis.co.uk X-Host-Fingerprint: 209.85.212.174 mail-wi0-f174.google.com Received: from [209.85.212.174] ([209.85.212.174:32768] helo=mail-wi0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3F/61-03021-FEC8DE55 for ; Mon, 07 Sep 2015 09:11:12 -0400 Received: by wiclk2 with SMTP id lk2so88432801wic.0 for ; Mon, 07 Sep 2015 06:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=craigfrancis.co.uk; s=default; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=tYwKVPTCX+zXdevWfKHBC36o3pPchXLCE8di3mjpKp0=; b=SQO0xajiIzZaf99nEMo3Ei81xRitPw70qa9NEAbLhAbx7cv85GbnIOT12waznxi8Au BMfEcMOHD/Fy3VRZKCxvdn3q4zF8Fb5C3Pl9KS/M3Zy8VqI3AFZZx8UPAcdO089Wd60g pUGRTt+s3ROfyi9GDfmpbh+oa1wyPLGn7i9cc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to; bh=tYwKVPTCX+zXdevWfKHBC36o3pPchXLCE8di3mjpKp0=; b=LO+N76KxfwDsEF1ThMMYQI3qheW336GA4gUKTI2DoQ+Z/hTUPUtQt0of5C97uOvehj Ohste8a/Tpmdt85wnCG1kPpQXLCOB1tnJyCqfOfb7/ptxJW+xcwgcGTVlSEAhRgQXhVn 3P4FbgpghdM8uo4qhrFVboHJagjcMlsaeDa3r+YyF0y9nStL1pU2zBhND9/zhbBjxDtp vN9/F5EJsRtvRflA/aKJbzJNV50KG8Bsnvt6SvoUIdLYK8Jsxah4DQw+lbKnwgbV3zFQ z7Bc7NX0FZQBYSHOhW1TahdCdHn+vOdEPqtJ1ErMg7eHCgT0TlUXuBNBNU3EKFNUgpjc uLrQ== X-Gm-Message-State: ALoCoQkRRJUVdHdCStOilXHS7U3P+hsfcmechTtvLuy/3fsXx5Nx1mZVhEy18eUcajPFjeE8BDTh X-Received: by 10.194.86.161 with SMTP id q1mr36479342wjz.18.1441631468258; Mon, 07 Sep 2015 06:11:08 -0700 (PDT) Received: from [192.168.1.13] (cpc79329-chap9-2-0-cust385.18-1.cable.virginm.net. [82.44.123.130]) by smtp.gmail.com with ESMTPSA id xw2sm20038921wjc.12.2015.09.07.06.11.06 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Sep 2015 06:11:07 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: <55E6EC36.6090301@gmail.com> Date: Mon, 7 Sep 2015 14:11:05 +0100 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: 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> <55E6EC36.6090301@gmail.com> To: Rowan Collins X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28? From: craig@craigfrancis.co.uk (Craig Francis) On 2 Sep 2015, at 13:31, Rowan Collins wrote: > 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. Maybe... personally I don't see why anyone would be performing = operations such as: exists($foo['bar'] + 1) In the same way that `isset($a + 1)` results in a parse error. But then again, I don't think it's a quirk that "you don't get a warning = when passing a completely undefined variable to isset()", as I don't see = isset() as a normal function. If you do treat is as a normal function, you might as well be using = is_null() or "=3D=3D=3D NULL". For example, I think its quite common for MVC style frameworks to check = if a variable exists (with isset) in a View (e.g. checking if a = paginator exists after printing the table of results). With the `exists($foo['bar']['baz'])` example, I just see that as a = simple: if $foo exists, and contains the key 'bar', and contains the key = 'baz' (no need to check values). Like isset() I see exists() as a special function that isn't passing a = variable in, but PHP doing some analysis of the thing in the brackets. Craig On 2 Sep 2015, at 13:31, Rowan Collins wrote: > Craig Francis wrote on 02/09/2015 10:06: >> On 1 Sep 2015, at 19:17, Rowan Collins = wrote: >>=20 >>> I'm still not sure how exists() would be anything other than an = alias for array_key_exists(). >>=20 >> I think that is the case as well (ish). >>=20 >> 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. >>=20 >> Before last week, if someone asked me to write some code to see if a = variable (or key) exists, >=20 > 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: >=20 >=20 >> I would have simply used isset() without thinking (this being a = problem if the variable was set to NULL). >=20 > 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. >=20 > 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 >=20 >=20 >> 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). >=20 > This is a more reasonable point, and I was pondering whether it would = be possible to allow a more natural syntax. >=20 > 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). >=20 >=20 >> And the second one does not really check for the existence of $_GET, = which in this case is probably ok. >=20 > I'm not really sure what you mean by this. >=20 >=20 > 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. >=20 > Regards, > --=20 > Rowan Collins > [IMSoP]