File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
tests/PHPStan/Rules/Variables Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1180,4 +1180,14 @@ public function testBug13353(): void
11801180 $ this ->analyse ([__DIR__ . '/data/bug-13353.php ' ], []);
11811181 }
11821182
1183+ public function testBug13694 (): void
1184+ {
1185+ $ this ->cliArgumentsVariablesRegistered = true ;
1186+ $ this ->polluteScopeWithLoopInitialAssignments = true ;
1187+ $ this ->checkMaybeUndefinedVariables = true ;
1188+ $ this ->polluteScopeWithAlwaysIterableForeach = true ;
1189+
1190+ $ this ->analyse ([__DIR__ . '/data/bug-13694.php ' ], []);
1191+ }
1192+
11831193}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * @param int[] $keys
5+ * @param array<int, int|null> $things
6+ */
7+ function evaluateThings (array $ keys , array $ things ): void
8+ {
9+ foreach ($ keys as $ key ) {
10+ if (array_key_exists ($ key , $ things ) && $ things [$ key ] === null ) {
11+ echo "Value for key $ key is null \n" ;
12+ continue ;
13+ }
14+
15+ if (isset ($ things [$ key ])) {
16+ echo "Key $ key is set \n" ;
17+ }
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments