@ 2015-10-06T15:00:04Z <?php
function myErrorHandler($errno) {
var_dump($errno);
if ( E_RECOVERABLE_ERROR===$errno ) {
echo "'catched' catchable fatal error\n";
return true;
}
return false;
}
set_exception_handler('myErrorHandler');
class ClassA {
public function method_a (ClassB $b) {}
}
class ClassWrong{}
$a = new ClassA;
$a->method_a(new ClassWrong);
echo 'done.';
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 object(TypeError)#3 (7) {
["message":protected]=>
string(109) "ClassA::method_a(): Argument #1 ($b) must be of type ClassB, ClassWrong given, called in /in/0WCuK on line 20"
["string":"Error":private]=>
string(0) ""
["code":protected]=>
int(0)
["file":protected]=>
string(9) "/in/0WCuK"
["line":protected]=>
int(14)
["trace":"Error":private]=>
array(1) {
[0]=>
array(6) {
["file"]=>
string(9) "/in/0WCuK"
["line"]=>
int(20)
["function"]=>
string(8) "method_a"
["class"]=>
string(6) "ClassA"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
object(ClassWrong)#2 (0) {
}
}
}
}
["previous":"Error":private]=>
NULL
}
Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 object(TypeError)#3 (7) {
["message":protected]=>
string(131) "Argument 1 passed to ClassA::method_a() must be an instance of ClassB, instance of ClassWrong given, called in /in/0WCuK on line 20"
["string":"Error":private]=>
string(0) ""
["code":protected]=>
int(0)
["file":protected]=>
string(9) "/in/0WCuK"
["line":protected]=>
int(14)
["trace":"Error":private]=>
array(1) {
[0]=>
array(6) {
["file"]=>
string(9) "/in/0WCuK"
["line"]=>
int(20)
["function"]=>
string(8) "method_a"
["class"]=>
string(6) "ClassA"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
object(ClassWrong)#2 (0) {
}
}
}
}
["previous":"Error":private]=>
NULL
}
Output for 5.4.2 - 5.4.45 , 5.5.24 - 5.5.35 , 5.6.8 - 5.6.28 Catchable fatal error: Argument 1 passed to ClassA::method_a() must be an instance of ClassB, instance of ClassWrong given, called in /in/0WCuK on line 20 and defined in /in/0WCuK on line 14
Process exited with code 255 . preferences:dark mode live preview
237.85 ms | 402 KiB | 270 Q