Skip to content

Commit

Permalink
styles: Enable PHP-CS-Fixer array_indentation rule (#1936)
Browse files Browse the repository at this point in the history
* styles: Enable PHP-CS-Fixer array_indentation rule

Related to #1929. This rule required more manual fixing.

* manual fix

* more fix
  • Loading branch information
theofidry committed Mar 19, 2024
1 parent 8c9cc85 commit e4dcc84
Show file tree
Hide file tree
Showing 27 changed files with 227 additions and 354 deletions.
47 changes: 23 additions & 24 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,30 @@
'@PHPUnit75Migration:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
// TODO: enable
'array_indentation' => false,
'array_indentation' => true,
'blank_line_before_statement' => false,
// TODO: enable back
// 'blank_line_before_statement' => [
// 'statements' => [
// 'break',
// 'continue',
// 'declare',
// 'do',
// 'for',
// 'foreach',
// 'if',
// 'include',
// 'include_once',
// 'require',
// 'require_once',
// 'return',
// 'switch',
// 'throw',
// 'try',
// 'while',
// 'yield',
// ],
// ],
// TODO: enable back
// 'blank_line_before_statement' => [
// 'statements' => [
// 'break',
// 'continue',
// 'declare',
// 'do',
// 'for',
// 'foreach',
// 'if',
// 'include',
// 'include_once',
// 'require',
// 'require_once',
// 'return',
// 'switch',
// 'throw',
// 'try',
// 'while',
// 'yield',
// ],
// ],
'blank_line_between_import_groups' => false,
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
Expand Down
2 changes: 1 addition & 1 deletion src/Differ/DiffSourceCodeMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
final class DiffSourceCodeMatcher
{
private const POSSIBLE_DELIMITERS = [
'#', '%', ':', ';', '=', '?', '@', '^', '~',
'#', '%', ':', ';', '=', '?', '@', '^', '~',
];

public function matches(string $diff, string $sourceCodeRegex): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Logger/GitHubAnnotationsLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getLogLines(): array
{$escapedExecutionResult->getMutantDiff()}
TEXT
,
,
];
$lines[] = $this->buildAnnotation(
Expand Down
2 changes: 1 addition & 1 deletion src/Logger/GitLabCodeQualityLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getLogLines(): array
'location' => [
'path' => Path::makeRelative($escapedExecutionResult->getOriginalFilePath(), $projectRootDirectory),
'lines' => [
'begin' => $escapedExecutionResult->getOriginalStartingLine(),
'begin' => $escapedExecutionResult->getOriginalStartingLine(),
],
],
'severity' => 'major',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public static function codeProvider(): iterable
echo basename('/etc/sudoers.d', '.d');
PHP
,
false, // Cannot detect this one since the call is not fully-qualified and there is no
// use statements - too tricky to detect
false, // Cannot detect this one since the call is not fully-qualified and there is no use statements - too tricky to detect
];

yield 'core function - use statement' => [
Expand Down
30 changes: 11 additions & 19 deletions tests/phpunit/Differ/DiffSourceCodeMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public static function diffRegexProvider(): Generator
return 'string';
}
}
DIFF
,
DIFF,
true,
];

Expand All @@ -95,8 +94,7 @@ public function hello() : string
return 'hello';
}
public function getString()
DIFF
,
DIFF,
true,
];

Expand All @@ -114,8 +112,7 @@ class SourceClass
{
Assert::numeric('1');
$this->getString();
DIFF
,
DIFF,
false,
];

Expand All @@ -133,8 +130,7 @@ public function hello() : string
return 'hello';
}
public function getString()
DIFF
,
DIFF,
true,
];

Expand All @@ -152,8 +148,7 @@ public function hello() : string
$this->getString();
return 'hello';
}
DIFF
,
DIFF,
true,
];

Expand All @@ -165,8 +160,7 @@ public function hello() : string
@@ @@
+ $a - 2 + $this->getString();
DIFF
,
DIFF,
false,
];

