Skip to content

Commit 82aef37

Browse files
committed
test offset-access on int types
1 parent caffc65 commit 82aef37

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -864,4 +864,18 @@ public function testBug10997(): void
864864
]);
865865
}
866866

867+
public function testBug11572(): void
868+
{
869+
$this->analyse([__DIR__ . '/data/bug-11572.php'], [
870+
[
871+
'Cannot access an offset on int.',
872+
45,
873+
],
874+
[
875+
'Cannot access an offset on int<3, 4>.',
876+
46,
877+
],
878+
]);
879+
}
880+
867881
}

tests/PHPStan/Rules/Arrays/data/bug-11572.php

+9
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,12 @@ function doFoo() {
3636
$s[] = 'foo';
3737
}
3838
}
39+
40+
/**
41+
* @param int<3,4> $range
42+
*/
43+
function doInt(int $i, $range): void
44+
{
45+
$i[] = 1;
46+
$range[] = 1;
47+
}

0 commit comments

Comments
 (0)