Skip to content

Commit e960229

Browse files
committed
test
1 parent 40a218d commit e960229

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,14 @@ public function testBug12981(): void
946946
'Offset array<int, int|string> might not exist on non-empty-array<bool|float|int|string>.',
947947
33,
948948
],
949+
[
950+
'Offset array<int, int|string>|int|string might not exist on non-empty-array<bool|float|int|string>.',
951+
39,
952+
],
953+
[
954+
'Offset array<int, int|string>|int|string might not exist on non-empty-array<bool|float|int|string>.',
955+
41,
956+
],
949957
]);
950958
}
951959

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,12 @@ public function sayHello2(array $arr): void
3232
$randIndex = array_rand($arr, $num);
3333
echo $arr[$randIndex];
3434
}
35+
36+
/** @param non-empty-array<scalar> $arr */
37+
public function sayHello4(array $arr, int $num): void
38+
{
39+
echo $arr[array_rand($arr, $num)];
40+
$randIndex = array_rand($arr, $num);
41+
echo $arr[$randIndex];
42+
}
3543
}

0 commit comments

Comments
 (0)