Skip to content

Commit

Permalink
Update "trailing_comma_in_multiline" to add comma to arguments and pa…
Browse files Browse the repository at this point in the history
…rameters (#21)
  • Loading branch information
kubawerlos authored Nov 25, 2021
1 parent 6b84670 commit 94aa678
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
->files()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->append([__FILE__])
->append([__FILE__]),
);
2 changes: 1 addition & 1 deletion src/Builder/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private function dumpClass(string $name, Rules $rules): void
$content = \str_replace(
\sprintf("'%s'", $rule),
\sprintf('Fixer\\%sFixer::name()', \ucfirst(\str_replace([' ', 'PhpCsFixerCustomFixers/'], '', \ucwords(\str_replace('_', ' ', $rule))))),
$content
$content,
);
}

Expand Down
1 change: 1 addition & 0 deletions src/Builder/Modifier/NonDefaultConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function __invoke(array $rules): array
$rules['no_superfluous_phpdoc_tags'] = ['remove_inheritdoc' => true];
$rules['php_unit_test_case_static_method_calls'] = ['call_type' => 'self'];
$rules['phpdoc_line_span'] = ['property' => 'single'];
$rules['trailing_comma_in_multiline'] = ['after_heredoc' => true, 'elements' => ['arguments', 'arrays', 'parameters']];
$rules['yoda_style'] = ['equal' => false, 'identical' => false, 'less_and_greater' => false];
$rules[NoSuperfluousConcatenationFixer::name()] = ['allow_preventing_trailing_spaces' => true];

Expand Down
11 changes: 9 additions & 2 deletions src/Rules/LibraryRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(string $name, string $author, int $year)
',
$name,
$year,
$author
$author,
));
}

Expand Down Expand Up @@ -323,7 +323,14 @@ public function getRules(): array
'ternary_operator_spaces' => true,
'ternary_to_elvis_operator' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => true,
'trailing_comma_in_multiline' => [
'after_heredoc' => true,
'elements' => [
'arguments',
'arrays',
'parameters',
],
],
'trim_array_spaces' => true,
'types_spaces' => true,
'unary_operator_spaces' => true,
Expand Down
9 changes: 8 additions & 1 deletion src/Rules/ProjectRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,14 @@ public function getRules(): array
'ternary_operator_spaces' => true,
'ternary_to_elvis_operator' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => true,
'trailing_comma_in_multiline' => [
'after_heredoc' => true,
'elements' => [
'arguments',
'arrays',
'parameters',
],
],
'trim_array_spaces' => true,
'types_spaces' => true,
'unary_operator_spaces' => true,
Expand Down
2 changes: 1 addition & 1 deletion tests/AutoReview/SrcCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testOnlyFactoryClassIsPublic(): void
self::assertSame(
$class === Factory::class,
\mb_strpos($reflectionClass->getDocComment(), '@internal') === false,
\sprintf('Class %s has "@internal" tag incorrectly.', $class)
\sprintf('Class %s has "@internal" tag incorrectly.', $class),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Builder/Modifier/NonDefaultConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static function (string $x, string $y): int {
}

return $x <=> $y;
}
},
);

self::assertSame($sortedRules, $rules);
Expand Down
4 changes: 2 additions & 2 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public function testCreateForLibrary(): void
{
self::assertInstanceOf(
Config::class,
Factory::createForLibrary('library name', 'library author', 2000)
Factory::createForLibrary('library name', 'library author', 2000),
);
}

public function testCreateForProject(): void
{
self::assertInstanceOf(
Config::class,
Factory::createForProject()
Factory::createForProject(),
);
}
}
4 changes: 2 additions & 2 deletions tests/Rules/LibraryRulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testRulesAreUpToDate(): void

self::assertSame(
$rules->getRules(),
$libraryRules->getRules()
$libraryRules->getRules(),
);
}

Expand All @@ -63,7 +63,7 @@ public function testRulesBuildInConfig(): void

self::assertInstanceOf(
FixerFactory::class,
$fixerFactory->useRuleSet($ruleSet)
$fixerFactory->useRuleSet($ruleSet),
);
}
}
4 changes: 2 additions & 2 deletions tests/Rules/ProjectRulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testRulesAreUpToDate(): void

self::assertSame(
$rules->getRules(),
$projectRules->getRules()
$projectRules->getRules(),
);
}

Expand All @@ -51,7 +51,7 @@ public function testRulesBuildInConfig(): void

self::assertInstanceOf(
FixerFactory::class,
$fixerFactory->useRuleSet($ruleSet)
$fixerFactory->useRuleSet($ruleSet),
);
}
}

0 comments on commit 94aa678

Please sign in to comment.