Skip to content

Commit

Permalink
Feat: Add ArrayIndentationFixer (part of #94)
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed May 6, 2024
1 parent 2861158 commit f8d2e2d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use PhpCsFixer\Fixer\Strict\StrictParamFixer;
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer;
use PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer;
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
use PhpCsFixer\Fixer\Whitespace\CompactNullableTypeDeclarationFixer;
use PhpCsFixer\Fixer\Whitespace\HeredocIndentationFixer;
Expand Down Expand Up @@ -382,6 +383,8 @@
StrictParamFixer::class,
// Convert double quotes to single quotes for simple strings
SingleQuoteFixer::class,
// Each element of an array must be indented exactly once.
ArrayIndentationFixer::class,
// Remove extra spaces in a nullable typehint
CompactNullableTypeDeclarationFixer::class,
// Heredoc/nowdoc content must be properly indented.
Expand Down
8 changes: 7 additions & 1 deletion tests/Integration/Fixtures/Basic.correct.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,18 @@ class Basic
$singleLineArray = ['foo', 'bar', 'baz'];
$singleLineArray2 = [1, 2, 3];

$multiLineAssociative = [
$multiLineAssociative1 = [
'foo' => 'bar',
'baz' => 'bat',
];

$multiLineAssociative2 = [
'foo' => 'bar',
'baz' => 'bat',
'bak' => 'baz',
];

$multiLineAssociative3 = [
'firstKey' => 'bar',
'thisIsSecondKey' => 'bat',
'third' => 'bat',
Expand Down
11 changes: 8 additions & 3 deletions tests/Integration/Fixtures/Basic.wrong.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ class Basic
$singleLineArray = ['foo', 'bar', 'baz',];
$singleLineArray2 = [1,2,3];

$multiLineAssociative = [
'foo'=>'bar',
'baz'=>'bat'
$multiLineAssociative1 = [
'foo' => 'bar', 'baz' => 'bat',
];

$multiLineAssociative2 = [
'foo'=>'bar',
'baz'=>'bat',
'bak'=>'baz'
];

$multiLineAssociative3 = [
'firstKey' => 'bar',
'thisIsSecondKey' => 'bat',
'third' => 'bat',
Expand Down

0 comments on commit f8d2e2d

Please sign in to comment.