Skip to content

Commit 2980730

Browse files
Add non regression test
1 parent 65797b9 commit 2980730

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,12 @@ public function testBug6209(): void
11491149
$this->analyse([__DIR__ . '/data/bug-6209.php'], []);
11501150
}
11511151

1152+
public function testBug11602(): void
1153+
{
1154+
$this->reportPossiblyNonexistentConstantArrayOffset = true;
1155+
$this->analyse([__DIR__ . '/data/bug-11602.php'], []);
1156+
}
1157+
11521158
public function testBug11276(): void
11531159
{
11541160
$this->reportPossiblyNonexistentConstantArrayOffset = true;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug11602;
4+
5+
class HelloWorld
6+
{
7+
public function parseRef(string $coordinate, string $ref): string
8+
{
9+
if (preg_match('/^([A-Z]{1,3})([0-9]{1,7})(:([A-Z]{1,3})([0-9]{1,7}))?$/', $ref, $matches) !== 1) {
10+
return $ref;
11+
}
12+
if (!isset($matches[5])) { // single cell, not range
13+
return $coordinate;
14+
}
15+
$minRow = (int) $matches[2];
16+
$maxRow = (int) $matches[5];
17+
$rows = $maxRow - $minRow + 1;
18+
$minCol = $matches[1];
19+
$maxCol = $matches[4];
20+
21+
return "$minCol$minRow:$maxCol$maxRow";
22+
}
23+
}

0 commit comments

Comments
 (0)