Re: PHP 7.1 - Address PHPSadness #28?

From: Date: Sat, 19 Sep 2015 14:49:55 +0000
Subject: Re: PHP 7.1 - Address PHPSadness #28?
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.internals 
Request: Send a blank email to internals+get-88375@lists.php.net to get a copy of this message
On 19/09/15 13:15, Rowan Collins wrote: >> I don't >> >see any 'completely new type of code' ... only a different frame in >> >which the variables are held. > It's "completely new" because you can't do it right now, that's all. > > I'm just trying to separate two different justifications for requesting this feature: some > people are saying their current code is buggy because of some lack in the language, and that > "thousands and millions of devs" encounter this; others, such as yourself, are saying that > they would like to write code in a certain style, which the language doesn't currently allow. I > have still seen absolutely no evidence of the former, most bugs apparently being due to poor > adoption of array_key_exists; I am reasonably convinced by your use case being valid, even if > it's not a style I'd choose. > > Every time you start talking about avoiding notices, and existing code, I therefore get > confused - there is no code using exists() in order for it to be buggy! If there was a bug with 'isset' it is that it returns false for a variable that IS SET to null. So using isset only returns true when there is an actual value assigned to the variable. There is not an array_key_isset(), but array_key_exists() which returns true for all cases of the variable existing. So I can call array_key_exists() followed by is_null() and be sure that I will not get a warning from the is_null() call because the variable has to exist, and the function is 'exists' rather than 'isset' for that very reason. Moving back to plain variables, we can check a variable isset(), if the variable has been created and is null, then we don't have a problem, but if the variable does not exist there is no way of testing for that state prior to calling is_null() so we get a warning. THAT is the warning that I'm talking about. Now if you have another way of identifying that the variable 'exists' before calling is_null() then I apologise but I've not found it yet :( -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

« previous php.internals (#88375) next »