Naming Conventions
debt(d3/e1/b5/t3)
Closest to 'default linter catches the common case' (d3). The detection_hints list phpcs, phpstan, and phpmd — all standard PHP tooling that catches naming violations automatically. phpcs in particular enforces PSR-1/PSR-12 naming rules out of the box, making this a default-linter-level catch.
Closest to 'one-line patch or single-call swap' (e1). The quick_fix is a direct prescription: enforce phpcs with PSR-1/PSR-12 rules and rename symbols according to convention. Individual violations are single-symbol renames; a codebase-wide rollout is a mechanical find-and-replace that tooling can automate.
Closest to 'persistent productivity tax' (b5). Naming conventions apply across web, cli, and queue-worker contexts (all PHP contexts per applies_to), and inconsistency slows down every developer reading unfamiliar code. However, once a consistent standard is adopted and enforced by phpcs, the ongoing burden is moderate rather than gravitational — it doesn't shape architecture, just readability across many work streams.
Closest to 'minor surprise (one edge case)' (t3). The misconception field identifies the trap: developers believe internal consistency is sufficient, not realising PSR conventions are required for third-party tooling and framework integration. This is a real gotcha but not a deep contradiction — it's a 'good enough is not enough' surprise rather than a behavioural inversion.
Also Known As
TL;DR
Explanation
PHP PSR-1 and PSR-12 conventions: class names in PascalCase (UserRepository), methods and properties in camelCase (getUserById), constants in UPPER_SNAKE_CASE (MAX_RETRIES), and variables in camelCase ($userId). Namespace names in PascalCase matching directory structure. Good names reveal intent: $elapsedTimeInDays is better than $d. Avoid abbreviations, type prefixes (Hungarian notation), and single-letter variables outside tight loops. Consistency within a codebase matters more than any single convention — pick one and enforce it with tools.
Common Misconception
Why It Matters
Common Mistakes
- Class names in snake_case instead of PascalCase — violates PSR and PHP community standard.
- Constants in camelCase instead of UPPER_SNAKE_CASE — indistinguishable from variables at a glance.
- Boolean variables without is/has/can prefix — $active could be a user object or a boolean.
- Abbreviations that are not universally understood: $usrMgr, $cfg, $rsp — spell things out.
Code Examples
// PHP naming violations:
$UserName = 'Alice'; // PascalCase variable — looks like a class
function Get_User() {} // Mixed conventions
const maxRetries = 3; // camelCase constant — should be MAX_RETRIES
class user_repository {} // snake_case class — should be UserRepository
$active = getUser(); // $active sounds boolean but holds an object
// PHP naming conventions (PSR-1 / community standard)
class OrderProcessor {} // PascalCase
public function processOrder(): void {} // camelCase method
const MAX_RETRY_ATTEMPTS = 3; // UPPER_SNAKE_CASE constant
$orderId = 42; // camelCase variable
// Boolean names should read as questions
public bool $isActive;
public bool $hasDiscount;
public bool $canRefund;
// Collections are plural
public array $orders;
// Avoid abbreviations that save 2 keystrokes but cost readability
// Bad: $usrCnt Good: $userCount