Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87936 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20072 invoked from network); 26 Aug 2015 17:07:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Aug 2015 17:07:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=craig@craigfrancis.co.uk; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=craig@craigfrancis.co.uk; sender-id=pass Received-SPF: pass (pb1.pair.com: domain craigfrancis.co.uk designates 209.85.212.169 as permitted sender) X-PHP-List-Original-Sender: craig@craigfrancis.co.uk X-Host-Fingerprint: 209.85.212.169 mail-wi0-f169.google.com Received: from [209.85.212.169] ([209.85.212.169:37887] helo=mail-wi0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A2/36-17883-442FDD55 for ; Wed, 26 Aug 2015 13:07:17 -0400 Received: by widdq5 with SMTP id dq5so21409031wid.0 for ; Wed, 26 Aug 2015 10:07:14 -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=bX26S6Q1f1MP/itwmfhKO59O4Zar2v4V8m9AC4vqAe0=; b=itekpn103VQI5WvyG1tWcFBjHQCzYijiZY5Xr7n3ZP3fWXqlKQhLcwoF8Ybd1DydfO 12qr3E4hEfOuG6CmYKTKiBYf27XWbWlh+XGlkD0l2khaYMdO9F+Yif9uXWmCOF8XoPE3 /ANQJsQngFlOx3CSibfTcFEJL1BL+NYHc5nW4= 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=bX26S6Q1f1MP/itwmfhKO59O4Zar2v4V8m9AC4vqAe0=; b=Y3m/feYzfKwI/tEhsjXCXKj8AqjGaA8mDQBcL5WvHI4FBtYgG5KpDRe3E58Gh3pdAk czcv3AU+GgsEFYQoSrW1a3QiteCRbi3ANHaCVLPbtW8jpDjbVdDkddqVGLdOnE5EbQ/p 3n9TmydCzWpKk11LI9N7qZfR6Ba9DKGYVCTuW7KOF6Mw6EXG5stM/q4MHcmIH5cBVgxj k44m6YPNnBddl+Hh9LUAwzPs7MLJ0mTg+/2Zaijec41mtFq91MWHiQRlIgeeKZuNIkMb nQ+ECZEwZhwSqCq9hsl9MXPUtpOB8vryNd7Z7qPETOPzP5Kl46MRNAZvn+9EKERAqXCD wO0A== X-Gm-Message-State: ALoCoQmru0yQylwunNs7zWU+dMyfctDN/x3GXEWPDUIxtMUR0uuqScRaxEibSkcjozuhLhS0mvQH X-Received: by 10.194.248.201 with SMTP id yo9mr57635782wjc.31.1440608834004; Wed, 26 Aug 2015 10:07:14 -0700 (PDT) Received: from [192.168.1.12] (cpc79329-chap9-2-0-cust385.18-1.cable.virginm.net. [82.44.123.130]) by smtp.gmail.com with ESMTPSA id ul1sm4762678wjc.30.2015.08.26.10.07.12 (version=TLS1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Aug 2015 10:07:13 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: <55DDD60F.5090509@gmail.com> Date: Wed, 26 Aug 2015 18:07:10 +0100 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <8C74463E-DBA2-4015-8159-0B44D973387F@craigfrancis.co.uk> 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> 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 26 Aug 2015, at 16:06, Rowan Collins wrote: > Craig Francis wrote on 26/08/2015 14:53: >> On 26 Aug 2015, at 12:36, Rowan Collins = wrote: >>=20 >>> Fortunately, the function you are looking for already exists: = http://php.net/array_key_exists >> It does, although I seem to have edited that out of my reply... was = trying to keep it short ;-) >=20 > You could have kept the reply even shorter by omitting examples for = which the language already provides the solution ;) I provide examples to help explain that I (and I suspect most = developers) default to using isset which works on either. Just because there is a function, which does not exactly roll off the = tongue (plus the fun of the needle/haystack ordering issue), does not = mean it gets used (even if it is the correct thing to use). >> At the moment I'm out of examples (bit busy at the moment), but I do = know that when I'm doing an isset() check, I'm really wanting to know if = the variable (or key) exists >=20 > Stop. As soon as you say "or key" you completely defeat your argument. = The whole thing is ONLY worth discussing if you can come up with an = example of an actual variable having unknown existence. I say "or key" because developers use the isset function on both $var = and $var['key']... yes, I know they are different, but when you are = coding in PHP an isset check is an isset check (well it isn't, because = the variable may technically exist). If this is a problem, maybe PHP should raise a notice when isset is used = on arrays? >> where NULL may be a perfectly valid value. >=20 > It's not that NULL isn't a valid value; it's that "doesn't exist" = isn't a meaningful state for a variable. It's like checking if the = current line number is greater than 100, it shouldn't mean anything to = the compiled program. See the SO answer I linked earlier for more = thought experiments along these lines. I think you have been spending too much time in C. Most of the PHP code bases I've worked on set variables to NULL at some = point (and they are not calling unset, because that isn't the = intention).