Inconsistent Indentation
debt(d3/e1/b3/t5)
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.
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.
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.
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.
Also Known As
TL;DR
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
Why It Matters
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
<?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;
}
// .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;
}