Excessive Blank Lines
debt(d3/e1/b1/t3)
Closest to 'default linter catches the common case' (d3). The term's detection_hints.tools lists php-cs-fixer, phpcs, and editorconfig — all standard, widely-adopted PHP formatting tools that catch excessive blank lines automatically. These are default-level tools in most PHP projects, not specialist SAST or type-checker tools.
Closest to 'one-line patch or single-call swap' (e1). The quick_fix explicitly says to let php-cs-fixer enforce this automatically — a single formatter invocation or CI configuration step fixes the entire codebase. No manual refactoring required.
Closest to 'minimal commitment' (b1). This is a pure style/formatting concern with no architectural or structural implications. Once a formatter is configured, it imposes zero ongoing cognitive load on maintainers. It does not affect logic, interfaces, or cross-cutting concerns.
Closest to 'minor surprise' (t3). The misconception field states developers believe more blank lines improve readability, when PSR-12 requires exactly one between methods. This is a mild, common misunderstanding — not a deep behavioral gotcha — but it does contradict the intuition that 'more whitespace = more clarity.'
Also Known As
TL;DR
Explanation
PSR-12 allows one blank line between code blocks for visual separation but prohibits multiple consecutive blank lines within a class body or function. Excessive blank lines are usually a sign that a function is too long and should be refactored — the blank lines represent mental paragraph breaks that would be better expressed as separate methods. PHP-CS-Fixer's no_extra_blank_lines rule removes them automatically.
Common Misconception
Why It Matters
Common Mistakes
- Two or more blank lines between methods in a class — PSR-12 requires exactly one.
- Blank lines at the start or end of a function body.
- Using blank lines to compensate for a function that is too long — extract methods instead.
- Inconsistent blank line usage making code look unstructured.
Code Examples
<?php
class UserService
{
private PDO $db;
public function __construct(PDO $db)
{
$this->db = $db;
}
public function find(int $id): ?User
{
$stmt = $this->db->prepare('SELECT * FROM users WHERE id = ?');
$stmt->execute([$id]);
return $stmt->fetchObject(User::class) ?: null;
}
}
<?php
class UserService
{
private PDO $db;
public function __construct(PDO $db)
{
$this->db = $db;
}
public function find(int $id): ?User
{
$stmt = $this->db->prepare('SELECT * FROM users WHERE id = ?');
$stmt->execute([$id]);
return $stmt->fetchObject(User::class) ?: null;
}
}