3 class GenericClass
<T
> {}
5 public function bar(): float {
11 // Using array without type parameters is okay for now
12 array bar
-baz
= array(),
13 // Using GenericClass without type parameters is okay for now
15 GenericClass yo @required
,
16 // Check to make sure that "->:" parses correctly when chained
17 // together in a larger expression.
18 SomeClass some
-obj @required
,
19 // An XHP class name can be used as a type hint; marking it
20 // with "@required" so the typechecker knows it can't be null
21 :blah fizz
-buzz @required
,
22 // If it's not marked "@required" and is doesn't have a non-null
23 // default value, then the typechecker treats it as nullable
25 // Make sure the weird trait importation syntax works when
26 // interleaved with normal XHP attribute declarations
28 // An XHP attribute annoted as "string" can contain Stringish
30 string string:attr
-might
-be
:stringish
= '',
31 // Make sure that attribute names with colons work fine
32 string name
:with
:colon
;
34 function test1(:foo
$obj): :blah
{
35 return $obj->:fizz
-buzz
;
37 function test2(:foo
$obj): ?
:blah
{
38 return $obj->:might
-be
-null;
40 function test3(:foo
$obj): Stringish
{
41 return $obj->:string:attr
-might
-be
:stringish
;
43 function test4(:foo
$obj): float {
44 return $obj->:some
-obj
->bar();
46 function test5(:foo
$obj): ?
string {
47 return $obj->:name
:with
:colon
;