Skip to content

Commit 3611637

Browse files
committed
Squiz/MultiLineFunctionDeclaration: add tests for arrow function declarations
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.
1 parent 3f126c3 commit 3611637

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc

+21
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,24 @@ private string $private,
255255
) {
256256
}
257257
}
258+
259+
$arrowNoArgs = fn () => $retrievedfromscope;
260+
261+
$arrowSingleLineArgs = fn (Type $param1, int $param2, string $param3): \ReturnType => $retrievedfromscope;
262+
263+
$arrowMultiLineArgs = fn (
264+
$longVar1,
265+
$longerVar2,
266+
&...$muchLongerVar3
267+
) => $longVar1;
268+
269+
$arrowNoArgs = fn( )
270+
=> $retrievedfromscope;
271+
272+
$arrowSingleLineArgs = fn( Type $param1 , int $param2, string $param3
273+
) : \ReturnType => $retrievedfromscope;
274+
275+
$arrowMultiLineArgs = fn (
276+
$longVar1, $longerVar2,
277+
278+
& ... $muchLongerVar3) => $longVar1;

src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc.fixed

+21
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,24 @@ class ConstructorPropertyPromotionMultiLineDocblockAndAttributeIncorrectIndent
267267
) {
268268
}
269269
}
270+
271+
$arrowNoArgs = fn () => $retrievedfromscope;
272+
273+
$arrowSingleLineArgs = fn (Type $param1, int $param2, string $param3): \ReturnType => $retrievedfromscope;
274+
275+
$arrowMultiLineArgs = fn (
276+
$longVar1,
277+
$longerVar2,
278+
&...$muchLongerVar3
279+
) => $longVar1;
280+
281+
$arrowNoArgs = fn ( )
282+
=> $retrievedfromscope;
283+
284+
$arrowSingleLineArgs = fn ( Type $param1 , int $param2, string $param3) : \ReturnType => $retrievedfromscope;
285+
286+
$arrowMultiLineArgs = fn (
287+
$longVar1,
288+
$longerVar2,
289+
& ... $muchLongerVar3
290+
) => $longVar1;

src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ public function getErrorList($testFile='MultiLineFunctionDeclarationUnitTest.inc
7070
252 => 1,
7171
253 => 1,
7272
254 => 1,
73+
269 => 1,
74+
272 => 1,
75+
273 => 1,
76+
276 => 1,
77+
277 => 1,
78+
278 => 2,
7379
];
7480
} else {
7581
$errors = [

0 commit comments

Comments
 (0)