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

Missing Function 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, phpstan, and phpmd — all standard PHP toolchain tools that catch missing docblocks and undocumented @throws by default or with minimal configuration. The pattern is detectable automatically, matching d3.

e1 Effort Remediation debt — work required to fix once spotted

Closest to 'one-line patch or single-call swap' (e1). The quick_fix is to add a PHPDoc comment above the method — a localised, minimal change that doesn't require refactoring logic or touching other files. Even adding multiple @throws lines is still a contained, single-location fix.

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

Closest to 'localised tax' (b3). Missing documentation affects the component or class where it appears; it doesn't impose a cross-cutting architectural burden. Applies across web/cli/queue contexts but each instance is isolated — the debt is a local productivity tax on maintainers reading or calling undocumented methods, not a system-shaping choice.

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 that developers believe PHP 8 native type declarations make PHPDoc obsolete, but @throws, complex generics like array<string, User>, and explanatory summaries cannot be expressed with native types alone. This is a well-known but commonly encountered mistake, fitting t5.

About DEBT scoring →

Also Known As

missing PHPDoc method undocumented function no method comment

TL;DR

Functions without PHPDoc lose IDE parameter hints, inline documentation, and the opportunity to explain non-obvious behaviour, preconditions, and edge cases.

Explanation

In PHP 8 with full native type declarations, @param and @return are often redundant — the types speak for themselves. What is never redundant: a one-line summary of what the function does, @throws documentation for every exception that can propagate out, @deprecated for functions being phased out, and explanatory notes for any non-obvious preconditions or side effects. PHPStan and Psalm use PHPDoc for complex generics and templates that native types cannot express.

Common Misconception

Native PHP 8 type declarations make PHPDoc obsolete — @throws, complex generics (array<string, User>), and explanatory summaries cannot be expressed with native types alone.

Why It Matters

Missing @throws documentation means callers do not know they must handle an exception — undocumented exceptions cause unhandled exception crashes in production.

Common Mistakes

  • Omitting @throws for every exception that can escape the function.
  • Repeating the method name as the docblock: /** getUserById */ — adds nothing.
  • Not documenting preconditions: the caller must ensure X before calling this.
  • Outdated docblocks after parameter types changed — wrong documentation is worse than none.

Code Examples

✗ Vulnerable
// No docblock — what does it throw? What are the constraints?
public function transfer(int $fromId, int $toId, float $amount)
{
    if ($amount <= 0) throw new InvalidArgumentException('Amount must be positive');
    // Can throw DatabaseException, InsufficientFundsException...
    $this->db->beginTransaction();
    // ...
}
✓ Fixed
/**
 * Transfers funds between two accounts atomically.
 *
 * @param int   $fromId Source account ID
 * @param int   $toId   Destination account ID
 * @param float $amount Positive amount in account currency
 *
 * @throws InvalidArgumentException  If amount is not positive
 * @throws InsufficientFundsException If source balance is insufficient
 * @throws DatabaseException          On transaction failure (rolled back)
 */
public function transfer(int $fromId, int $toId, float $amount): void

Added 16 Mar 2026
Edited 22 Mar 2026
Views 47
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 1 ping W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 1 ping T 0 pings F 1 ping S 1 ping S 2 pings M 1 ping T 0 pings W 1 ping T 0 pings F 1 ping 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 1 ping M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Amazonbot 10 Perplexity 4 Google 4 Ahrefs 4 Scrapy 4 SEMrush 3 Claude 2 Bing 1 Meta AI 1 Majestic 1 Yandex 1 PetalBot 1
crawler 33 crawler_json 3
DEV INTEL Tools & Severity
🟢 Low ⚙ Fix effort: Low
⚡ Quick Fix
Add PHPDoc only when the method signature doesn't tell the whole story — complex @param types, @throws, or a non-obvious @return are valuable; don't duplicate what type declarations already express
📦 Applies To
PHP 5.0+ web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
Public method with complex array shape return type undocumented; @throws not documented; method with non-obvious side effects undocumented
Auto-detectable: ✓ Yes phpcs phpstan phpmd
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Medium ✗ Manual fix Fix: Low Context: Function


✓ schema.org compliant