Consider the following code:

foo.php:
<?php
class test {
  public static function foo() { echo "I'm foo in class test\n"; }
  public static function foo2() { self::foo(); }
}
?>

foo2.php:
<?php
namespace test;
function foo() { echo "I'm foo in namespace test\n"; }
?>

test.php:
<?php
include 'foo.php';
include 'foo2.php';
test::foo(); // I'm foo in namespace test
use test::foo as dummy;
test::foo(); // I'm foo in namespace test
test::foo2(); // I'm foo in class test
$test = 'test';
$test::foo(); // I'm foo in class test
call_user_func(array('test', 'foo')); // I'm foo in class test
?>

Please review the following observations:

There's a name clash that goes undetected: test::foo refers to both a
namespaced function and a static method.

Once the clash occur there's no way to refer to the static method through a
static reference, except when within the class scope where you can refer to
the method through self::
The static method remains partially hidden by the namespaced function.

Best Regards,

Martin Alterisio

Reply via email to