Bart de Boer wrote:
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:
<?php
class Data {
static function findRange() {
if (!child::$tableName)
throw new Exception('WTF');
else
return child::$tableName;
}
}
class Prod {
static $tableName = 'PRODS';
}
?>
But it seems this feature request belongs in a different thread. :)
Late static binding can also be used to access static properties, of
course. The same class resolution mechanism is used by foo::$member and
foo::method(); so the keyword would apply to both.
Same with magic syntax like $a = new self();
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::
?
It's always dangerous to introduce a new keyword, as it can/will break
BC (i.e what if somebody has defined a function derived(), the parser
would choke on that).
I'm personally fine with static, even if it may eventually introduce
some confusion.
Regards
--
Etienne Kneuss
http://www.colder.ch
Men never do evil so completely and cheerfully as
when they do it from a religious conviction.
-- Pascal
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php