Le 14/09/2015 22:17, Robert Williams a écrit :

I’m not sure what a good solution is, however. Changing isset() will
have consequences: making it return true for null will magically fix a
lot of bugs out there, but it’ll also break code where the programmer
understood how it really works. Adding a parameter to control it is
ugly. Extending defined() to variables might be a good choice, as it’s
already doing for constants exactly what’s needed for variables; the
only downside is that it would be better-named declared() than
defined(), but that’s the case for constants, too, so I can live with
it. For now, isset() and empty() can continue to work as-is but perhaps
with a notice and deprecation when used with undeclared variables.

Going back in time and changing isset() behavior is not an option, even if I'd personally prefer considering a null variable as 'set'. You may be right and it may fix a lot of bugs, but, IMHO, you'd rather forget it. The same with adding a second argument.

I'd love extending defined() to support defined($var) but it would be ambiguous because it already means: 'get the string contained in $var and check if a constant with that name exists'. So, we can't use it this way.

IMO, the best solution is the exists() construct.

Regards

François


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to