Expand All @@ -179,23 +173,21 @@ public function hello() : string
- $a - 2 + $this->getString() / 2; # comment
+ $a - 2 + $this->getString(); # comment
DIFF
,
true,
DIFF,
true,
];

yield 'Regex containing less common delimiters should not lead to syntax error' => [
'.*%.*',
<<<'DIFF'
<<<'DIFF'
--- Original
+++ New
@@ @@
- $a % 2;
+ $a % 3;
DIFF
,
true,
DIFF,
true,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public function test_it_sets_test_framework_version_as_unknown_in_case_of_except
$output->expects($this->once())
->method('writeln')
->with([
'',
'Running initial test suite...',
'',
'PHPUnit version: unknown',
'',
]);
'',
'Running initial test suite...',
'',
'PHPUnit version: unknown',
'',
]);
$output->method('getVerbosity')
->willReturn(OutputInterface::VERBOSITY_QUIET);

Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/Logger/GitLabCodeQualityLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static function metricsProvider(): iterable
'location' => [
'path' => 'foo/bar',
'lines' => [
'begin' => 9,
'begin' => 9,
],
],
'severity' => 'major',
Expand All @@ -100,7 +100,7 @@ public static function metricsProvider(): iterable
'location' => [
'path' => 'foo/bar',
'lines' => [
'begin' => 10,
'begin' => 10,
],
],
'severity' => 'major',
Expand All @@ -121,7 +121,7 @@ public static function metricsProvider(): iterable
'location' => [
'path' => 'foo/bar',
'lines' => [
'begin' => 10,
'begin' => 10,
],
],
'severity' => 'major',
Expand Down
6 changes: 4 additions & 2 deletions tests/phpunit/Metrics/TargetDetectionStatusesProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public function test_it_ignores_some_statuses_when_debugging_is_not_enabled_for_

$provider = new TargetDetectionStatusesProvider($logs, LogVerbosity::NORMAL, false, false);

$this->assertProvidesExcluding([
$this->assertProvidesExcluding(
[
DetectionStatus::KILLED,
DetectionStatus::ERROR,
],
Expand All @@ -119,7 +120,8 @@ public function test_it_ignores_more_statuses_when_running_in_only_covered_mode_

$provider = new TargetDetectionStatusesProvider($logs, LogVerbosity::NORMAL, true, false);

$this->assertProvidesExcluding([
$this->assertProvidesExcluding(
[
DetectionStatus::KILLED,
DetectionStatus::ERROR,
DetectionStatus::NOT_COVERED,
Expand Down
9 changes: 4 additions & 5 deletions tests/phpunit/Mutator/Arithmetic/DivisionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,20 @@ public function test_it_can_mutate(string $input, $expected = []): void
public static function mutationsProvider(): iterable
{
yield 'It changes regular divison' => [
<<<'PHP'
<<<'PHP'
<?php
$a = 10 / 2;
PHP
,
<<<'PHP'
PHP,
<<<'PHP'
<?php
$a = 10 * 2;
PHP,
];

yield 'It does not change division equals' => [
<<<'PHP'
<<<'PHP'
<?php
$a = 10;
Expand Down
9 changes: 4 additions & 5 deletions tests/phpunit/Mutator/Arithmetic/MultiplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,20 @@ public function test_it_can_mutate(string $input, $expected = []): void
public static function mutationsProvider(): iterable
{
yield 'It mutates normal multiplication' => [
<<<'PHP'
<<<'PHP'
<?php
$a = 10 * 3;
PHP
,
<<<'PHP'
PHP,
<<<'PHP'
<?php
$a = 10 / 3;
PHP,
];

yield 'It does not mutate multiplication equals' => [
<<<'PHP'
<<<'PHP'
<?php
$a = 1;
Expand Down
Loading

0 comments on commit e4dcc84

Please sign in to comment.