Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable all options on trailing_comma_in_multiline #18

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"homepage": "https://github.com/realodix/relax",
"require": {
"php": "^7.4 || ^8.0",
"friendsofphp/php-cs-fixer": "^3.61",
"friendsofphp/php-cs-fixer": "^3.63",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.21",
"symfony/console": "^5.4.41 || ^6.0 || ^7.0"
},
Expand Down
3 changes: 1 addition & 2 deletions src/RuleSet/Sets/Relax.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public function mainRules(): array
'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['class', 'function', 'const']],
'single_import_per_statement' => ['group_to_single_imports' => false],
'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
// TODO: Add 'match' & 'parameters' when PHP 8.0+ is required
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments']],
'trailing_comma_in_multiline' => ['elements' => ['arguments', 'array_destructuring', 'arrays', 'match', 'parameters']],
'unary_operator_spaces' => ['only_dec_inc' => true],
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
'phpdoc_align' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Ruleset/realodixspec_expected.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RealodixSpec
public function __construct(
public int $a,
public ?int $b = 3600, // 1 hour...
public string $c = 'Hello World!'
public string $c = 'Hello World!',
) {}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Ruleset/relax-commonbox_expected.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function getBar()
class SingleLineEmptyBody
{
public function __construct(
int $ruleSet
int $ruleSet,
) {}

public function basic__single_line_empty_body() {}
Expand Down
7 changes: 7 additions & 0 deletions tests/Fixtures/Ruleset/relax_actual.php
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,13 @@ public function control_structure__trailing_comma_in_multiline()
2
];

// array_destructuring
$a = [11, 2, 3];
[
$c,
$d
] = $a;

// arguments
foo(
1,
Expand Down
13 changes: 10 additions & 3 deletions tests/Fixtures/Ruleset/relax_expected.php
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,13 @@ public function control_structure__trailing_comma_in_multiline()
2,
];

// array_destructuring
$a = [11, 2, 3];
[
$c,
$d,
] = $a;

// arguments
foo(
1,
Expand All @@ -775,13 +782,13 @@ public function control_structure__trailing_comma_in_multiline()
// parameters
function foo_trailing_comma_in_multiline(
$x,
$y
$y,
) {}

// match
match (true) {
1 => '1',
2 => '2'
2 => '2',
};

// after_heredoc in array
Expand Down Expand Up @@ -821,7 +828,7 @@ function om_ensure_fully_multiline($a = 10,
function om_ensure_single_line(
$a = 10,
$b = 20,
$c = 30
$c = 30,
) {}
sample(
1,
Expand Down
Loading