Re: PHP 7.1 - Address PHPSadness #28?

From: Date: Wed, 26 Aug 2015 10:10:34 +0000
Subject: Re: PHP 7.1 - Address PHPSadness #28?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-87926@lists.php.net to get a copy of this message
Scott Arciszewski wrote on 26/08/2015 04:09:
Hi everybody, 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)?
My answer to this would be a very loud "no". I have written at length about this on StackOverflow: http://stackoverflow.com/a/18646568/157957 In short, if your algorithm relies on knowing whether, anywhere in the preceding scope, a variable has been implicitly "declared" (in as much as that concept has any meaning in PHP), that algorithm is broken. If it relies on knowing whether a variable has been changed from its initial state, then isset() will do exactly what you want. Note that many people looking for examples of this "problem" start mentioning array keys and object properties; we have functions for checking existence of those, so please don't waste time on such examples. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#87926) next »