Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix namespacing of classname shape keys for type aliases
Summary: Fixes #8195 Reviewed By: fredemmott Differential Revision: D7958066
- Loading branch information
1 parent
950b326
commit 6272f66
Showing
4 changed files
with
158 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?hh | ||
|
||
namespace SomeNS { | ||
|
||
enum Foo: string { | ||
VALUE = __CLASS__; | ||
} | ||
|
||
enum Bar: string { | ||
VALUE = __CLASS__; | ||
} | ||
|
||
enum Baz: string { | ||
VALUE = __CLASS__; | ||
} | ||
|
||
} | ||
|
||
namespace MyNS { | ||
|
||
|
||
namespace MySubNS { | ||
|
||
enum MyEnum: string { | ||
VALUE = 'Herp'; | ||
} | ||
|
||
} | ||
|
||
use type SomeNS\Foo; | ||
use SomeNS\Bar; | ||
|
||
enum MyEnum: string { | ||
FOO = 'Herp'; | ||
} | ||
|
||
type MyShape = shape( | ||
MyEnum::FOO => string, | ||
); | ||
|
||
type T = MyEnum; | ||
|
||
type UsesFoo = shape(Foo::VALUE => int); | ||
type UsesBar = shape(Bar::VALUE => int); | ||
type UsesBaz = shape(\SomeNS\Baz::VALUE => int); | ||
|
||
type ExplicitRelative = shape(namespace\MyEnum::FOO => int); | ||
type ImplicitRelative = shape(MySubNS\MyEnum::VALUE => int); | ||
|
||
var_dump(type_structure(MyShape::class)); | ||
var_dump(type_structure(T::class)); | ||
var_dump(type_structure(UsesFoo::class)); | ||
var_dump(type_structure(UsesBar::class)); | ||
var_dump(type_structure(UsesBaz::class)); | ||
var_dump(type_structure(ExplicitRelative::class)); | ||
var_dump(type_structure(ImplicitRelative::class)); | ||
|
||
} |
92 changes: 92 additions & 0 deletions
92
hphp/test/slow/namespace/alias/namespaced_aliases.php.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
array(3) { | ||
["kind"]=> | ||
int(14) | ||
["fields"]=> | ||
array(1) { | ||
["Herp"]=> | ||
array(1) { | ||
["kind"]=> | ||
int(4) | ||
} | ||
} | ||
["alias"]=> | ||
string(12) "MyNS\MyShape" | ||
} | ||
array(3) { | ||
["kind"]=> | ||
int(18) | ||
["classname"]=> | ||
string(11) "MyNS\MyEnum" | ||
["alias"]=> | ||
string(6) "MyNS\T" | ||
} | ||
array(3) { | ||
["kind"]=> | ||
int(14) | ||
["fields"]=> | ||
array(1) { | ||
["SomeNS\Foo"]=> | ||
array(1) { | ||
["kind"]=> | ||
int(1) | ||
} | ||
} | ||
["alias"]=> | ||
string(12) "MyNS\UsesFoo" | ||
} | ||
array(3) { | ||
["kind"]=> | ||
int(14) | ||
["fields"]=> | ||
array(1) { | ||
["SomeNS\Bar"]=> | ||
array(1) { | ||
["kind"]=> | ||
int(1) | ||
} | ||
} | ||
["alias"]=> | ||
string(12) "MyNS\UsesBar" | ||
} | ||
array(3) { | ||
["kind"]=> | ||
int(14) | ||
["fields"]=> | ||
array(1) { | ||
["SomeNS\Baz"]=> | ||
array(1) { | ||
["kind"]=> | ||
int(1) | ||
} | ||
} | ||
["alias"]=> | ||
string(12) "MyNS\UsesBaz" | ||
} | ||
array(3) { | ||
["kind"]=> | ||
int(14) | ||
["fields"]=> | ||
array(1) { | ||
["Herp"]=> | ||
array(1) { | ||
["kind"]=> | ||
int(1) | ||
} | ||
} | ||
["alias"]=> | ||
string(21) "MyNS\ExplicitRelative" | ||
} | ||
array(3) { | ||
["kind"]=> | ||
int(14) | ||
["fields"]=> | ||
array(1) { | ||
["Herp"]=> | ||
array(1) { | ||
["kind"]=> | ||
int(1) | ||
} | ||
} | ||
["alias"]=> | ||
string(21) "MyNS\ImplicitRelative" | ||
} |