Hi,
It may have already been proposed, but I give it a shot:
I believe it would be nice to be able to dynamically reference static
members and constants.
Currently, there is no way to do that and the only way would be to
create a static method and use call_user_func(array($classname, 'getThat'));
In other words:
class A {
public static $foo = 'bar';
const gee = 'zzz';
public static function getFoo() { return self::$foo; }
}
$classname = 'A';
echo $classname::$foo; // bar
echo $classname::gee; // zzz
// instead of:
echo call_user_func(array($classname, 'getFoo'));
Please take a look at the patch I made for it.
For consistency purposes, I also implemented $classname::myMethod();
even if it's not required. FWIW, I've no strong feeling about it.
Regards,
--
Etienne Kneuss
http://www.colder.ch
colder@php.net
Men never do evil so completely and cheerfully as
when they do it from a religious conviction.
-- Pascal
Hello Etienne,
besides a tiny bit of whitespace issues the patch looks fine. Actually we
use tabs at the beginning of lines here (prior and after |'s). Once you got
more people looking/commenting on the patch we mde decide whetehr to apply
it.
best regards
marcus
Tuesday, March 6, 2007, 4:06:55 PM, you wrote:
Hi,
It may have already been proposed, but I give it a shot:
I believe it would be nice to be able to dynamically reference static
members and constants.
Currently, there is no way to do that and the only way would be to
create a static method and use call_user_func(array($classname, 'getThat'));
In other words:
class A {
public static $foo = 'bar';
const gee = 'zzz';
public static function getFoo() { return self::$foo; }
}
$classname = 'A';
echo $classname::$foo; // bar
echo $classname::gee; // zzz
// instead of:
echo call_user_func(array($classname, 'getFoo'));
Please take a look at the patch I made for it.
For consistency purposes, I also implemented $classname::myMethod();
even if it's not required. FWIW, I've no strong feeling about it.
Regards,
Best regards,
Marcus