Mixed Indentation
debt(d3/e1/b3/t5)
Closest to 'default linter catches the common case' (d3). The term's detection_hints.tools list includes php-cs-fixer, phpcs, and editorconfig — all standard, commonly configured tools in PHP projects that catch mixed indentation automatically. It doesn't require a specialist tool; any baseline linter setup catches it.
Closest to 'one-line patch or single-call swap' (e1). The quick_fix explicitly states running php-cs-fixer with the indentation_type fixer converts everything in one shot, plus adding .editorconfig to prevent recurrence. This is a single automated command, not a manual refactor.
Closest to 'localised tax' (b3). Mixed indentation imposes a persistent but contained tax: it creates diff noise and editor misalignment across the team, but it doesn't shape architecture or cross-cut business logic. The applies_to covers all contexts (web, cli, queue-worker), giving it slightly wider reach than a single-component issue, but the impact is purely presentational/tooling, not structural.
Closest to 'notable trap' (t5). The misconception field explicitly states that developers believe 'tabs vs spaces is purely a style debate with no technical consequence,' when it actually causes diff noise, editor misalignment, and parse errors in Python/YAML. This is a documented, well-known gotcha that many developers learn the hard way — a t5 notable trap rather than a catastrophic one since the consequences are usually visible once tools are configured.
Also Known As
TL;DR
Explanation
Mixing tabs and spaces is the most common cause of "works on my machine" formatting bugs. Different editors and tools render tabs as different widths (2, 4, or 8 spaces), making mixed files appear correctly in one editor and badly indented in another. PHP-FIG PSR-12 mandates 4-space indentation with no tabs. Most editors can be configured to insert spaces on Tab keypress; php-cs-fixer and phpcs can auto-fix mixed indentation.
Common Misconception
Why It Matters
Common Mistakes
- Copying code from the web that uses different indentation than your project.
- IDE auto-format that mixes tabs and spaces on different lines.
- Not having .editorconfig or a linter enforcing consistent indentation.
- Not converting all tabs to spaces (or vice versa) when inheriting legacy code.
Code Examples
function calculate($a, $b) {
$result = $a + $b; // spaces
$result *= 2; // tab — mixed!
return $result; // spaces again
// Looks fine in one editor, broken in another
}
// PSR-12 mandates 4 spaces — never tabs, never mixed
// .editorconfig (applies to all editors in the project):
[*.php]
indent_style = space
indent_size = 4
// Auto-fix mixed indentation:
$ vendor/bin/phpcbf --standard=PSR12 src/
// phpcs to detect:
$ vendor/bin/phpcs --standard=PSR12 src/
// Example — correct:
class OrderService {
public function place(Order \$order): Invoice {
\$total = \$order->calculateTotal();
return new Invoice(\$total);
}
}