Alexander Lisachenko wrote on 01/11/2015 21:49:
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);
     }
}
[...]
 From userland point of view, these signatures should be compatible, so I
decided to check this behavior, was it intended or not.

Should they? func_get_args() can be used to simulate any function signature, so you could equally say that the following are "compatible":

class Foo {
    public static function test($foo, $bar, $baz) {
    }
}

class Baz extends Foo {
    public static function test() {
        list($foo, $bar, $baz) = var_dump(func_get_args());
        parent::test($foo, $bar, $baz);
    }
}


Clearly, from the language's point of view, class Baz is missing the parameters in its function signature that Foo specifies, so the warning seems perfectly correct to me. In your example, you've replaced a single optional parameter ($bar = null) with a specification of variadic parameters (...$args); these are clearly not interchangeable, so again, the signature is different.

Regards,
--
Rowan Collins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to