Skip to content

Commit

Permalink
Tests: Add test for global update with list
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sirbrillig committed May 14, 2019
1 parent fd217f2 commit 8611e83
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,15 @@ function updateGlobal($newVal) {
function unusedGlobal() {
global $myGlobal; // should warn that var is unused
}

function updateGlobalWithList($newVal) {
global $myGlobal;
list( $myGlobal, $otherVar ) = my_function($newVal);
echo $otherVar;
}

function updateGlobalWithListShorthand($newVal) {
global $myGlobal;
[ $myGlobal, $otherVar ] = my_function($newVal);
echo $otherVar;
}

0 comments on commit 8611e83

Please sign in to comment.