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?:

<?php

class Base
{
        function __construct() {
                echo $this->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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to