Closed fredemmott closed 4 years ago
I vote to keep the nesting behaviour, but fix it so it's sane.
Fix is up internally D1669100
This is inconsistent with the typechecker.
namespace Foo {
namespace Bar {
class Baz { }
}
}
HHVM thinks it's \Foo\Bar\Baz
, hh_client thinks it's \Bar\Baz
.
I am going over old issues on this repository, to see which ones apply to the current versions of hhvm.
Hhvm and the typechecker now correctly identify the class as \Foo\Bar\Baz
.
<?hh
namespace {
namespace Foo {
namespace Bar {
final class Baz {
public function __construct() {
echo static::class.\PHP_EOL;
}
}
function inner(): void {
new Baz();
}
}
function one_level_out(): void {
new Bar\Baz();
}
}
function top_level(): void {
new \Foo\Bar\Baz();
}
<<__EntryPoint>>
function entrypoint(): void {
\Foo\Bar\inner();
\Foo\one_level_out();
\top_level();
}
}
outputs
Foo\Bar\Baz
Foo\Bar\Baz
Foo\Bar\Baz
This works:
it probably shouldn't - nesting namespaces is entirely forbidden in PHP5. If they're supposed to be nestable, that should probably be Foo\Bar\Baz :)