Skip to content

Commit 3338db8

Browse files
authored
Add regression test (#5797)
1 parent e634e59 commit 3338db8

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,16 @@ public function testBug9240(): void
13261326
$this->analyse([__DIR__ . '/data/bug-9240.php'], []);
13271327
}
13281328

1329+
public function testBug14758(): void
1330+
{
1331+
$this->analyse([__DIR__ . '/data/bug-14758.php'], [
1332+
[
1333+
'Offset decimal-int-string does not exist on array<string, string>.',
1334+
11,
1335+
],
1336+
]);
1337+
}
1338+
13291339
#[RequiresPhp('>= 8.4.0')]
13301340
public function testArrayFindKeyExisting(): void
13311341
{
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Bug14758;
4+
5+
/**
6+
* @param string $s
7+
* @param array<string, string> $arr
8+
*/
9+
function doBarBug14758(string $s, $arr) {
10+
if (ctype_digit($s)) {
11+
var_dump($arr[$s]);
12+
}
13+
}
14+
15+
/**
16+
* @param string $s
17+
* @param array<int, string> $arr
18+
*/
19+
function doBarBug14758IntKeyed(string $s, $arr) {
20+
if (ctype_digit($s)) {
21+
var_dump($arr[$s]);
22+
}
23+
}

0 commit comments

Comments
 (0)