Revert "Fix bug in mysql_next_result's return value that confused "done" with "error""
[hiphop-php.git] / hphp / doc / extension.type_hints
blobd43687360b2f1cdd3b656c3c13f9e73434a30720
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
11 function foo():
13   function foo(int $a) {
14     return $a + 1;
15   }
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