2 <h2>Richer type hints</h2>
4 This feature requires the [[index.php?file=options.compiler | compiler option]]
5 EnableHipHopSyntax=true, or interpreter option Eval.EnableHipHopSyntax=true.
7 HipHop extends the support of type hints to primitive types, like bool, int, and
8 double. It also supports string for type hints.
10 For example, the following code would only allow passing an integer to the
13 function foo(int $a) {
17 The main purposes for type hinting are (1) more efficient execution, (2) more
18 explicit contract for functions.
20 As in vanilla PHP, HipHop allows type-hinted parameters to have null as the
21 default value, even if the type hint is a primitive type.
23 function foo(int $a = null) { ... }
24 foo(null); // then passing null is allowed