global statement removal: hphp/test [7/x]
[hiphop-php.git] / hphp / test / quick / typehint_number.php
blob4e9b56f13316f0c5cbfa15bdb8eace03426c4e1d
1 <?hh
3 function my_handler($errno, $errstr, $file, $line) {
4 throw new Exception($errstr);
7 function try_takes_num($a) {
8 try {
9 takes_num($a);
10 } catch (Exception $e) {
11 echo $e->getMessage(), "\n";
15 function takes_num(num $a) {
16 var_dump($a);
19 class NumericallyStringable {
20 function __toString() {
21 return "100";
25 function main() {
26 try_takes_num(10);
27 try_takes_num(10.0);
28 try_takes_num(10.5);
29 try_takes_num('10.5'); // nope: no strings, even numeric
30 try_takes_num('foo'); // nope: string
31 try_takes_num(new NumericallyStringable()); // nope: object
32 try_takes_num(new StdClass()); // nope: object
35 set_error_handler('my_handler');
36 main();