@ 2014-10-29T19:54:48Z <?php
set_error_handler(
function(
HH\int $errno,
HH\string $errstr
) {
printf("ERROR (%d): %s\n ==> ", $errno, $errstr);
// ON ERROR RESUME NEXT;
return true;
}
);
class string {
}
class int {
}
class float {
}
class bool {
}
function test_hh_string(HH\string $foo) { var_dump($foo); }
function test_hh_int(HH\int $foo) { var_dump($foo); }
function test_hh_float(HH\float $foo) { var_dump($foo); }
function test_hh_bool(HH\bool $foo) { var_dump($foo); }
function test_string(string $foo) { var_dump($foo); }
function test_int(int $foo) { var_dump($foo); }
function test_float(float $foo) { var_dump($foo); }
function test_bool(bool $foo) { var_dump($foo); }
print("--- CORRECT USAGE ---\n");
test_hh_string('123');
test_hh_int(123);
test_hh_float(1.23);
test_hh_bool(true);
test_string(new string());
test_int(new int());
test_float(new float());
test_bool(new bool());
print("--- INCORRECT USAGE ---\n");
test_hh_string(new string());
test_hh_int(new int());
test_hh_float(new float());
test_hh_bool(new bool());
test_string('123');
test_int(123);
test_float(1.23);
test_bool(true);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.3.0 - 5.3.29 , 5.4.0 - 5.4.34 , 5.5.0 - 5.5.18 , 5.6.0 - 5.6.2 --- CORRECT USAGE ---
Catchable fatal error: Argument 1 passed to {closure}() must be an instance of HH\int, integer given in /in/iWH0N on line 5
Process exited with code 255 . Output for 4.4.2 - 4.4.9 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/iWH0N on line 4
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 , 5.0.0 - 5.0.5 Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/iWH0N on line 4
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error, expecting `')'' in /in/iWH0N on line 4
Process exited with code 255 . preferences:dark mode live preview
216.65 ms | 1395 KiB | 145 Q