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 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'?). 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? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php