Re: [patch] Dynamic access of static members/methods, and constants

From: Date: Tue, 06 Mar 2007 22:20:05 +0000
Subject: Re: [patch] Dynamic access of static members/methods, and constants
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-28277@lists.php.net to get a copy of this message
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

« previous php.internals (#28277) next »