Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87930 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48381 invoked from network); 26 Aug 2015 11:23:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Aug 2015 11:23:14 -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.172 as permitted sender) X-PHP-List-Original-Sender: craig@craigfrancis.co.uk X-Host-Fingerprint: 209.85.212.172 mail-wi0-f172.google.com Received: from [209.85.212.172] ([209.85.212.172:37287] helo=mail-wi0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1B/32-17883-0A1ADD55 for ; Wed, 26 Aug 2015 07:23:13 -0400 Received: by widdq5 with SMTP id dq5so12186157wid.0 for ; Wed, 26 Aug 2015 04:23:10 -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=Khyp+e/4mGv3xVlaBmqUJpID4LNOOMbW3rHX0fzH39c=; b=BMCPjdUfdxUa64fyVmYJX3uoqcDk9kumTc4zIAXVlz5eQR2/FODPG1u3/9BNf4Cl2/ XFuVSD576+JyF0WERoPyjTt0qpKe4GDakpPJYpgauIBi4lU8VQcgwjDPzWgrpm42H6hx E1QfLSeMMCOFwfr3F/IY930yMMGLaDxyQ5q5w= 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=Khyp+e/4mGv3xVlaBmqUJpID4LNOOMbW3rHX0fzH39c=; b=CmQgD6qOrlB1UiLJtoW8vReDArJfuO0xge2gGZDGcc2zYBH4+Cw74XkGxi0Q8J+mJY uyN0T3G+u2hiy21BEwOpMT0G8/FxaNcQYn1b8Kl2+SULarkscLDF77JWZbQcaTcBKkDd 6MFTTaURj1bGkOogB3s02KAmFKHc0yX+QbncfRCxK5QoIThUs95B2ThEh/fCRkyNqXeN xD73/9qjaGjwntp8wtsvuZeILCfJBe3StvpGe9fNrBH5dxBo++YD8fcHcQiFyH7/KrlT rc+4FA1i6QIc4BLm+vWnBmBVLolNbdTLkJoL1TnYMUxvJFV18W08Yzw/btBXJ5absDYk RMaA== X-Gm-Message-State: ALoCoQlsZkqNvFkCb5/mlpYh2gQfyb5VG+KqtrJRD9mde5SELnaE9n8Q5CiiH54nkdbxd087DLiG X-Received: by 10.180.108.175 with SMTP id hl15mr3332937wib.1.1440588190380; Wed, 26 Aug 2015 04:23:10 -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 gv1sm7110686wib.15.2015.08.26.04.23.09 (version=TLS1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Aug 2015 04:23:09 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: <55DD4269.4090402@gmail.com> Date: Wed, 26 Aug 2015 12:23:07 +0100 Cc: Scott Arciszewski , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <6348DFA7-04BD-41BB-A500-17A8A531B56C@craigfrancis.co.uk> References: <55DD4269.4090402@gmail.com> To: Stanislav Malyshev 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 05:36, Stanislav Malyshev = wrote: >=20 >> Would anyone be interested in adding another helper like >> isset()/empty() simply called exists() which would return true if the >> variable is defined in the current scope (i.e. without raising an >> E_NOTICE)? >=20 > Not sure what the use case would be for this. For most practical > purposes, isset/empty look completely fine. As a web (not core) developer I've been bitten by this a couple of = times. Both were fairly quick to identify/fix, but enough to be a little = annoying. If you want some example of where I got this wrong... I have a config array for defining the websites CSP header, it starts = something like: $csp_directives =3D array( 'default-src' =3D> array("'none'"), 'form-action' =3D> array("'self'"), 'style-src' =3D> array("'self'"), 'img-src' =3D> array("'self'"), 'script-src' =3D> array("'self'"), ); Depending on the website I may then add a key to define the = 'report-uri', or I may set it to NULL to say that I don't want one. If = it remains unset (key does not exist), then the framework provides a = default. At first I used an isset() check, forgetting that setting to = NULL would not be seen as "set". When creating a URL builder that allowed the query string to be passed = in as an array. If it defaulted to the current URL (with its query = string values), then the passed in array might tell it to explicitly = remove certain values by setting them to NULL. When I first wrote this, = I did an isset() check when adding the current URL's query string to the = array of query string values (which take precedence). Neither were major problems, just a slight annoyance (i.e. identified = and fixed before I committed the code). But I'm normally using an = isset() as the proposed exists() function would work. On 26 Aug 2015, at 05:36, Stanislav Malyshev = wrote: > Hi! >=20 >> Would anyone be interested in adding another helper like >> isset()/empty() simply called exists() which would return true if the >> variable is defined in the current scope (i.e. without raising an >> E_NOTICE)? >=20 > Not sure what the use case would be for this. For most practical > purposes, isset/empty look completely fine. >=20 >> It should be a simple change to add this function but it's too late >> for 7.0 so, if there is any interest, I would respectfully put it off >> until 7.1. >=20 > It is simple, but not everything that is simple should be done. > Especially when we talking about adding core functions. >=20 > --=20 > Stas Malyshev > smalyshev@gmail.com >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20