Bug #70839 [Asn]: Convertion optional argument to variadic forbidden by LSP checks

From: Date: Mon, 02 Nov 2015 17:04:37 +0000
Subject: Bug #70839 [Asn]: Convertion optional argument to variadic forbidden by LSP checks
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196980@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70839&edit=1

 ID:                 70839
 Updated by:         nikic@php.net
 Reported by:        nikic@php.net
 Summary:            Convertion optional argument to variadic forbidden
                     by LSP checks
 Status:             Assigned
 Type:               Bug
 Package:            Scripting Engine problem
-PHP Version:        7.0.0RC6
+PHP Version:        5.6.16
 Assigned To:        nikic
 Block user comment: N
 Private report:     N

 New Comment:

Actually this issue also exists in PHP 5.6 if you have more than one optional parameter:

class Foo {
    public function test($foo = null, $bar = null) {}
}

class Baz extends Foo {
    public function test(...$args) {}
}

The fact that it worked for one was just an accident that PHP 7 fixed.

We should allow changing any number of optional arguments to a variadic one in both 5.6 and 7.0.


Previous Comments:
------------------------------------------------------------------------
[2015-11-02 16:48:45] nikic@php.net

Description:
------------
Should be allowed and was allowed in 5.6. Off by one error caused by the variadic parameter no
longer counting as an argument.

Test script:
---------------
class Foo {
    public function test($bar = null) {}
}

class Baz extends Foo {
    public function test(...$args) {}
}




------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70839&edit=1


Thread (4 messages)

« previous php.bugs (#196980) next »