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

Lines Too Long

Style Beginner
debt(d1/e1/b1/t3)
d1 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'caught instantly' (d1), because phpcs, php-cs-fixer, and editorconfig (all listed in detection_hints.tools) flag long lines automatically and immediately — detection is fully automated with zero ambiguity.

e1 Effort Remediation debt — work required to fix once spotted

Closest to 'one-line patch or single-call swap' (e1), because the quick_fix states php-cs-fixer's line_length rule enforces it automatically; in the worst case a developer wraps a fluent chain or array literal, which is a trivial local edit with no cross-file impact.

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

Closest to 'minimal commitment' (b1), because this is a pure style/formatting convention scoped to individual lines; it imposes no structural weight on the codebase, no architectural coupling, and no ongoing productivity tax beyond the initial formatter configuration.

t3 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'minor surprise' (t3), because the misconception field identifies one real but mild gotcha — developers assume wide monitors make line limits obsolete — but the concept itself is straightforward and the surprise is limited to that one edge-of-relevance argument rather than a behavioural contradiction.

About DEBT scoring →

Also Known As

long lines line length 120 character limit

TL;DR

Lines exceeding 120 characters force horizontal scrolling and break side-by-side diff views — PSR-12 recommends a soft limit of 120 and hard limit of no limit, but team conventions often enforce 120.

Explanation

Long lines arise from deep nesting, long method chains, or verbose expressions. PSR-2 recommended 80 chars; PSR-12 sets a soft limit of 120 with a hard limit of no restriction. In practice most teams enforce 120-160 chars in PHP-CS-Fixer. Long lines are a symptom of deeper issues: deep nesting (extract methods), long chains (intermediate variables), or large expression trees (decompose). PHP-CS-Fixer cannot auto-break long lines but warns about them.

Common Misconception

Modern monitors are wide so line length limits are obsolete — side-by-side diff, split editor views, and printed code reviews all benefit from lines under 120 characters.

Why It Matters

Long lines break code review tools, make git diffs hard to read, and force horizontal scrolling — consistently short lines improve reviewability across all contexts.

Common Mistakes

  • Fluent chains without line breaks between methods.
  • Long if conditions without parenthetical grouping across multiple lines.
  • Array literals on a single line with many elements.
  • SQL strings on one line — break SQL across multiple lines with a heredoc or concatenation.

Code Examples

✗ Vulnerable
// Single line — hard to read, breaks diffs:
$users = $this->userRepository->findAll()->filter(fn($u) => $u->isActive())->sortBy('name')->take(50)->map(fn($u) => $u->toArray());

if ($user->isAdmin() && $user->hasPermission('write') && $resource->isOwnedBy($user) && !$resource->isLocked()) {
✓ Fixed
// Line breaks at logical points:
$users = $this->userRepository
    ->findAll()
    ->filter(fn($u) => $u->isActive())
    ->sortBy('name')
    ->take(50)
    ->map(fn($u) => $u->toArray());

if (
    $user->isAdmin()
    && $user->hasPermission('write')
    && $resource->isOwnedBy($user)
    && !$resource->isLocked()
) {

Added 16 Mar 2026
Edited 22 Mar 2026
Views 704
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings S 0 pings M 5 pings T 1 ping W 0 pings T 0 pings F 1 ping S 2 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 3 pings T 0 pings F 0 pings S 0 pings S 1 ping M 2 pings T 0 pings W 0 pings T 1 ping F 0 pings S 0 pings S 1 ping M
PetalBot 1
No pings yesterday
Amazonbot 18 Google 16 Perplexity 8 ChatGPT 8 Ahrefs 7 SEMrush 6 PetalBot 6 Majestic 2 Unknown AI 2 Scrapy 2 Applebot 2 Bing 2 Meta AI 1 Yandex 1 Twitter/X 1 Brave Search 1
crawler 80 crawler_json 3
🧱 FUNDAMENTALS — new to this? Start with the ground floor.
Code Formatting style Code formatting is the visual arrangement of your source code—how you use spaces, line breaks, and indentation to make code readable and consistent.

Readable code reduces bugs and speeds up collaboration. As projects grow, consistent formatting prevents style debates and lets teams focus on logic instead of nitpicking spaces.

💡 Enable format-on-save in your editor so every file gets consistent formatting automatically.

Ask Codex about Code Formatting →
DEV INTEL Tools & Severity
🟢 Low ⚙ Fix effort: Low
⚡ Quick Fix
PSR-12 suggests max 120 characters; php-cs-fixer line_length rule enforces it automatically — long lines in PHP are almost always a sign that code should be extracted to a variable or method
📦 Applies To
any web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
Lines >120 characters; chained method calls on one line; deeply nested expressions refusing to wrap
Auto-detectable: ✓ Yes phpcs php-cs-fixer editorconfig
⚠ Related Problems
🤖 AI Agent
Confidence: High False Positives: Low ✓ Auto-fixable Fix: Low Context: Line


✓ schema.org compliant