<?php
error_reporting(E_ALL|E_STRICT);
class Foo {}
class Hoge
{
public function aaa(Foo $foo, $piyo)
{
var_dump($foo);
}
}
class Bar extends Hoge
{
public function aaa($foo = null)
{
parent::aaa($foo, 'aaa');
}
}
$hoge = new Hoge();
$hoge->aaa(new Foo(), 'aaa');
$bar = new Bar();
$bar->aaa(new Foo());
Fatal error: Declaration of Bar::aaa($foo = null) must be compatible with Hoge::aaa(Foo $foo, $piyo) in /in/0EJ6s on line 17
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of Bar::aaa($foo = NULL) should be compatible with Hoge::aaa(Foo $foo, $piyo) in /in/0EJ6s on line 17
object(Foo)#2 (0) {
}
object(Foo)#3 (0) {
}
Warning: Declaration of Bar::aaa($foo = NULL) should be compatible with Hoge::aaa(Foo $foo, $piyo) in /in/0EJ6s on line 21
object(Foo)#2 (0) {
}
object(Foo)#3 (0) {
}
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Strict Standards: Declaration of Bar::aaa() should be compatible with Hoge::aaa(Foo $foo, $piyo) in /in/0EJ6s on line 21
object(Foo)#2 (0) {
}
object(Foo)#3 (0) {
}