3 ms·
In PHP, variables, functions, constants and classes are all completely separate namespaces, and likewise methods, properties and static properties are separate
by TazeTSchnitzel 10y ago
In PHP, variables, functions, constants and classes are all completely separate namespaces, and likewise methods, properties and static properties are separate namespaces.
Reusing :: for namespaces would complicate this. Is foo::bar a class constant or a namespaced constant? Do we autoload src/foo.php or src/foo/bar.php? If I do `new foobar::qux`, is foobar::qux a class, a class constant containing a class name, or a namespaced constant containing a class name? Do we autoload src/foobar.php or src/foobar/qux.php?
It's not like the lexer or parser could magically solve this. The way the language is designed, there is inherent ambiguity here.
In some other languages, there is a unified symbol table, so you don't have this problem. But PHP doesn't have that.