Skip to content

Commit d45a394

Browse files
committed
Add test for arrow function in global scope
1 parent 6a0023c commit d45a394

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Tests/VariableAnalysisSniff/ArrowFunctionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function testArrowFunctionsWithoutUnusedBeforeUsed()
5858
102,
5959
112,
6060
150,
61+
184,
6162
];
6263
$this->assertSame($expectedWarnings, $lines);
6364
}

Tests/VariableAnalysisSniff/fixtures/ArrowFunctionFixture.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,14 @@ function arrowFunctionWithNestedArrowFunction() {
175175
];
176176
$fn();
177177
}
178+
179+
// Arrow function in global scope
180+
array_map(
181+
fn(
182+
$dir,
183+
string $bar,
184+
\My\Class|bool $foo, // Unused variable $foo
185+
\My\Class|bool $baz,
186+
) => PREFIX_DIR . $dir . $bar . $baz,
187+
PHP_ERROR_LOGS['ignore_dirs']
188+
);

0 commit comments

Comments
 (0)