forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-5017.php
More file actions
56 lines (47 loc) · 1.15 KB
/
bug-5017.php
File metadata and controls
56 lines (47 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Bug5017;
use function PHPStan\Testing\assertType;
class Foo
{
public function doFoo()
{
$items = [0, 1, 2, 3, 4];
while ($items) {
assertType('non-empty-list<int<min, 4>>', $items);
$batch = array_splice($items, 0, 2);
assertType('list<int<min, 4>>', $items);
assertType('non-empty-list<int<min, 4>>', $batch);
}
}
/**
* @param int[] $items
*/
public function doBar($items)
{
while ($items) {
assertType('non-empty-array<int>', $items);
$batch = array_splice($items, 0, 2);
assertType('array<(int<0, max>|string), int>', $items);
assertType('array<int>', $batch);
}
}
public function doBar2()
{
$items = [0, 1, 2, 3, 4];
assertType('array{0, 1, 2, 3, 4}', $items);
$batch = array_splice($items, 0, 2);
assertType('array{2, 3, 4}', $items);
assertType('array{0, 1}', $batch);
}
/**
* @param int[] $ints
* @param string[] $strings
*/
public function doBar3(array $ints, array $strings)
{
$removed = array_splice($ints, 0, 2, $strings);
assertType('array<int>', $removed);
assertType('array<(int<0, max>|string), int|string>', $ints);
assertType('array<string>', $strings);
}
}