forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-yield-oversized-self-rejection.php
More file actions
95 lines (91 loc) · 2.76 KB
/
bug-yield-oversized-self-rejection.php
File metadata and controls
95 lines (91 loc) · 2.76 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php declare(strict_types = 1);
namespace BugYieldOversizedSelfRejection;
/**
* Reproducer for a regression where `optimizeConstantArrays` produced a
* Generator value type that did not accept the very yields it was inferred
* from. Each yield is well-typed; the closure's inferred Generator value
* type must therefore be a super-type of every value it actually yields.
*
* @param callable(string): iterable<string, mixed> $fn
* @return \Generator<string, mixed>
*/
function bridge(callable $fn): \Generator
{
foreach (['a', 'b'] as $kind) {
yield from $fn($kind);
}
}
bridge(static function (string $kind): iterable {
$key = 'b' === $kind ? 'x' : 'y';
yield 'one' => [
'kind' => $kind,
'entries' => [[$key => [1, '2022-08-04', [['08:00', '12:00']]]]],
'lookup' => [],
'targets' => [[1, '2022-08-04']],
];
yield 'two' => [
'kind' => $kind,
'entries' => [[$key => [1, '2022-08-04', [['08:00', '12:00'], ['14:00', '18:00']]]]],
'lookup' => [],
'targets' => [[1, '2022-08-04']],
];
yield 'three' => [
'kind' => $kind,
'entries' => [[$key => [1, '2022-08-04', [['00:00', '00:00']]]]],
'lookup' => [],
'targets' => [[1, '2022-08-04']],
];
yield 'four' => [
'kind' => $kind,
'entries' => [[$key => [1, '2022-08-04', [['22:00', '04:00']]]]],
'lookup' => [],
'targets' => [[1, '2022-08-04/2022-08-05']],
];
yield 'five' => [
'kind' => $kind,
'entries' => [[$key => [1, '2022-08-04', [['16:00', '23:00']], 'lookupIds' => [42]]]],
'lookup' => [42 => [1, '2022-08-05T00:05/2022-08-05T02:00']],
'targets' => [[1, '2022-08-04/2022-08-05']],
];
yield 'six' => [
'kind' => $kind,
'entries' => [
[$key => [1, '2022-08-04', [['08:00', '12:00']]]],
[$key => [1, '2022-08-10', [['08:00', '12:00']]]],
],
'lookup' => [],
'targets' => [[1, '2022-08-04'], [1, '2022-08-10']],
];
yield 'seven' => [
'kind' => $kind,
'entries' => [
[$key => [1, '2022-08-04', [['08:00', '12:00']]]],
[$key => [1, '2022-08-05', [['08:00', '12:00']]]],
[$key => [1, '2022-08-06', [['08:00', '12:00']]]],
],
'lookup' => [],
'targets' => [[1, '2022-08-04/2022-08-06']],
];
yield 'eight' => [
'kind' => $kind,
'entries' => [
[$key => [1, '2022-08-04', [['08:00', '12:00']]]],
[$key => [2, '2022-08-05', [['08:00', '12:00']]]],
[$key => [2, '2022-08-06', [['08:00', '12:00']]]],
[$key => [3, '2022-08-06', [['08:00', '12:00']]]],
[$key => [3, '2022-08-10', [['08:00', '12:00']]]],
],
'lookup' => [],
'targets' => [[1, '2022-08-04'], [2, '2022-08-05/2022-08-06'], [3, '2022-08-06'], [3, '2022-08-10']],
];
yield 'nine' => [
'kind' => $kind,
'entries' => [
[$key => [1, '2022-08-04', [['08:00', '12:00']]]],
[$key => [1, '2022-08-05', [['08:00', '12:00']]]],
],
'lookup' => [],
'targets' => [],
'flag' => false,
];
});