Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:30024 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42977 invoked by uid 1010); 1 Jun 2007 07:14:37 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 42962 invoked from network); 1 Jun 2007 07:14:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jun 2007 07:14:37 -0000 X-Host-Fingerprint: 194.109.253.196 mediawave.xs4all.nl Received: from [194.109.253.196] ([194.109.253.196:2460] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E7/13-15749-B57CF564 for ; Fri, 01 Jun 2007 03:14:36 -0400 To: internals@lists.php.net, ceo@l-i-e.com Message-ID: <465FC76B.6030208@mediawave.nl> Date: Fri, 01 Jun 2007 09:14:51 +0200 User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 CC: Jochem Maas , Ken Stanley 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> In-Reply-To: <43689.216.230.84.67.1180643866.squirrel@www.l-i-e.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 194.109.253.196 Subject: Re: [PHP-DEV] late static binding From: bart@mediawave.nl (Bart de Boer) Richard Lynch wrote: > On Wed, May 30, 2007 9:54 am, Jochem Maas wrote: >> Richard Lynch wrote: >>> Maybe I'm just confused (well, I'm always confused...) but if a >>> Class >>> has multiple children, how the heck would PHP know which child:: to >>> call?... >> the use of the name 'child' is very confusing, I would prefer 'super' >> or 'static' ... >> regardless the concept is actually quite simple: >> >> interface DOInfo { >> static function getTableName(); >> } >> >> abstract class DataObject implements DOInfo { >> static function findRange() { >> $table = super::getTableName(); >> return $foo; // $foo is a collection of whatever (e.g. Product >> objects) >> } >> >> static function getTableName() { >> throw new Exception('be a dear and implement '.__METHOD__.' in your >> subclass'); } >> >> } >> >> class Product extends DataObject { >> static function getTableName() { return 'PRODS'; } >> } >> >> $products = Product::findRange(); >> >> excuse me if I've just committed a grave sin against the OO Codex in >> writing something >> that either isn't 'correct' or is syntactically incorrect according to >> the current >> state of php - hopefully the idea is clear anyway. > > You may think this is "quite simple" but I've skimmed it several times > and have no idea what the heck is going on... > > I do know that 'super', to me, implies superclass which PHP just calls > parent:: so I don't like that either. > > If it's just calling the static method of the interface parent-y > thingie, I dunno, maybe just static:: would work? > static:: seems weird because it implies otherkeyword:: is not static. Perhaps we should forget about the whole keyword and just allow objects to access its static members like any other member? It works like that for static functions too. Why not let it act that way for static variables?: var; } } class Child extends Base { static $var = "howdy"; } ?> Seems to me all the PHP engine would have to do is create an object member with the same name which references the static variable of the class? But then I'm no PHP engine expert. :) -- Bart