Stanislav Malyshev schreef:
Hi!
------------------------------------------------------------------------
1. include.php <?php
namespace Test;
class Bar { public static function baz() { return 'namespaced static
method'; } }
function foo() { return 'namespaced function'; }
------------------------------------------------------------------------
2. index.php <?php
require_once 'include.php'; use Test::Bar;
class Test { public static function foo() { return 'static method'; }
}
I would advise you to avoid calling your classes and namespaces by the
same name, for the sake of clarity - especially if you are going to have
identically named static functions in both. You can always have My::Test
instead, etc.
essentially good advice, but completely dismissive of the underlying issue.
2. How should I call the static method
baz of class Bar in namespace Test with call_user_func
call_user_func(array('Test::Bar', 'baz')). Remember, the true name is
always the full name.
3. Is there no possibility to change your minds and replace the double
colon with
something else, likes a simple colon?
With simple colon - not likely.
what about a simple new concept then?
I find it very confusing to
figure out what is what and the way I should call it.
You should always use full name with call_*, reflection, variable class
names and other runtime constructs. You can use shortcuts with static
constructs - where you specify the class name explicitly.
now that last point is darn good raw material for an upcoming namespaces
guideline, don't mind if I pinch it do you?
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php