Skip to content

Commit 8933c53

Browse files
committed
Feat: Add ArrayIndentationFixer (part of #94)
1 parent 383fcaf commit 8933c53

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

ecs.php

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
use PhpCsFixer\Fixer\Strict\StrictComparisonFixer;
136136
use PhpCsFixer\Fixer\Strict\StrictParamFixer;
137137
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer;
138+
use PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer;
138139
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
139140
use PhpCsFixer\Fixer\Whitespace\CompactNullableTypeDeclarationFixer;
140141
use PhpCsFixer\Fixer\Whitespace\HeredocIndentationFixer;
@@ -385,6 +386,8 @@
385386
StrictComparisonFixer::class,
386387
// Convert double quotes to single quotes for simple strings
387388
SingleQuoteFixer::class,
389+
// Each element of an array must be indented exactly once.
390+
ArrayIndentationFixer::class,
388391
// Remove extra spaces in a nullable typehint
389392
CompactNullableTypeDeclarationFixer::class,
390393
// Heredoc/nowdoc content must be properly indented.

tests/Integration/Fixtures/Basic.correct.php.inc

+7-1
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,18 @@ class Basic
6666
$singleLineArray = ['foo', 'bar', 'baz'];
6767
$singleLineArray2 = [1, 2, 3];
6868

69-
$multiLineAssociative = [
69+
$multiLineAssociative1 = [
7070
'foo' => 'bar',
7171
'baz' => 'bat',
7272
];
7373

7474
$multiLineAssociative2 = [
75+
'foo' => 'bar',
76+
'baz' => 'bat',
77+
'bak' => 'baz',
78+
];
79+
80+
$multiLineAssociative3 = [
7581
'firstKey' => 'bar',
7682
'thisIsSecondKey' => 'bat',
7783
'third' => 'bat',

tests/Integration/Fixtures/Basic.wrong.php.inc

+8-3
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,17 @@ class Basic
6363
$singleLineArray = ['foo', 'bar', 'baz',];
6464
$singleLineArray2 = [1,2,3];
6565

66-
$multiLineAssociative = [
67-
'foo'=>'bar',
68-
'baz'=>'bat'
66+
$multiLineAssociative1 = [
67+
'foo' => 'bar', 'baz' => 'bat',
6968
];
7069

7170
$multiLineAssociative2 = [
71+
'foo'=>'bar',
72+
'baz'=>'bat',
73+
'bak'=>'baz'
74+
];
75+
76+
$multiLineAssociative3 = [
7277
'firstKey' => 'bar',
7378
'thisIsSecondKey' => 'bat',
7479
'third' => 'bat',

0 commit comments

Comments
 (0)