Re: __call interceptor and static methods

From: Date: Mon, 08 Nov 2004 01:36:58 +0000
Subject: Re: __call interceptor and static methods
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-13775@lists.php.net to get a copy of this message
would it be doable (and more acceptable / less confusing) if __call could only be invoked statically if the class was abstract and vice versa only be invoked on objects if the class was not abstract? (the idea being to make the distinction during parsing rather than execution, allowing you to throw a parse error for incorrect usage [including use of $this in __call() when only allowing static calls]) Andi Gutmans wrote:
In most cases method overloading is used for objects and not for classes (for example, initiating a SOAP object and then calling methods on it.). It doesn't make sense to mix these two things because it would lead to confusion what context the method was called in. You would either need another call back or pass a flag to __call() and in my opinion just doesn't seem to be worth it. Andi At 05:26 PM 11/7/2004 +0100, Timm Friebe wrote:
Hi, is there any reason why __call shouldn't be invoked for static method calls? Reproduce --------- php5 -r 'class A { function __call($name, $args) { var_dump($name, $args); } } A::foo();' Actual result ------------- Fatal error: Call to undefined method A::foo() in Command line code on line 1 Expected result --------------- string(3) "foo" array(0) { } - Timm -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#13775) next »