global statement removal: hphp/test [7/x]
[hiphop-php.git] / hphp / test / quick / fc_enum_1.php
blob37637fb5e12903a43abfe95903d2a90b089ef5b7
1 <?hh
3 enum Foo : int as int {
4 FOO = 1;
5 BAR = 2;
6 BAZ = 3;
9 type Nus = int;
10 enum Bar : Nus {
11 FOO = 1;
12 BAR = 2;
13 BAZ = 3;
16 enum Baz : mixed {
17 FOO = 1;
18 BAR = "welp";
22 function test(): @Foo {
23 return Foo::FOO;
26 function test2(@int $x): void {
27 var_dump($x);
30 function lurr(): void {
31 test2(Foo::BAR);
34 function do_case(@Bar $x): int {
35 switch ($x) {
36 case Bar::FOO:
37 return 0;
38 case Bar::BAR:
39 return 1;
40 case Bar::BAZ:
41 return 2;
43 return -1;
46 function welp(@Baz $x): void {
47 var_dump($x);
50 var_dump(test());
51 lurr();
52 var_dump(do_case(Bar::BAR));
53 // This is bogus and should produce warning
54 var_dump(do_case("welp"));
55 welp(Baz::FOO);
56 welp(Baz::BAR);
57 // This is bogus but will work fine
58 welp(20);
59 // This is bogus and should produce warning
60 welp(20.0);