Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29982 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96555 invoked by uid 1010); 31 May 2007 07:46:58 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 96540 invoked from network); 31 May 2007 07:46:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 May 2007 07:46:57 -0000 X-Host-Fingerprint: 194.109.253.196 mediawave.xs4all.nl Received: from [194.109.253.196] ([194.109.253.196:22208] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 20/00-20257-4A37E564 for ; Thu, 31 May 2007 03:05:10 -0400 To: internals@lists.php.net,Jochem Maas Message-ID: <465E73A5.50706@mediawave.nl> Date: Thu, 31 May 2007 09:05:09 +0200 User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 CC: ceo@l-i-e.com, Ken Stanley References: <56275.216.230.84.67.1180484964.squirrel@www.l-i-e.com> <465D9040.6030001@iamjochem.com> In-Reply-To: <465D9040.6030001@iamjochem.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) static function getTableName() { return 'PRODS'; } What a great idea! You can just do: $tableName = $this->getTableName(); ...from within the base class. No need for static:: or super:: keywords anymore... It may be not as elegant as having a special keyword for it... But, for now, this approach would partially make my code a bit more elegant... Thanx! Now, all I would still like to be able to do is: $className::getTableName(); 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. > >>> - Ken >>> -- >>> It looked like something resembling white marble, which was >>> probably what it was: something resembling white marble. >>> -- Douglas Adams, "The Hitchhikers Guide to the >>> Galaxy" >>> >>