Skip to content

Commit

Permalink
Also add test for outside var
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed Dec 1, 2024
1 parent b1b9871 commit e2f7e3d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Tests/VariableAnalysisSniff/fixtures/CompactFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ function foo() {
function function_with_arrow_function_and_compact() {
$make_array = fn ($arg) => compact('arg');
$make_nothing = fn ($arg) => []; // Unused variable $arg
$make_no_variable = fn () => compact('arg') // Undefined variable $arg
$make_no_variable = fn () => compact('arg');
echo $make_array('hello');
echo $make_nothing('hello');
echo $make_no_variable();
$make_array_multiple = fn ($arg1, $arg2, $arg3) => compact('arg1', 'arg2', 'arg3');
echo $make_array_multiple();
$outside_var = 'hello world';
$use_outside_var = fn($inside_var) => compact('outside_var', 'inside_var');
echo $use_outside_var();
}

0 comments on commit e2f7e3d

Please sign in to comment.