Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22044 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84650 invoked by uid 1010); 1 Mar 2006 10:00:20 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 84635 invoked from network); 1 Mar 2006 10:00:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Mar 2006 10:00:20 -0000 X-Host-Fingerprint: 81.169.182.136 ajaxatwork.net Linux 2.4/2.6 Received: from ([81.169.182.136:43416] helo=strato.aixcept.de) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 5A/73-25426-2B075044 for ; Wed, 01 Mar 2006 05:00:18 -0500 Received: from [192.168.1.3] (dslb-084-063-027-197.pools.arcor-ip.net [84.63.27.197]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by strato.aixcept.de (Postfix) with ESMTP id CB7A435C1D2; Wed, 1 Mar 2006 11:00:15 +0100 (CET) Date: Wed, 1 Mar 2006 11:00:31 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1356201130.20060301110031@marcus-boerger.de> To: PHP-DEV Cc: Andi Gutmans , Mike Lively In-Reply-To: <1140732362.3702.14.camel@localhost.localdomain> References: <1140732362.3702.14.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [PATCH] Late Static Binding From: helly@php.net (Marcus Boerger) Hello internals, it looks like either nobody objects or nobody has interest. Either way i tested the patch and worked helped it a bit and it looks good, doesn't affect anything else and doesn't show a single problem in valgrind. So If noone objects i will commit this next week. regards marcus special mail to andi :-) Thursday, February 23, 2006, 11:06:02 PM, you wrote: > I have finished a patch that implements a working version of late static > binding. > I used the notes from the Paris PDM as my guidelines for implementation. > (http://www.php.net/~derick/meeting-notes.html#late-static-binding-using-this-without-or-perhaps-with-a-different-name) > As requested in the notes I reused 'static::'. I also wrote a few tests > not only to test the new functionality but also to make sure 'static' can't be inherited or extended. > I also added a new function get_caller_class() which returns the name of > the class that static:: would represent. > (borrowing from PDM notes) > In php5.* the following script outputs "A::static2": > class A { > static function staticA() { > self::static2(); > } > static function static2() { > echo "A::static2\n"; > } > } > class B extends A { > static function static2() { > echo "B::static2\n"; > } > } > B::staticA(); ?>> > This has somewhat recently been highlighted by different developers to > be somewhat problematic behavior in creating user friendly APIs. If you > want to see a possible use for it you need look no further than the > example ZActiveRecord API that was used in their webcast with php|arch. > (http://blog.joshuaeichorn.com/archives/2006/01/09/zactiverecord-cant-work/) > Currently the code laid out there is impossible short of some ugly use of > debug_backtrace() and file parsing :/. This patch of course would allow that kind of code too exist. > In a small example based on the one I gave earlier you could change the > code too the following and have it print "B::static2": > class A { > static function staticA() { > static::static2(); > } > static function static2() { > echo "A::static2\n"; > } > } > class B extends A { > static function static2() { > echo "B::static2\n"; > } > } > B::staticA(); ?>> > As far as current userland code impact, there is very little as far as I > can tell. No keywords have been added, just another use for an existing > one. No changes were made to self:: or parent:: so the change should be > pretty transparent. The only thing that I see remotely causing any > issues would be the new function (get_caller_class().) I added that just > to complete the set so to speak.