<?php
class C {
}
class A {
public function b(/* C */ $c) {
echo 'c';
}
}
class B extends A {
public function b(C $c) {
echo 'd';
}
}
$c = new C();
$b = new B();
echo $b->b($c);
Fatal error: Declaration of B::b(C $c) must be compatible with A::b($c) in /in/HPrqa on line 14
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in /in/HPrqa on line 13
Warning: Declaration of B::b(C $c) should be compatible with A::b($c) in /in/HPrqa on line 14
Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::b(), 0 passed in /in/HPrqa on line 20 and exactly 1 expected in /in/HPrqa:14
Stack trace:
#0 /in/HPrqa(20): B->b()
#1 {main}
thrown in /in/HPrqa on line 14
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::b(), 0 passed in /in/HPrqa on line 20 and exactly 1 expected in /in/HPrqa:14
Stack trace:
#0 /in/HPrqa(20): B->b()
#1 {main}
thrown in /in/HPrqa on line 14
Process exited with code 255.
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in /in/HPrqa on line 13
Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::b(), 0 passed in /in/HPrqa on line 20 and exactly 1 expected in /in/HPrqa:14
Stack trace:
#0 /in/HPrqa(20): B->b()
#1 {main}
thrown in /in/HPrqa on line 14
Process exited with code 255.
Output for 7.0.0 - 7.0.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in /in/HPrqa on line 13
Fatal error: Uncaught TypeError: Argument 1 passed to B::b() must be an instance of C, none given, called in /in/HPrqa on line 20 and defined in /in/HPrqa:14
Stack trace:
#0 /in/HPrqa(20): B->b()
#1 {main}
thrown in /in/HPrqa on line 14
Process exited with code 255.
Output for 5.6.0 - 5.6.40
Catchable fatal error: Argument 1 passed to B::b() must be an instance of C, none given, called in /in/HPrqa on line 20 and defined in /in/HPrqa on line 14
Process exited with code 255.