Skip to content

Commit

Permalink
PHP 8.0 | Squiz/ControlSignature: check signature of match expressions
Browse files Browse the repository at this point in the history
This adds support for checking the signature of `match` expressions to this sniff.

Includes unit test.
  • Loading branch information
jrfnl committed Feb 23, 2021
1 parent 8b0137a commit dffc59e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function register()
T_ELSE,
T_ELSEIF,
T_SWITCH,
T_MATCH,
];

}//end register()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ while ( $level-- ):
ob_end_clean();
endwhile;

$r = match ($x) {
1 => 1,
};

$r = match($x){1 => 1};

// Intentional parse error. This should be the last test in the file.
foreach
// Some unrelated comment.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,13 @@ while ( $level-- ):
ob_end_clean();
endwhile;

$r = match ($x) {
1 => 1,
};

$r = match ($x) {
1 => 1};

// Intentional parse error. This should be the last test in the file.
foreach
// Some unrelated comment.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function getErrorList($testFile='ControlSignatureUnitTest.inc')
$errors[276] = 1;
$errors[279] = 1;
$errors[283] = 1;
$errors[306] = 3;
}//end if

return $errors;
Expand Down

0 comments on commit dffc59e

Please sign in to comment.