<?php
class A {
protected $message = 'breaks';
public function __construct() {
}
public function getMessage($type) {
return $this->message;
}
}
class B extends A {
public function __construct($message) {
parent::__construct();
$this->message = $message;
}
public function getMessage($type, $extra) {
return $this->message;
}
}
$o = new B('works');
echo $o->getMessage() . PHP_EOL;
Fatal error: Declaration of B::getMessage($type, $extra) must be compatible with A::getMessage($type) in /in/uKQM4 on line 21
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of B::getMessage($type, $extra) should be compatible with A::getMessage($type) in /in/uKQM4 on line 21
Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::getMessage(), 0 passed in /in/uKQM4 on line 27 and exactly 2 expected in /in/uKQM4:21
Stack trace:
#0 /in/uKQM4(27): B->getMessage()
#1 {main}
thrown in /in/uKQM4 on line 21
Process exited with code 255.
Warning: Declaration of B::getMessage($type, $extra) should be compatible with A::getMessage($type) in /in/uKQM4 on line 24
Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::getMessage(), 0 passed in /in/uKQM4 on line 27 and exactly 2 expected in /in/uKQM4:21
Stack trace:
#0 /in/uKQM4(27): B->getMessage()
#1 {main}
thrown in /in/uKQM4 on line 21
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Warning: Declaration of B::getMessage($type, $extra) should be compatible with A::getMessage($type) in /in/uKQM4 on line 24
Warning: Missing argument 1 for B::getMessage(), called in /in/uKQM4 on line 27 and defined in /in/uKQM4 on line 21
Warning: Missing argument 2 for B::getMessage(), called in /in/uKQM4 on line 27 and defined in /in/uKQM4 on line 21
works
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Strict Standards: Declaration of B::getMessage() should be compatible with A::getMessage($type) in /in/uKQM4 on line 24
Warning: Missing argument 1 for B::getMessage(), called in /in/uKQM4 on line 27 and defined in /in/uKQM4 on line 21
Warning: Missing argument 2 for B::getMessage(), called in /in/uKQM4 on line 27 and defined in /in/uKQM4 on line 21
works