Newsgroups: php.internals,php.internals Path: news.php.net Xref: news.php.net php.internals:30921 php.internals:30922 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51337 invoked by uid 1010); 14 Jul 2007 10:46:24 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 51321 invoked from network); 14 Jul 2007 10:46:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2007 10:46:23 -0000 Received: from [127.0.0.1] ([127.0.0.1:27676]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 3B/30-47295-E79A8964 for ; Sat, 14 Jul 2007 06:46:22 -0400 Authentication-Results: pb1.pair.com header.from=tm@php-qt.org; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tm@php-qt.org; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain php-qt.org designates 65.254.63.160 as permitted sender) X-PHP-List-Original-Sender: tm@php-qt.org X-Host-Fingerprint: 65.254.63.160 unknown Linux 2.5 (sometimes 2.4) (4) Received: from [65.254.63.160] ([65.254.63.160:34854] helo=iquip.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 98/10-47295-D47A8964 for ; Sat, 14 Jul 2007 06:37:02 -0400 Received: (qmail 17614 invoked from network); 14 Jul 2007 06:30:16 -0400 Received: from unknown (HELO ?10.43.185.142?) (82.113.121.16) by php-qt.org with SMTP; 14 Jul 2007 06:30:16 -0400 To: internals@lists.php.net Date: Sat, 14 Jul 2007 12:30:07 +0200 User-Agent: KMail/1.9.6 References: <46981E98.30803@php.net> In-Reply-To: <46981E98.30803@php.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200707141230.08116.tm@php-qt.org> Subject: Re: [PHP-DEV] __call_static() Magic Method From: tm@php-qt.org (Thomas Moenicke) 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