Page MenuHomePhabricator

Let default parameters linter rule support `...` in variadic function
Open, Needs TriagePublic

Description

In PHP5.6, variadic functions can now be implemented using the ... operator. For example,

<?php
function f($req, $opt = null, ...$params) {
    // $params is an array containing the remaining arguments.
    printf('$req: %d; $opt: %d; number of params: %d'."\n",
           $req, $opt, count($params));
}

However, this new syntax currently violate default value linter rule:

Warning  (XHP60) Default Parameters
 Arguments with default values must be at the end of the argument list.

            1 <?php
            2
 >>>        3 function f($req, $opt = null, ...$params) {
            4     // $params is an array containing the remaining arguments.
            5     printf('$req: %d; $opt: %d; number of params: %d'."\n",
            6            $req, $opt, count($params));