← Home ← Codex ← DEBT ← Engine
Browse by Category
+ added · ✎ updated 7d
← Back to glossary

Long Parameter List

Code Quality Beginner
debt(d3/e3/b3/t5)
d3 Detectability Operational debt — how invisible misuse is to your safety net

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.

e3 Effort Remediation debt — work required to fix once spotted

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.

b3 Burden Structural debt — long-term weight of choosing wrong

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.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

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.

About DEBT scoring →

Also Known As

too many parameters parameter list smell excessive parameters

TL;DR

A function or method with too many parameters — typically 4+ — making calls hard to read and easy to get wrong.

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

✗ Adding a parameter object just moves the problem. A parameter object does more than group fields — it gives the grouping a name, a place for related validation, and a stable API surface that can evolve without changing every call site.

Why It Matters

Functions with many parameters are hard to call correctly, impossible to extend without breaking callers, and signal that the function has too many responsibilities.

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

✗ Vulnerable
function createUser(
    string $name, string $email, string $role,
    bool $active, ?string $avatar, int $orgId
): User {}
✓ Fixed
// 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 {}

Added 15 Mar 2026
Edited 22 Mar 2026
Views 175
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 2 pings T 0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 2 pings W 0 pings T 0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 1 ping W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 2 pings S 0 pings S
No pings yet today
SEMrush 1 PetalBot 1
Amazonbot 20 Ahrefs 19 PetalBot 15 SEMrush 14 Perplexity 9 Scrapy 6 Google 4 Bing 4 ChatGPT 3 Unknown AI 2 Claude 2 Twitter/X 2 Applebot 2 Majestic 1 Meta AI 1 Qwen 1 Brave Search 1
crawler 103 crawler_json 3
⚡ DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Group related parameters into a Parameter Object — function createUser(string $name, string $email, string $country, string $timezone) becomes createUser(UserRegistration $data)
📦 Applies To
any web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
Function with 5+ parameters; many optional parameters; caller code hard to read because of many positional arguments
Auto-detectable: ✓ Yes phpmd phpcs phpstan
⚠ Related Problems
🤖 AI Agent
Confidence: High False Positives: Low ✗ Manual fix Fix: Medium Context: Function Tests: Update


✓ schema.org compliant