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]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php