Skip to content

Commit 8611e83

Browse files
committed
Tests: Add test for global update with list
This is a follow-up to #83 which allows global assignments to count as "reads" for the sake of marking unused variables. Demonstrates the fix to #89
1 parent fd217f2 commit 8611e83

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

VariableAnalysis/Tests/CodeAnalysis/fixtures/FunctionWithGlobalVarFixture.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,15 @@ function updateGlobal($newVal) {
3838
function unusedGlobal() {
3939
global $myGlobal; // should warn that var is unused
4040
}
41+
42+
function updateGlobalWithList($newVal) {
43+
global $myGlobal;
44+
list( $myGlobal, $otherVar ) = my_function($newVal);
45+
echo $otherVar;
46+
}
47+
48+
function updateGlobalWithListShorthand($newVal) {
49+
global $myGlobal;
50+
[ $myGlobal, $otherVar ] = my_function($newVal);
51+
echo $otherVar;
52+
}

0 commit comments

Comments
 (0)