2013/7/19 Peter Cowburn <petercowb...@gmail.com> > On 19 July 2013 17:36, Daniel Lowrey <rdlow...@gmail.com> wrote: > > > 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] > > > > array_filter([…], 'is_null'); > > That would do the opposite of what you want.
> > > > > 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? > > >