<?php
class ClassA {
public function method_a (ClassB $b) {}
}
class ClassWrong{}
$a = new ClassA;
$a->method_a(new ClassWrong);
echo 'done.';
/*
throw new MyException('This is a really bad error', 123);
final public ExceptionException::getPrevious ( void )
error_reporting(E_ALL);
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, '00007600', $errno, $errfile, $errline, new Exception('jjj'));
}
set_error_handler("exception_error_handler");
try {
echo $x;
}
catch(Exception $e) {
var_dump($e->getPrevious());
}*/
Fatal error: Uncaught TypeError: ClassA::method_a(): Argument #1 ($b) must be of type ClassB, ClassWrong given, called in /in/jP2QC on line 11 and defined in /in/jP2QC:5
Stack trace:
#0 /in/jP2QC(11): ClassA->method_a(Object(ClassWrong))
#1 {main}
thrown in /in/jP2QC on line 5
Process exited with code 255.
Fatal error: Uncaught TypeError: Argument 1 passed to ClassA::method_a() must be an instance of ClassB, instance of ClassWrong given, called in /in/jP2QC on line 11 and defined in /in/jP2QC:5
Stack trace:
#0 /in/jP2QC(11): ClassA->method_a(Object(ClassWrong))
#1 {main}
thrown in /in/jP2QC on line 5
Process exited with code 255.
Catchable fatal error: Argument 1 passed to ClassA::method_a() must be an instance of ClassB, instance of ClassWrong given, called in /in/jP2QC on line 11 and defined in /in/jP2QC on line 5
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Class 'ClassB' not found in /in/jP2QC on line 5
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/jP2QC on line 5
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/jP2QC on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/jP2QC on line 5
Process exited with code 255.