Re: PHP 7.1 - Address PHPSadness #28?

From: Date: Wed, 16 Sep 2015 12:23:02 +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-88231@lists.php.net to get a copy of this message
François Laupretre wrote on 16/09/2015 12:36:.
I agree that it is not needed on local vars very often (maybe in some template systems...).
I have yet to see, in this entire discussion, one single example. The example Craig Francis gave of a template system worked 100% correctly using the current semantics of isset().
But, even if it is used mostly as a replacement for array_key_exists() or property_exists(), it will improve readability and push devs away from isset(), which is quite positive.
Why is it positive to push devs away from a perfectly useful function to a different one which will only exist in the latest version of PHP (and cannot be polyfilled in userland, because it needs access to the engine's representation of a variable)? I would say encouraging devs to treat unset($foo) and $foo=null as distinct states is an extremely bad idea. There are two things we can do here: - better document on the isset() manual page that array_key_exists() may be more appropriate in some cases - invent a language construct that is a bit more readable / typeable than array_key_exists but does the same thing; passing a plain variable or any other expression to this should be an error, just as isset(1+1) already is. Possibly the same for property_exists(), since some people think stdClass objects look prettier than associative arrays, though I've never understood the attraction myself. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#88231) next »