<?php
class A {
public function test(A $a) {
var_dump($a);
}
}
class B extends A {
public function test(B $b) {
parent::test($b);
}
}
$a = new A;
$b = new B;
$b->test($a);
Fatal error: Declaration of B::test(B $b) must be compatible with A::test(A $a) in /in/BfA93 on line 14
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of B::test(B $b) should be compatible with A::test(A $a) in /in/BfA93 on line 14
Fatal error: Uncaught TypeError: Argument 1 passed to B::test() must be an instance of B, instance of A given, called in /in/BfA93 on line 23 and defined in /in/BfA93:14
Stack trace:
#0 /in/BfA93(23): B->test(Object(A))
#1 {main}
thrown in /in/BfA93 on line 14
Process exited with code 255.
Warning: Declaration of B::test(B $b) should be compatible with A::test(A $a) in /in/BfA93 on line 18
Fatal error: Uncaught TypeError: Argument 1 passed to B::test() must be an instance of B, instance of A given, called in /in/BfA93 on line 23 and defined in /in/BfA93:14
Stack trace:
#0 /in/BfA93(23): B->test(Object(A))
#1 {main}
thrown in /in/BfA93 on line 14
Process exited with code 255.
Strict Standards: Declaration of B::test() should be compatible with A::test(A $a) in /in/BfA93 on line 18
Catchable fatal error: Argument 1 passed to B::test() must be an instance of B, instance of A given, called in /in/BfA93 on line 23 and defined in /in/BfA93 on line 14
Process exited with code 255.
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Strict Standards: Declaration of B::test() should be compatible with that of A::test() in /in/BfA93 on line 18
Catchable fatal error: Argument 1 passed to B::test() must be an instance of B, instance of A given, called in /in/BfA93 on line 23 and defined in /in/BfA93 on line 14
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Strict Standards: Declaration of B::test() should be compatible with that of A::test() in /in/BfA93 on line 18
Fatal error: Argument 1 passed to B::test() must be an instance of B, called in /in/BfA93 on line 23 and defined in /in/BfA93 on line 14
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Strict Standards: Declaration of B::test() should be compatible with that of A::test() in /in/BfA93 on line 18
Fatal error: Argument 1 must be an instance of B in /in/BfA93 on line 14
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/BfA93 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/BfA93 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/BfA93 on line 5
Process exited with code 255.