Skip to content

Commit e5b2baf

Browse files
staabmondrejmirtes
authored andcommitted
Added regression test
1 parent dc8d8d0 commit e5b2baf

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,4 +907,11 @@ public function testBug11602(): void
907907
$this->analyse([__DIR__ . '/data/bug-11602.php'], []);
908908
}
909909

910+
public function testBug12593(): void
911+
{
912+
$this->reportPossiblyNonexistentGeneralArrayOffset = true;
913+
914+
$this->analyse([__DIR__ . '/data/bug-12593.php'], []);
915+
}
916+
910917
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Bug12593;
4+
5+
class HelloWorld
6+
{
7+
/**
8+
* @param list<int> $indexes
9+
*/
10+
protected function removeArguments(array $indexes): void
11+
{
12+
if (isset($_SERVER['argv']) && is_array($_SERVER['argv'])) {
13+
foreach ($indexes as $index) {
14+
if (isset($_SERVER['argv'][$index])) {
15+
unset($_SERVER['argv'][$index]);
16+
}
17+
}
18+
}
19+
}
20+
}
21+
22+
class HelloWorld2
23+
{
24+
/**
25+
* @param list<int> $indexes
26+
*/
27+
protected function removeArguments(array $indexes): void
28+
{
29+
foreach ($indexes as $index) {
30+
if (isset($_SERVER['argv']) && is_array($_SERVER['argv']) && isset($_SERVER['argv'][$index])) {
31+
unset($_SERVER['argv'][$index]);
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)