Skip to content

Commit 76a336b

Browse files
committed
test
1 parent f13ee69 commit 76a336b

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
@@ -955,6 +955,14 @@ public function testBug12981(): void
955955
'Offset array<int, int|string> might not exist on non-empty-array<bool|float|int|string>.',
956956
33,
957957
],
958+
[
959+
'Offset array<int, int|string>|int|string might not exist on non-empty-array<bool|float|int|string>.',
960+
39,
961+
],
962+
[
963+
'Offset array<int, int|string>|int|string might not exist on non-empty-array<bool|float|int|string>.',
964+
41,
965+
],
958966
]);
959967
}
960968

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)