Skip to content

Commit

Permalink
Squiz/MultiLineFunctionDeclaration: add tests for arrow function decl…
Browse files Browse the repository at this point in the history
…arations

The Squiz sniff inherits the change from the `PEAR.Functions.FunctionDeclaration` sniff.

This commit adds tests to document the behaviour and safeguard the inherited change.
  • Loading branch information
jrfnl committed May 4, 2023
1 parent eced441 commit db548df
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,24 @@ new ExceptionMessage(),
) {
}
}

$arrowNoArgs = fn () => $retrievedfromscope;

$arrowSingleLineArgs = fn (Type $param1, int $param2, string $param3): \ReturnType => $retrievedfromscope;

$arrowMultiLineArgs = fn (
$longVar1,
$longerVar2,
&...$muchLongerVar3
) => $longVar1;

$arrowNoArgs = fn( )
=> $retrievedfromscope;

$arrowSingleLineArgs = fn( Type $param1 , int $param2, string $param3
) : \ReturnType => $retrievedfromscope;

$arrowMultiLineArgs = fn (
$longVar1, $longerVar2,

& ... $muchLongerVar3) => $longVar1;
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,24 @@ new ExceptionMessage(),
) {
}
}

$arrowNoArgs = fn () => $retrievedfromscope;

$arrowSingleLineArgs = fn (Type $param1, int $param2, string $param3): \ReturnType => $retrievedfromscope;

$arrowMultiLineArgs = fn (
$longVar1,
$longerVar2,
&...$muchLongerVar3
) => $longVar1;

$arrowNoArgs = fn ( )
=> $retrievedfromscope;

$arrowSingleLineArgs = fn ( Type $param1 , int $param2, string $param3) : \ReturnType => $retrievedfromscope;

$arrowMultiLineArgs = fn (
$longVar1,
$longerVar2,
& ... $muchLongerVar3
) => $longVar1;
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public function getErrorList($testFile='MultiLineFunctionDeclarationUnitTest.inc
252 => 1,
253 => 1,
254 => 1,
316 => 1,
319 => 1,
320 => 1,
323 => 1,
324 => 1,
325 => 2,
];
} else {
$errors = [
Expand Down

0 comments on commit db548df

Please sign in to comment.