-
Notifications
You must be signed in to change notification settings - Fork 428
/
bug-4117.php
54 lines (45 loc) · 1.35 KB
/
bug-4117.php
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
<?php
namespace Bug4117Types;
use ArrayIterator;
use IteratorAggregate;
use function PHPStan\Testing\assertType;
/**
* @refactor Refactor utils into base library
* @template T of mixed
* @implements IteratorAggregate<int, T>
*/
class GenericList implements IteratorAggregate
{
/** @var array<int, T> */
protected $items = [];
/**
* @return ArrayIterator<int, T>
*/
public function getIterator(): ArrayIterator
{
return new ArrayIterator($this->items);
}
/**
* @return ?T
*/
public function broken(int $key)
{
$item = $this->items[$key] ?? null;
if ($item) {
assertType("T of mixed~0|0.0|''|'0'|array{}|false|null (class Bug4117Types\GenericList, argument)", $item);
} else {
assertType("(array{}&T (class Bug4117Types\GenericList, argument))|(0.0&T (class Bug4117Types\GenericList, argument))|(0&T (class Bug4117Types\GenericList, argument))|(''&T (class Bug4117Types\GenericList, argument))|('0'&T (class Bug4117Types\GenericList, argument))|(T (class Bug4117Types\GenericList, argument)&false)|null", $item);
}
assertType("T of mixed~0|0.0|''|'0'|array{}|false|null (class Bug4117Types\GenericList, argument)|null", $item);
return $item;
}
/**
* @return ?T
*/
public function works(int $key)
{
$item = $this->items[$key] ?? null;
assertType('T (class Bug4117Types\GenericList, argument)|null', $item);
return $item;
}
}