From e2f7e3d195663100f6582e1703b538b375c430c2 Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Sun, 1 Dec 2024 14:38:26 -0500 Subject: [PATCH] Also add test for outside var --- Tests/VariableAnalysisSniff/fixtures/CompactFixture.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tests/VariableAnalysisSniff/fixtures/CompactFixture.php b/Tests/VariableAnalysisSniff/fixtures/CompactFixture.php index e4da908..e10a2f9 100644 --- a/Tests/VariableAnalysisSniff/fixtures/CompactFixture.php +++ b/Tests/VariableAnalysisSniff/fixtures/CompactFixture.php @@ -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(); }