[Question] Variadic method signature compatibility between 5.6 and 7.0
| From: | Alexander Lisachenko | Date: | Sun, 01 Nov 2015 21:49:03 +0000 |
| Subject: | [Question] Variadic method signature compatibility between 5.6 and 7.0 | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-89029@lists.php.net to get a copy of this message | ||
Hello, internals!
I have a question about changed behavior in 7.0 for matching signature of
variadic method.
Here is an example of code:
class Foo {
public static function test($bar = null) {
var_dump(func_get_args());
}
}
class Baz extends Foo {
public static function test(...$args) {
parent::test(...$args);
}
}
Baz::test();
Baz::test('hello');
For 5.6 this code works normally, but in 7.0 it produces a warning about
signature: "Warning: Declaration of Baz::test(...$args) should be
compatible with Foo::test($bar = NULL)"
See https://3v4l.org/so6P2
From userland point of view, these signatures should be compatible, so I
decided to check this behavior, was it intended or not.
Thanks!