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 Sep 11, 2022
1 parent 3f126c3 commit 3611637
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 @@ -255,3 +255,24 @@ private string $private,
) {
}
}

$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 @@ -267,3 +267,24 @@ class ConstructorPropertyPromotionMultiLineDocblockAndAttributeIncorrectIndent
) {
}
}

$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,
269 => 1,
272 => 1,
273 => 1,
276 => 1,
277 => 1,
278 => 2,
];
} else {
$errors = [
Expand Down

0 comments on commit 3611637

Please sign in to comment.