PHP function with unlimited number of parameters

后端 未结 8 1712
执念已碎
执念已碎 2020-12-03 13:45

How do I write a function that can accept unlimited number of parameters?

What am trying to do is create a function within a class that wraps the following:

8条回答
  •  無奈伤痛
    2020-12-03 14:21

    At 5 parameters, this design is starting to exhibit the AntiPattern "Too Many Parameters". This suggests the refactoring called Parameter Object, an object or structure with data members representing the arguments to be passed in. However, avoid making it a Magic Container.

    See also Introduce Parameter Object refactoring at refactoring.com.

提交回复
热议问题