dseguy, French
@dseguy@phpc.social avatar

A variadic argument collects all the unused named parameters, along with their key. That way, it is possible to handle them with their name inside the method.

On the other hand, array_merge (and some cousins) refuse them, and emits a Fatal error.

heiglandreas,
@heiglandreas@phpc.social avatar

@dseguy The fact that it actually provides the key is IMO a bug as it actually provides 2 different function signatures.

The variadic parameter should always provide a list of arguments. There should never be user-provided keys available in that parameter.

heiglandreas,
@heiglandreas@phpc.social avatar

@dseguy And TBH: That is the second thing that doesn't work as expected due to variadic parameters that I see in a week or two ...

ocramius,
@ocramius@mastodon.social avatar

@heiglandreas @dseguy variadic arguments were awesome... before named parameters ruined them.

heiglandreas,
@heiglandreas@phpc.social avatar

@ocramius @dseguy Variadic arguments are still awesome!

Just make sure to run them through array_values first 🤪

gmazzap,
@gmazzap@phpc.social avatar

@heiglandreas @ocramius @dseguy /** @no-named-arguments */

heiglandreas,
@heiglandreas@phpc.social avatar

@gmazzap That is not a fix for the problem.

It just tells the user politely that the names of the arguments are not part of the public API and one should not rely upon them. That is not enforced on a language level.

It does not fix that argument "names" are passed to a variadic parameter.

/cc @ocramius @dseguy

ocramius,
@ocramius@mastodon.social avatar

@heiglandreas @gmazzap @dseguy ye, but you will need to wait another 2 decades for a language level fix 😛

The SA stuff is all opt-in-or-I-told-you-so, so the alternative is jumping to another language.

heiglandreas,
@heiglandreas@phpc.social avatar

@ocramius Because BC Breaks.... 🤪

It's a f*cking Bug!

/cc @gmazzap @dseguy

  • All
  • Subscribed
  • Moderated
  • Favorites
  • php
  • InstantRegret
  • ngwrru68w68
  • everett
  • mdbf
  • modclub
  • rosin
  • khanakhh
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • Youngstown
  • GTA5RPClips
  • slotface
  • kavyap
  • JUstTest
  • ethstaker
  • osvaldo12
  • normalnudes
  • tacticalgear
  • cisconetworking
  • cubers
  • Durango
  • Leos
  • anitta
  • tester
  • megavids
  • provamag3
  • lostlight
  • All magazines