Le 04/04/2024 à 23:38, Mark Trapp a écrit :
On Thu, Apr 4, 2024 at 2:16 PM Bilge <bi...@scriptfusion.com> wrote:
On 04/04/2024 16:57, Tim Düsterhus wrote:
I think it would be reasonable to consider deprecating passing extra
arguments to a non-variadic function.
This seems like the only reasonable thing to do, to me. If this were the
case, there should be no need for any new syntax, since we could simply
deny passing extra arguments in the next major, no?

Bilge
I'd caution about being too hasty to deprecate and remove support for
this feature without understanding the underlying reasons why it has
been used historically, and without providing a better (not just
different) alternative for those use cases, lest an impossible upgrade
path is created.

While the variadic operator should be a 1:1 replacement for using
func_get_args(), is it enough of a benefit to force potentially tens
of thousands of codebases to change when they both accomplish the same
thing? What bad thing happens if PHP continues to support both
methods?

There is already enough friction to upgrade between major versions.
Introducing an optional attribute or syntax allows codebases that care
about signature strictness get that safety, while avoiding a
potentially costly and onerous upgrade for the community.

- Mark

I agree with both, ie. I think it's reasonable to deprecate extra variadic arguments, but also do it with caution: some old code, some templating systems for example may use implicit variadic arguments to pass values to templates.

There are tons of use case like this in old yet still running code.

But I would love it to be deprecated, raise warnings, and give some time for people to fix (adding an explicit `mixed ... $values` is enough to fix broken code).

Cheers,

--

Pierre

Reply via email to