Oddbean new post about | logout
ā–² ā–¼
 Looking for #PHP feedback.

I have a lib build for PHP 7 that has 3 methods:

addFoo($id, $priority)
addFooBefore($id, $before)
addFooAfter($id, $after)

($before/$after refer to some other $id.)

For PHP 8, I am strongly considering just assuming named args and changing it to:

addFoo($id, $priority, $before, $after);

Specify only one of priority/before/after, by name. Multiple is an error.

Is this a good idea/bad idea, and why? 
 @8bbd5ecb Iā€™m torn on this kind of thing, too, and whenever I encounter this, I wish PHP had overloading, but I think that would cause a whole slew of new problems.