Hi,
You examples are showing some quite horrible situations with namespaces.
Agreed, the least thing, an error should be thrown on collision.
Regards,
Stan Vassilev
I find the namespace resolution rules quite confusing. It's become quite
difficult to tell if I'm calling a static method or a function, or
namespaced static method or namespaced function, and so on. I don't quite
fully understand or appreciated the point of namespaces. If some one could
help me out here.
-- google.php --
<?php
namespace Google;
function search() {
return 'namespace google search';
}
-- test.php --
<?php
require('google.php');
class Google {
public static function search() {
return 'class google search';
}
public static function test() {
return 'class google test';
}
}
function search() {
return 'global function search';
}
use Google as Other;
echo '1 '.__FILE__.' #'.__LINE__.' '.search().'<br/>';
echo '2 '.__FILE__.' #'.__LINE__.' '.Google::search().'<br/>';
echo '3 '.__FILE__.' #'.__LINE__.' '.Google::test().'<br/>';
echo '4 '.__FILE__.' #'.__LINE__.' '.Other::test().'<br/>';
1. behaved as I expected it to.
2. didn't do what I thought it should have done, now the class is broken,
but wouldn't though any exception.
3. behaved as I expected it to.
4. wow strange I've managed to rename my class though namespace resolution
rules.
I feel that namespaces are going to cause some big problems. Shouldn't it
wait for PHP6 rather than backport to PHP5.
This is only one of the problems I've come across with namespaces.
Is it going to be possible to get to the google class search method? I
find
it terrible that now a name *DOES* clash, but this time with out so much
as
an error! I preferred it to highlight the fact that I had a class with the
same name.
Any thoughts?
/James
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php