Skip to content

Commit

Permalink
relaxplus: Add assign_null_coalescing_to_coalesce_equal
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Jul 30, 2024
1 parent 9ff7ff8 commit 1ad0279
Show file tree
Hide file tree
Showing 3 changed files with 11 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 @@ -25,6 +25,7 @@ public function rules(): array
public function mainRules(): array
{
return [
'assign_null_coalescing_to_coalesce_equal' => true,
'explicit_string_variable' => true,
'no_superfluous_elseif' => true,
'numeric_literal_separator' => ['override_existing' => true],
Expand Down
5 changes: 5 additions & 0 deletions tests/Fixtures/Ruleset/relaxplus_actual.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public function control_structure__no_superfluous_elseif()
}
}

public function operator__assign_null_coalescing_to_coalesce_equal()
{
$foo = $foo ?? 1;
}

public function operator__ternary_to_null_coalescing()
{
$a = true;
Expand Down
5 changes: 5 additions & 0 deletions tests/Fixtures/Ruleset/relaxplus_expected.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public function control_structure__no_superfluous_elseif()
}
}

public function operator__assign_null_coalescing_to_coalesce_equal()
{
$foo ??= 1;
}

public function operator__ternary_to_null_coalescing()
{
$a = true;
Expand Down

0 comments on commit 1ad0279

Please sign in to comment.