Missing Class Comments
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
{
// ...
}
Tags
🤝 Adopt this term
£79/year · your link shown here
Added
16 Mar 2026
Edited
22 Mar 2026
Views
21
🤖 AI Guestbook educational data only
|
|
Last 30 days
Agents 0
No pings yet today
No pings yesterday
Amazonbot 6
Perplexity 5
Unknown AI 3
Google 2
Ahrefs 2
How they use it
crawler 16
crawler_json 1
pre-tracking 1
Related categories
⚡
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