Skip to content

Commit f8d2e2d

Browse files
committed
Feat: Add ArrayIndentationFixer (part of #94)
1 parent 2861158 commit f8d2e2d

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

Diff for: ecs.php

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
135135
use PhpCsFixer\Fixer\Strict\StrictParamFixer;
136136
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer;
137+
use PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer;
137138
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
138139
use PhpCsFixer\Fixer\Whitespace\CompactNullableTypeDeclarationFixer;
139140
use PhpCsFixer\Fixer\Whitespace\HeredocIndentationFixer;
@@ -382,6 +383,8 @@
382383
StrictParamFixer::class,
383384
// Convert double quotes to single quotes for simple strings
384385
SingleQuoteFixer::class,
386+
// Each element of an array must be indented exactly once.
387+
ArrayIndentationFixer::class,
385388
// Remove extra spaces in a nullable typehint
386389
CompactNullableTypeDeclarationFixer::class,
387390
// Heredoc/nowdoc content must be properly indented.

Diff for: tests/Integration/Fixtures/Basic.correct.php.inc

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

67-
$multiLineAssociative = [
67+
$multiLineAssociative1 = [
6868
'foo' => 'bar',
6969
'baz' => 'bat',
7070
];
7171

7272
$multiLineAssociative2 = [
73+
'foo' => 'bar',
74+
'baz' => 'bat',
75+
'bak' => 'baz',
76+
];
77+
78+
$multiLineAssociative3 = [
7379
'firstKey' => 'bar',
7480
'thisIsSecondKey' => 'bat',
7581
'third' => 'bat',

Diff for: tests/Integration/Fixtures/Basic.wrong.php.inc

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

64-
$multiLineAssociative = [
65-
'foo'=>'bar',
66-
'baz'=>'bat'
64+
$multiLineAssociative1 = [
65+
'foo' => 'bar', 'baz' => 'bat',
6766
];
6867

6968
$multiLineAssociative2 = [
69+
'foo'=>'bar',
70+
'baz'=>'bat',
71+
'bak'=>'baz'
72+
];
73+
74+
$multiLineAssociative3 = [
7075
'firstKey' => 'bar',
7176
'thisIsSecondKey' => 'bat',
7277
'third' => 'bat',

0 commit comments

Comments
 (0)