Hey internals! Currently the empty() language construct only works on variables. You can write if (empty($array)) but not empty if (empty(getSomeArray()).
The original reason for this restriction probably is that - in a way - it "doesn't make sense" to pass anything but a variable to empty() as you could just use the ! operator in this case. if (empty(getSomeArray())) is logically equivalent to if (!getSomeArray()). I'd like to propose to change empty() to accept arbitrary expressions. The reason is simple: Even though it is possible to write if (!getSomeArray()) with the same effect, if (empty(getSomeArray())) reads much nicer. !getSomeArray() to me somehow implies that getSomeArray() may return a bool(false) or something like that. On the other hand empty(getSomeArray()) seems naturally fit for checking for empty arrays. Another reason is that currently you get a very obscure error message if you try to use empty() on a function return value: "Can't use function return value in write context". Aha. Where did I try to write to the return value?! So, what do you think? Nikita PS: The patch is trivial: https://gist.github.com/2355274 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php