Re: __call_static() Magic Method

From: Date: Sat, 14 Jul 2007 10:30:07 +0000
Subject: Re: __call_static() Magic Method
References: 1  Groups: php.internals php.internals 
Request: Send a blank email to internals+get-30921@lists.php.net to get a copy of this message
This is actually a very good idea. I had to put a hook into the opcode handler for static method calls to get the same result which is not really elegant. I was waiting for this feature for a couple month. Also I found out that the names of the static methods are already lowercase when it comes to the handler, i don't know if that is fixed in the meanwhile. On Saturday 14 July 2007 02:53:44 Sara Golemon wrote: > Attached is a patch which exports an internals hook in zend_class_entry > for fetching function pointers similar to the object hook get_method() > available to instance methods. > > This patch also exports a userspace hook __call_static() which operates > in the fashion of the current __call() magic method, but for static calls. > > Wez called for some functionality like this a few weeks ago for a COM > wrapper (or something similar), and I noticed there was actually a > comment in the engine about how this should eventually be done anyway... > > Usage example: > > class foo > { > public static function __call_static($fname, $args) > { > echo "foo::{$fname}() called staticly with ", > count($args), " parameters\n"; > } > } > > foo::randomMethod(1,2,3); > > > I considered setting get_static_method to zend_std_get_static_method() > by default (avoiding the if set check during runtime), but all the other > hoooks follow this pattern so I went with consistency. > > If noone comments to the negative, I'll commit next friday (7/20)... > > -Sara -- Thomas

« previous php.internals (#30921) next »