Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:30073 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71385 invoked by uid 1010); 5 Jun 2007 16:28:59 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 71369 invoked from network); 5 Jun 2007 16:28:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2007 16:28:58 -0000 Authentication-Results: pb1.pair.com header.from=bart@mediawave.nl; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=bart@mediawave.nl; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mediawave.nl from 194.109.253.196 cause and error) X-PHP-List-Original-Sender: bart@mediawave.nl X-Host-Fingerprint: 194.109.253.196 mediawave.xs4all.nl Received: from [194.109.253.196] ([194.109.253.196:44503] helo=mediawave.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 57/71-56966-04F85664 for ; Tue, 05 Jun 2007 12:28:52 -0400 Received: from mediawave.nl (mediawave.nl [127.0.0.1]) by mediawave.nl (8.13.8/8.13.7) with ESMTP id l55GSeeZ007860; Tue, 5 Jun 2007 18:28:40 +0200 Received: (from apache@localhost) by mediawave.nl (8.13.8/8.13.8/Submit) id l55GSdLc007859; Tue, 5 Jun 2007 18:28:39 +0200 X-Authentication-Warning: mediawave.nl: apache set sender to bart@mediawave.nl using -f Received: from 192.87.117.168 (SquirrelMail authenticated user bart) by www.mediawave.nl with HTTP; Tue, 5 Jun 2007 18:28:39 +0200 (CEST) Message-ID: <2689.192.87.117.168.1181060919.squirrel@www.mediawave.nl> In-Reply-To: <46657E94.1030900@iamjochem.com> References: <56275.216.230.84.67.1180484964.squirrel@www.l-i-e.com> <465D9040.6030001@iamjochem.com> <43689.216.230.84.67.1180643866.squirrel@www.l-i-e.com> <465FC76B.6030208@mediawave.nl> <4660A44F.6060802@mediawave.nl> <46657E94.1030900@iamjochem.com> Date: Tue, 5 Jun 2007 18:28:39 +0200 (CEST) To: "Jochem Maas" Cc: internals@lists.php.net, "Ken Stanley" User-Agent: SquirrelMail/1.4.10a-1.fc6 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Subject: Re: [PHP-DEV] late static binding (please break BC?) From: bart@mediawave.nl ("Bart de Boer") > Bart de Boer wrote: >> Ken Stanley wrote: >> > > ... >> That's not right. Accessing the child class would only be possible from >> within an instantiated object. Unlike parent::, you will never be able >> to use static:: in a purely static context. Imagine there are multiple >> child classes which all inherit from the same base class. If there's no >> instance, PHP won't be able to know which child class to target with >> child::, static:: or whateverkeyword:: since it can be any one of those >> child classes. > > huh??? the 'child' class would refer to the class that was actually named > when then call to the method was made (thats what late static binding > means, > does it not?): > > class Data { > static function getTableName() { > throw new Exception('WTF'); > } > > static function findRange() { > $t = child::getTableName(); > } > } > > class Prod { > static function getTableName() { > return 'PRODS'; > } > } > > Data::findRange(); // child = Data class > Prod::findRange(); // child = Prod class > I think I misunderstood what was meant by late static binding. Thank you for clearing that up. And my sincerest apologies to everyone to whom I might have caused confusion. > if you require a class instance in order to use 'child' then > the whole point is moot - because you can already do > > $child = get_class($this); > > inside the relevant function (assuming the function is not declared > static, > and why would you declare it as such if your requiring an instance to use > 'child'?). > I thought late static binding had something to do with accessing static _variables_ in child classes. You're currently solving that problem by defining a static function getTableName() in the child class. But I think that isn't very efficient when you're dealing with complex objects and/or arrays which would need to be accessed frequently. If it were possible your code example could be solved as: But it seems this feature request belongs in a different thread. :) > maybe 'child' should be called 'callee' or even 'lsb' (that would make > people > hit the docs for sure :-)). alternatively maybe 'this' could be used as > the LSB keyword: > > this::foo(); > > the samentics for determining what class is referred to with 'this::' is > akin to > that used for determining what class is referred with '$this->', no? > > MAYBE php6 should do late static binding for 'self', akin to other OO > oriented > scripting langs .. and just live with BC. I seriously wonder whether much > code would > break ... given that 'self' is not currently late binding how often would > people have actually > overwritten static methods ion child classes that are being called via the > 'self' syntax > in [parent] classes? > Now I understand why this:: might be confusing since it is meant for objects. self:: would mean we can't access stuff in the current class anymore. What about derived:: or extended:: ?