Long Parameter List
debt(d3/e3/b3/t5)
Closest to 'default linter catches the common case' (d3). The detection_hints list phpmd, phpcs, and phpstan — all standard PHP static analysis tools that are commonly included in default or near-default configurations and will flag functions with 5+ parameters automatically.
Closest to 'simple parameterised fix (replace pattern with safer alternative)' (e3). The quick_fix describes introducing a Parameter Object — a small, contained refactor that replaces multiple parameters with a typed class. This touches the function signature and all direct call sites but is a well-understood, mechanical transformation within one component rather than a cross-cutting architectural change.
Closest to 'localised tax' (b3). Long parameter lists impose a productivity tax primarily on the component or module where they appear — callers of that function are harder to write and read, and extension is painful, but the structural weight doesn't necessarily propagate across the whole codebase unless the affected function is a heavily shared utility.
Closest to 'notable trap (a documented gotcha most devs eventually learn)' (t5). The misconception field explicitly states that developers believe 'adding a parameter object just moves the problem,' failing to appreciate that a Parameter Object provides naming, encapsulated validation, and a stable API surface. This is a well-documented gotcha that competent developers often get wrong once before learning the distinction.
Also Known As
TL;DR
Explanation
Long parameter lists are fragile: callers must remember the order of arguments, optional parameters with defaults spread throughout are easy to mis-specify, and adding a new parameter breaks every call site. The common refactoring is to introduce a Parameter Object — a simple class or readonly struct that groups related parameters — so the method signature becomes function process(OrderData $order) instead of function process($id, $name, $qty, $price, $discount, $tax).
Common Misconception
Why It Matters
Common Mistakes
- Adding a new optional parameter every time behaviour needs to vary — use a parameter object or strategy instead.
- Boolean flag parameters that control internal branching — split into two separate functions.
- Not using constructor promotion for objects that are just bundles of related parameters.
- Accepting an array of 'options' instead of a typed parameter object — loses type safety and discoverability.
Code Examples
function createUser(
string $name, string $email, string $role,
bool $active, ?string $avatar, int $orgId
): User {}
// Introduce a parameter object
class CreateUserRequest {
public function __construct(
public readonly string $name,
public readonly string $email,
public readonly string $role = 'member',
public readonly bool $active = true,
public readonly ?string $avatar = null,
public readonly int $orgId = 0,
) {}
}
function createUser(CreateUserRequest $req): User {}