On Mon, Nov 28, 2011 at 1:11 PM, Nikita Popov <nikita....@googlemail.com> wrote: > How would this be different from defining a function MyClass?
Actually, I just found myself wanting this the other day. The class name in question was being defined in a config file, which the user would be free to override with their own class name (and a closure was ruled out because this config file could be xml/ini/etc). There are plenty of other ways I decided I could work around this, but I did stop and think that something like __invokeStatic() would be nice. My main rationale for wanting this was that classes can be resolved via an autoloader, whereas functions cannot. However, I could definitely see where this could get sticky. For example: <?php function MyClass() { return true; } abstract class MyClass { public static function __invokeStatic() { return false; } } $className = 'MyClass'; var_dump($className()); ?> What would the output be in a case like this? Right now, while it's horrible practice to share names across functions and classes, they don't actually share the same namespace. Something like __invokeStatic() would make it ambiguous in some cases (like above), so I'm not really sure how that could be resolved. -- Evan Coury -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php