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

Inconsistent Indentation

Style 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 term's detection_hints list php-cs-fixer, phpcs, and editorconfig — all standard, widely-adopted tools in the PHP ecosystem that catch mixed indentation automatically. The metadata also marks automated detection as 'yes', confirming this is a routine linter-level catch rather than requiring specialist SAST or manual review.

e1 Effort Remediation debt — work required to fix once spotted

Closest to 'one-line patch or single-call swap' (e1). The quick_fix states: 'Standardise on 4 spaces (PSR-12) and enforce with php-cs-fixer and .editorconfig'. Running php-cs-fixer fix is a single command that reformats the entire codebase automatically, and adding .editorconfig is a one-file addition. No logic changes are required.

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

Closest to 'localised tax' (b3). The applies_to covers web, cli, and queue-worker contexts broadly, but the burden is administrative rather than architectural — it affects diff noise and editor configuration rather than shaping system design. Once enforced via tooling, the ongoing tax is minimal and contained to onboarding and editor setup.

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 explicitly identifies the trap: developers believe tabs are better because they are configurable, but that configurability is itself the problem — code looks different across editors, breaking visual alignment. This is a well-known gotcha that surprises developers once but is easily corrected with tooling.

About DEBT scoring →

Also Known As

mixed tabs spaces indentation tab width

TL;DR

Mixing tabs and spaces, or using varying numbers of spaces for indentation — causes visual misalignment across editors and makes diffs noisy.

Explanation

PSR-1/PSR-12 mandates 4 spaces per indent level, no tabs. Inconsistent indentation typically enters codebases when developers with different editor settings commit without formatting, or when code is pasted from an external source. .editorconfig and PHP-CS-Fixer enforce consistent indentation automatically. Mixed tabs and spaces are the worst offender — the visual appearance depends entirely on the editor's tab-width setting.

Common Misconception

Tabs are better than spaces because they are configurable — configurability is the problem: code with tabs looks different in every editor, breaking visual alignment of code reviewed by a team.

Why It Matters

Mixed indentation turns every line of a reformatted file into a diff change, obscuring the actual logic changes in code review — automated enforcement eliminates this entirely.

Common Mistakes

  • Pasting code from Stack Overflow or documentation that uses 2-space or tab indentation.
  • Editor auto-indent set to tabs in a spaces project.
  • Using 2 spaces for nested closures 'to save horizontal space'.
  • Not having .editorconfig in the repository to enforce consistent settings across all editors.

Code Examples

✗ Vulnerable
<?php
function calculate(int $x): int
{
	$result = 0;        // Tab
    if ($x > 0) {     // 4 spaces
      $result = $x;   // 2 spaces — 3 different styles in 4 lines
    }
    return $result;
}
✓ Fixed
// .editorconfig in project root:
[*.php]
indent_style = space
indent_size = 4

// .php-cs-fixer.dist.php:
'indentation_type' => true,  // Enforces 4-space indentation

<?php
function calculate(int $x): int
{
    $result = 0;
    if ($x > 0) {
        $result = $x;
    }
    return $result;
}

Added 16 Mar 2026
Edited 22 Mar 2026
Views 56
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 0 pings T 0 pings F 0 pings S 0 pings S 1 ping M 3 pings T 0 pings W 0 pings T 1 ping F 0 pings S 0 pings S 1 ping 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 16 Perplexity 8 Ahrefs 4 Google 4 Scrapy 3 Unknown AI 2 Claude 2 Bing 2 SEMrush 2 Majestic 1 Meta AI 1 PetalBot 1
crawler 44 crawler_json 2
DEV INTEL Tools & Severity
🟢 Low ⚙ Fix effort: Low
⚡ Quick Fix
Standardise on 4 spaces (PSR-12) and enforce with php-cs-fixer and .editorconfig — mixed indentation is invisible in some editors and breaks diffs
📦 Applies To
any web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
Mix of tabs and spaces in PHP files; 2-space and 4-space mixed in same project; git diff showing whitespace-only changes
Auto-detectable: ✓ Yes php-cs-fixer phpcs editorconfig
⚠ Related Problems
🤖 AI Agent
Confidence: High False Positives: Low ✓ Auto-fixable Fix: Low Context: File


✓ schema.org compliant