Skip to content

Commit b03ff03

Browse files
committed
OverwriteVariablesWithForeachRule - test key var
1 parent f37cf89 commit b03ff03

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tests/Rules/ForeachLoop/OverwriteVariablesWithForeachRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public function testRule(): void
3636
'Foreach overwrites $d with its value variable.',
3737
32,
3838
],
39+
[
40+
'Foreach overwrites $b with its key variable.',
41+
38,
42+
],
3943
]);
4044
}
4145

tests/Rules/ForeachLoop/data/foreach.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,13 @@ public function doBaz(array $a, string $b, string $d) {
3434
}
3535
}
3636

37+
public function doLorem(array $a, string $b) {
38+
foreach ($a as $b => $val) {
39+
40+
}
41+
foreach ($a as $c => $val) {
42+
43+
}
44+
}
45+
3746
}

0 commit comments

Comments
 (0)