Hello, Hello,
On Mon, Aug 4, 2008 at 6:57 AM, Stanislav Malyshev <[EMAIL PROTECTED]> wrote: > Hi! > >> 1) I don't believe that having it thrown as another of those magic >> method is a good idea. Rather, I'd like to have it represented by an >> interface: Invokable. That way, type hints/checks can be done in user >> land in a sane matter: > > We can have Invokable and even have Closure implement it, if there's need, I > see no problem with it. > However, I'm not sure we should *require* interface membership for __invoke > to work - I do not see any added value in this. I'm not sure I understand what you mean? Either the interface covers __invoke and "$obj instanceof Invokable" is a safe check to know if we can $obj();, or it doesn't and we know nothing. > >> 2) Do we really want __invoke's argument to be mapped to caller >> arguments. Providing an array of arguments, ala __call(Static) sounds >> more consistent. > > More "consistent" with what? __call is different from __invoke - __call is > global interceptor (takes any function), __invoke is not. And you can easily > convert it to array with function_get_args(). I agree, it's a feature that works "similarly" as __construct, and we don't have __construct($args); Additionally, it would require more work to distinguish: $a = function($b,$c) { ... }; $a(1,2); from class A { public function __invoke($args) { } } $a = new A; $a(1,2); as we certainly don't want function($args){}. In overall, there is no need to discuss that Interface much, as it causes more problems than it solves. But please check out the get_closure handler. > >> 3) Do we really want to allow both static and non-static versions of >> __invoke ? >> class A { public static function __invoke($args) { .. }} $a = new A; >> $a(); being a static call to __invoke doesn't make much sense to me. > > I don't see how static __invoke may be useful. Anyone has a use case? > -- > Stanislav Malyshev, Zend Software Architect > [EMAIL PROTECTED] http://www.zend.com/ > (408)253-8829 MSN: [EMAIL PROTECTED] > > -- Etienne Kneuss http://www.colder.ch Men never do evil so completely and cheerfully as when they do it from a religious conviction. -- Pascal -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php