Re: Inconsistencies in callable, call_user_func and direct variable calls

From: Date: Thu, 19 Mar 2015 17:48:11 +0000
Subject: Re: Inconsistencies in callable, call_user_func and direct variable calls
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.internals 
Request: Send a blank email to internals+get-85224@lists.php.net to get a copy of this message
> There's then the question of what kind of object it would return - a > Closure? Some child or sibling of Closure? What methods could be usefully > provided? Yes, it's a closure. I've actually fleshed this out quite a bit, and there are a few important questions: - With methods do you allow unbound closures? callable("Foo::method") ? - How do you provide a context object? Two parameters? If so, what order? The object first makes more sense, but that means you have a string for your first parameter when there is only one, but an object if there are two. So you put the context second and it's kind of weird to do callable("method", $foo) Also note that if we had a unified table for properties, methods and constatns this is vastly simplified: - $foo::method could provide an unbound, scoped closure - $foo->method could provide a bound closure Or you do alternative grammar rules inside of callable, such that callable(foo::method) must would check for a method instead of a constant. All in all, I really wish we had unified properties, methods and constants. It would also have the advantage that if you have a property of an object that is a callable you could call it with normal syntax $foo->property() instead of having to do things like `$f = $foo->property; $f()`. Callable might work, though.

« previous php.internals (#85224) next »