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

Class Naming Convention

Style PHP 5.0+ Beginner
debt(d3/e1/b1/t3)
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 phpcs, phpstan, and phpmd — all standard PHP tools that catch non-PascalCase class names automatically. phpcs with PSR-1 rules is widely used as a default linter in PHP projects, so violations are caught by default tooling rather than requiring a specialist setup.

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 simple rename: OrderProcessor not ProcessOrders. Renaming a class in a modern IDE is a single refactor action. Even if it touches multiple files (PSR-4 filename must match), the change per class is trivial and mechanical.

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

Closest to 'minimal commitment' (b1). This is a style/naming convention scoped to individual class declarations. It doesn't impose architectural weight, doesn't create cross-cutting dependencies, and doesn't slow down future maintainers beyond the one-time effort of learning the convention. It applies widely across contexts but carries no structural load.

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

Closest to 'minor surprise' (t3). The misconception field identifies one notable trap: redundant type suffixes (UserClass, OrderModel) feel like they add clarity but actually add noise. The common_mistakes also include all-caps acronyms (HTMLParser vs HtmlParser) which contradicts common instinct. These are edge-case surprises rather than fundamental behavioral inversions, warranting t3.

About DEBT scoring →

Also Known As

PascalCase class UpperCamelCase class name

TL;DR

PHP classes must use PascalCase (UpperCamelCase) per PSR-1 — each word capitalised, no underscores, descriptive nouns or noun phrases.

Explanation

PSR-1 mandates PascalCase for class names. Good class names are: specific (UserRepository not DataManager), nouns or noun phrases (Order, EmailService, InvoicePdfGenerator), and consistent with domain language. Avoid generic names (Manager, Handler, Helper, Processor) — they signal low cohesion. Abstract classes and interfaces have no required prefix/suffix in PSR standards but many teams use Interface suffix or I prefix for interfaces, Abstract prefix for abstract classes.

Common Misconception

Suffixing every class with its type (UserClass, OrderModel, PaymentInterface) makes code clearer — the namespace provides context; User and Order are clearer than UserClass and OrderModel.

Why It Matters

Consistent naming conventions allow developers to infer class purpose and type from the name alone, reducing the cognitive load of navigating an unfamiliar codebase.

Common Mistakes

  • snake_case or camelCase class names: user_service, userService — must be UserService.
  • All-caps acronyms: HTMLParser — prefer HtmlParser (only first letter capped).
  • Generic names: DataManager, BaseHelper — be specific about what the class does.
  • Class name not matching filename — PSR-4 requires App\User to be in App/User.php.

Code Examples

✗ Vulnerable
// Wrong naming:
class user_repository { }    // snake_case — wrong
class userService { }        // camelCase — wrong
class PAYMENTGATEWAY { }     // ALL_CAPS — wrong
class data_manager { }       // Generic + snake_case
class HTMLrenderer { }       // Inconsistent acronym caps
✓ Fixed
// Correct PascalCase, specific names:
class UserRepository { }     // PascalCase, specific
class PaymentGateway { }     // PascalCase, domain term
class HtmlRenderer { }       // Acronym: only first letter capped
class InvoicePdfGenerator { } // Multi-word, clear purpose
class OrderNotFoundException extends RuntimeException { }

Added 16 Mar 2026
Edited 22 Mar 2026
Views 46
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 1 ping W 2 pings T 0 pings F 0 pings S 2 pings S 0 pings M 0 pings T 0 pings W 1 ping T 0 pings F 2 pings S 0 pings S 0 pings M 1 ping T 0 pings 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 1 ping S 0 pings M 1 ping T 0 pings W
No pings yet today
PetalBot 1
Amazonbot 10 Perplexity 6 Ahrefs 4 Scrapy 3 Google 2 Unknown AI 2 SEMrush 2 Claude 1 Meta AI 1 Bing 1 Yandex 1 PetalBot 1
crawler 33 crawler_json 1
DEV INTEL Tools & Severity
🟢 Low ⚙ Fix effort: Low
⚡ Quick Fix
Use PascalCase nouns for classes: OrderProcessor not ProcessOrders; suffix with role when ambiguous: UserRepository, OrderFactory, PaymentService
📦 Applies To
PHP 5.0+ web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
Class names with verb prefixes ProcessOrder; abbreviations UsrMgr; non-PascalCase; generic suffixes Manager Helper Util with 10+ unrelated methods
Auto-detectable: ✓ Yes phpcs phpstan phpmd
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Low ✓ Auto-fixable Fix: Low Context: File


✓ schema.org compliant