On 26 Aug 2015, at 05:36, Stanislav Malyshev <smalys...@gmail.com> wrote: > >> 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)? > > 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 = array( 'default-src' => array("'none'"), 'form-action' => array("'self'"), 'style-src' => array("'self'"), 'img-src' => array("'self'"), 'script-src' => 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 <smalys...@gmail.com> wrote: > Hi! > >> 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)? > > Not sure what the use case would be for this. For most practical > purposes, isset/empty look completely fine. > >> 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. > > It is simple, but not everything that is simple should be done. > Especially when we talking about adding core functions. > > -- > Stas Malyshev > smalys...@gmail.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php