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

Function & Method Naming Convention

Style Beginner
debt(d3/e1/b3/t3)
d3 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'default linter catches the common case' (d3). The term's detection_hints list phpcs, phpmd, and phpstan — phpcs with PSR-1/PSR-2 rulesets will flag snake_case methods and missing verb prefixes as a default check, catching the most common naming violations automatically without specialist configuration.

e1 Effort Remediation debt — work required to fix once spotted

Closest to 'one-line patch or single-call swap' (e1). The quick_fix is a direct rename — e.g. rename get_user_by_id() to getUserById() or active() to isActive(). Each fix is a single rename operation per function, with IDE refactor tools making it a trivial one-step correction.

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

Closest to 'localised tax' (b3). Naming conventions apply across web, cli, and queue-worker contexts, so poor naming persists wherever those functions are called, but the debt is readable rather than structural — it slows comprehension locally without reshaping architecture. Each badly-named method is a small recurring tax rather than a gravitational force.

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

Closest to 'minor surprise' (t3). The misconception is that short names save typing (getUsrEmail vs getUserEmailAddress), which is a common but mild misunderstanding rather than a catastrophic gotcha. The snake_case vs camelCase confusion is also a one-time surprise for developers coming from Python/Ruby, but it's well-documented and quickly corrected.

About DEBT scoring →

Also Known As

camelCase method method naming function name

TL;DR

PHP functions and methods use camelCase per PSR-1 — lowercase first word, each subsequent word capitalised, verb-noun pairs for actions.

Explanation

PSR-1 mandates camelCase for method names. Effective method names follow verb-noun patterns: getUser(), saveOrder(), isActive(), hasPermission(). Boolean methods use is/has/can/should prefix. Getters use get prefix; setters use set. Factory methods use make/create/build. PHPUnit test methods use test prefix (testUserCanLogin) or @test annotation. Avoid abbreviations (getUsrNm → getUserName) and avoid generic names (process, handle, run — what does it do?).

Common Misconception

Short method names are better because they save typing — method names are read far more often than they are typed; getUserEmailAddress() is always clearer than getUsrEmail().

Why It Matters

Well-named methods make code readable without needing comments — findActiveUsersByRole() explains exactly what happens; process() explains nothing.

Common Mistakes

  • snake_case methods: get_user_by_id() — PHP is camelCase for methods.
  • No verb prefix: user() instead of getUser() or findUser().
  • Boolean methods without is/has/can: active() instead of isActive().
  • Overly abbreviated names: getUsrNm() — spell it out: getUserName().

Code Examples

✗ Vulnerable
// Wrong conventions:
class UserService {
    public function get_user(int $id) { }   // snake_case
    public function User(int $id) { }       // Uppercase, no verb
    public function active(): bool { }      // No is/has/can prefix
    public function DoSomething() { }       // Uppercase verb, vague
    public function proc(array $d) { }     // Abbreviations
}
✓ Fixed
// PSR-1 camelCase with clear verb-noun:
class UserService {
    public function findById(int $id): ?User { }
    public function isActive(User $user): bool { }
    public function canDelete(User $user, Resource $r): bool { }
    public function createFromRequest(Request $r): User { }
    public function updateEmailAddress(User $u, string $email): void { }
}

Added 16 Mar 2026
Edited 22 Mar 2026
Views 49
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings 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 0 pings F 4 pings S 0 pings S 1 ping M 0 pings T 1 ping W 0 pings T 0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 3 pings T 0 pings W
No pings yet today
PetalBot 2 Google 1
Amazonbot 7 Perplexity 6 Ahrefs 4 Google 4 Scrapy 4 Unknown AI 2 Claude 2 Bing 2 PetalBot 2 Meta AI 1 Yandex 1
crawler 32 crawler_json 3
DEV INTEL Tools & Severity
🟢 Low ⚙ Fix effort: Low
⚡ Quick Fix
Name functions with a verb + noun: calculateTax(), sendWelcomeEmail(), validateUserInput() — and be consistent with verb tense: isValid() for boolean checks, getUser() for retrieval, createOrder() for creation
📦 Applies To
any web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
Functions named with nouns: user(), order(); boolean functions without is/has/can prefix; inconsistent tense: get vs fetch vs load
Auto-detectable: ✓ Yes phpcs phpmd phpstan
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Medium ✓ Auto-fixable Fix: Low Context: File


✓ schema.org compliant