mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
e72bf63691
Any number of arguments can be replaced by a variadic one, so long as the variadic argument is compatible (in the sense of contravariance) with the subsumed arguments. In particular this means that function(...$args) becomes a near-universal signature: It is compatible with any function signature that does not accept parameters by-reference. This also fixes bug #70839, which describes a special case. Closes GH-5059.
17 lines
312 B
PHP
17 lines
312 B
PHP
--TEST--
|
|
Illegal variadic inheritance due to reference mismatch
|
|
--FILE--
|
|
<?php
|
|
|
|
class A {
|
|
public function test(&$a, &$b) {}
|
|
}
|
|
|
|
class B extends A {
|
|
public function test(...$args) {}
|
|
}
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Fatal error: Declaration of B::test(...$args) must be compatible with A::test(&$a, &$b) in %s on line %d
|