Re: [RFC][DISCUSSION] Strict Argument Count

From: Date: Mon, 02 Mar 2015 04:43:33 +0000
Subject: Re: [RFC][DISCUSSION] Strict Argument Count
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi Marcio,

On Mon, Mar 2, 2015 at 8:02 AM, Marcio Almada <[email protected]> wrote:

> I'm moving the "Strict Argument Count" RFC into discussion phase:
>
> RFC: https://wiki.php.net/rfc/strict_argcount
> PR: https://github.com/php/php-src/pull/1108
>
> Many different opinions were collected during research phase and the RFC
> was updated with real BC break measurements and other important sections.
> So, before discussing:
>
>    - Even if you already read the RFC in the past, read it again now.
>    - Don't claim **possible** massive BC breaks before read the
>    measurements already done. No matter how seasoned you are with PHP, real
>    numbers matter most than assumptions. Your measurements are welcome too.
>    - Try the patch. Really.
>    - Consider reading the use case present on this post: goo.gl/3ykdIy
>    - Keep discussion on topic and remember we are all trying to improve PHP
>    in some way :)
>

I like the idea.

/** fn expects a variable-length argument lists */
function fn($arg) {
    $arg = func_get_arg();
    $args = func_get_args();
}

fn(1); // Ok
fn(...[1, 2, 3, 4, 5]); // Ok
call_user_func_array("fn", [1, 2, 3, 4, 5, 6, 7]); // Ok

I understand motivation why your patch behave like this. It's for BC, right?
However, isn't it better to declare variable length parameters by function
signature
in the long run?

function fn($arg, ...) {}

Is it possible to have E_DEPRECATED error without "..."?  and do not care
about func_get_arg*() existence? Make E_DEPRECATED error E_WARNING
in PHP 7.2 or 7.3.


Regards,

--
Yasuo Ohgaki
[email protected]


Thread (47 messages)

« previous php.internals (#84143) next »