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

Missing Class Comments

Style PHP 5.0+ Beginner
debt(d3/e1/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 phpcs, phpmd, and phpstan — all standard PHP tooling that ships with most PHP project setups. phpcs with PSR-12 or a documentation sniff will flag missing class docblocks as part of a routine CI run, placing this squarely at d3.

e1 Effort Remediation debt — work required to fix once spotted

Closest to 'one-line patch or single-call swap' (e1). The quick_fix explicitly says 'Add a one-line PHPDoc comment to public-facing classes.' Writing a brief docblock is a trivial, localised edit requiring no refactoring or cross-file changes.

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

Closest to 'localised tax' (b3). Missing comments impose a cost on the specific class being read — developers must read the full implementation to understand intent — but the rest of the codebase is largely unaffected. It is a persistent but contained friction rather than a systemic architectural weight.

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 states directly: 'Self-documenting class names remove the need for comments — a class name identifies what it is; a docblock explains why it exists and any non-obvious design decisions.' Most developers have held this belief at some point, and the common_mistakes reinforce secondary traps (empty docblocks, restating the class name), making this a well-documented but frequently misunderstood concept.

About DEBT scoring →

Also Known As

missing PHPDoc no class comment undocumented class

TL;DR

A class without a PHPDoc block lacks the docblock description, @package annotation, and context needed for IDE tooling, generated documentation, and new developers.

Explanation

Class-level PHPDoc should describe what the class represents, its responsibilities, and any non-obvious design decisions. At minimum: a one-line summary. For complex classes: a longer description, @see references, usage examples, and @deprecated notices. PHPDoc blocks are parsed by IDE inspectors, phpDocumentor, and static analysers. In PHP 8 with native types, many @param and @return tags are redundant, but class-level descriptions remain valuable.

Common Misconception

Self-documenting class names remove the need for comments — a class name identifies what it is; a docblock explains why it exists and any non-obvious design decisions.

Why It Matters

A class without a docblock makes IDEs show no hover documentation, makes phpDocumentor generate empty pages, and forces new developers to read the entire implementation to understand the class's purpose.

Common Mistakes

  • Empty docblocks with only /** */ and no content — worse than nothing, implies documentation was started and abandoned.
  • Docblocks that restate the class name: /** Class UserRepository */ — add real information.
  • Missing @deprecated tag on classes that should no longer be used.
  • Out-of-date docblocks that describe the old behaviour after refactoring.

Code Examples

✗ Vulnerable
<?php
namespace App\Repository;

// No docblock — IDEs show nothing on hover
class UserRepository
{
    // ...
}

// Or useless docblock:
/**
 * Class UserRepository
 */
class UserRepository { }
✓ Fixed
<?php
namespace App\Repository;

/**
 * Retrieves and persists User aggregates using PDO.
 *
 * All queries use prepared statements. Soft-deleted users
 * are excluded unless withTrashed() is called first.
 *
 * @see User
 */
class UserRepository
{
    // ...
}

Added 16 Mar 2026
Edited 22 Mar 2026
Views 116
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings S 0 pings M 1 ping T 0 pings W 1 ping T 1 ping F 0 pings S 0 pings S 3 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 2 pings S 0 pings M 0 pings T 1 ping W 0 pings T 0 pings F 0 pings S 0 pings S 1 ping M 0 pings T 0 pings W 1 ping T 0 pings F 0 pings S 3 pings S 1 ping M
Amazonbot 1
SEMrush 1 Yandex 1 PetalBot 1
PetalBot 11 Amazonbot 10 Ahrefs 8 Google 7 SEMrush 7 Perplexity 6 ChatGPT 5 Scrapy 5 Unknown AI 4 Claude 3 Yandex 2 Applebot 2 Meta AI 1 Majestic 1 Twitter/X 1 Brave Search 1 Bing 1
crawler 69 crawler_json 5 pre-tracking 1
DEV INTEL Tools & Severity
🟢 Low ⚙ Fix effort: Low
⚡ Quick Fix
Add a one-line PHPDoc comment to public-facing classes describing the responsibility — not what it is (the class name says that) but what problem it solves and what it should NOT be used for
📦 Applies To
PHP 5.0+ web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
Public class without PHPDoc; class whose purpose is unclear from its name alone; infrastructure class with no usage guidance
Auto-detectable: ✓ Yes phpcs phpmd phpstan
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Medium ✗ Manual fix Fix: Low Context: Class


✓ schema.org compliant