Skip to content

Commit

Permalink
relaxplus: Add ternary_to_null_coalescing
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Jul 30, 2024
1 parent 8a4b07c commit 9ff7ff8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/RuleSet/Sets/RelaxPlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function mainRules(): array
'numeric_literal_separator' => ['override_existing' => true],
'php_unit_fqcn_annotation' => true,
'string_implicit_backslashes' => true,
'ternary_to_null_coalescing' => true,
'general_phpdoc_annotation_remove' => [
'annotations' => [
// https://github.com/doctrine/coding-standard/blob/3e88327/lib/Doctrine/ruleset.xml#L227
Expand Down
8 changes: 8 additions & 0 deletions tests/Fixtures/Ruleset/relaxplus_actual.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ public function control_structure__no_superfluous_elseif()
}
}

public function operator__ternary_to_null_coalescing()
{
$a = true;
$b = true;

$sample = isset($a) ? $a : $b;
}

public function string_notation__explicit_string_variable()
{
$name = 'foo';
Expand Down
8 changes: 8 additions & 0 deletions tests/Fixtures/Ruleset/relaxplus_expected.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ public function control_structure__no_superfluous_elseif()
}
}

public function operator__ternary_to_null_coalescing()
{
$a = true;
$b = true;

$sample = $a ?? $b;
}

public function string_notation__explicit_string_variable()
{
$name = 'foo';
Expand Down

0 comments on commit 9ff7ff8

Please sign in to comment.