Skip to content

Commit

Permalink
#105 - array no multiline whitespace (#106)
Browse files Browse the repository at this point in the history
* #105 - added array whitespace fixer

* #105 - updated tests
  • Loading branch information
kamilpiech97 authored Nov 15, 2023
1 parent 5059c63 commit 4ca2988
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
"scripts": {
"cs": "./vendor/bin/php-cs-fixer fix --dry-run --diff --config codestyle.php",
"csf": "./vendor/bin/php-cs-fixer fix --diff --config codestyle.php",
"test": "./vendor/bin/phpunit tests --colors always",
"unit": "./vendor/bin/phpunit tests/unit --colors always",
"e2e": "./vendor/bin/phpunit tests/codestyle --colors always"
"test": "./vendor/bin/phpunit tests --colors=always",
"unit": "./vendor/bin/phpunit tests/unit --colors=always",
"e2e": "./vendor/bin/phpunit tests/codestyle --colors=always"
},
"bin": [
"bin/codestyle"
Expand Down
2 changes: 2 additions & 0 deletions src/Configuration/Defaults/CommonRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Blumilk\Codestyle\Fixers\DoubleQuoteFixer;
use Blumilk\Codestyle\Fixers\NoLaravelMigrationsGeneratedCommentFixer;
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer;
use PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer;
use PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer;
use PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer;
Expand Down Expand Up @@ -330,5 +331,6 @@ class CommonRules extends Rules
"anonymous_functions_opening_brace" => "same_line",
],
LowercaseKeywordsFixer::class => true,
NoMultilineWhitespaceAroundDoubleArrowFixer::class => true,
];
}
24 changes: 24 additions & 0 deletions tests/fixtures/noMultilineWhitespaceAroundDoubleArrow/actual.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

class NoMultilineWhitespaceAroundDoubleArrow
{
public function getArray1(): array
{
return [

];
}

public function getArray2(): array
{
return [1

=> 2];
}

public function getClosure(): Closure
{
return fn() =>
[];
}
}
21 changes: 21 additions & 0 deletions tests/fixtures/noMultilineWhitespaceAroundDoubleArrow/expected.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

class NoMultilineWhitespaceAroundDoubleArrow
{
public function getArray1(): array
{
return [];
}

public function getArray2(): array
{
return [1 => 2];
}

public function getClosure(): Closure
{
return fn() => [];
}
}

0 comments on commit 4ca2988

Please sign in to comment.