Re: PHP 7.1 - Address PHPSadness #28?

From: Date: Tue, 15 Sep 2015 03:16:32 +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-88204@lists.php.net to get a copy of this message
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

« previous php.internals (#88204) next »