+1 Nice to be able to do this directly without resorting to call_user_func().
Edom Etienne Kneuss wrote: > Hi, > > I've already proposed that 1-2 months ago, but now seems to be a good > time to discuss new things, so let's try again: > > I believe it would be nice to be able to dynamically reference static > members, constants, and methods. > > 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 = 'value1'; > const gee = 'value2'; > public static function bar() { return 'value3'; } > > // old way: > public static function getFoo() { return self::$foo; } > public static function getGee() { return self::gee; } > > } > > $classname = 'A'; > echo $classname::$foo; // value1 > echo $classname::gee; // value2 > echo $classname::bar(); // value3 > > // --- instead of: --- > > $classname = 'A'; > echo call_user_func(array($classname, 'getFoo')); // value1 > echo call_user_func(array($classname, 'getGee')); // value2 > echo call_user_func(array($classname, 'bar')); // value3 > > which is quite slow. > > Please take a look at the patch[1] I made for it. Comments would be > appreciated! > > Regards, > > > 1: http://patches.colder.ch/Zend/dynamic-static-calls.patch?markup > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php