<?php
function setAge(int $age)
{
var_dump($age);
}
// First test is clearly wrong
// setAge("totally not an int"); <-- Fatal error expected int found string
// Try passing something like this
setAge("30+1");
// What about this?
setAge("30");
// Finally a real int :)
setAge(30);
// U jelly?
setAge(.1);
Fatal error: Uncaught TypeError: setAge(): Argument #1 ($age) must be of type int, string given, called in /in/OIDal on line 11 and defined in /in/OIDal:3
Stack trace:
#0 /in/OIDal(11): setAge('30+1')
#1 {main}
thrown in /in/OIDal on line 3
Process exited with code 255.
Catchable fatal error: Argument 1 passed to setAge() must be an instance of int, string given, called in /in/OIDal on line 11 and defined in /in/OIDal on line 3
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Fatal error: Argument 1 passed to setAge() must be an object of class int, called in /in/OIDal on line 11 and defined in /in/OIDal on line 3
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Argument 1 must be an object of class int in /in/OIDal on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/OIDal on line 3
Process exited with code 255.