Send a blank email to [email protected] to get a copy of this message
I have a simple question about the callability of language constructs and
whether or not that's something that might change in the future. Consider:
var_dump(is_callable('echo')); // bool(false)
var_dump(call_user_func('echo', 'foo')); // E_WARNING
echo('foo'); // foo
var_dump(is_callable('isset')); // bool(false)
var_dump(isset(1)); // E_ERROR
Obviously this behavior arises because tokens like echo and isset are
language constructs and not functions. I can see some potential benefits
for working around this. For example, say I want to filter only the NULL
elements from an array but keep the other "falsy" values. Recognizing
isset as callable would allow me to do this:
var_dump(array_filter([0, FALSE, NULL], 'isset')); // [0, FALSE]
Of course, this limitation is trivial to work around with a userland
callback to check for the explicit NULL equivalency, but it would be nice
to avoid the hassle. So my question is ...
How deeply ingrained into the engine is this behavior? Is there any chance
of language constructs ever passing the tests for callability or is that
just a pipe dream that's not worth the implementation effort?