-
Notifications
You must be signed in to change notification settings - Fork 574
Expand file tree
/
Copy pathbug-12601.php
More file actions
54 lines (44 loc) · 1.4 KB
/
bug-12601.php
File metadata and controls
54 lines (44 loc) · 1.4 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
<?php // lint >= 8.0
declare(strict_types = 1);
namespace Bug12601;
use ArrayIterator;
use IteratorAggregate;
use Traversable;
use function PHPStan\Testing\assertType;
/** @implements IteratorAggregate<non-empty-string, non-empty-string> */
class HelloWorld implements IteratorAggregate
{
/** @param array<non-empty-string, non-empty-string> $map */
public function __construct(private array $map) {}
/** @return Traversable<non-empty-string, non-empty-string> */
public function getIterator(): Traversable
{
$iterator = new ArrayIterator($this->map);
assertType('ArrayIterator<non-empty-string, non-empty-string>', $iterator);
return $iterator;
}
}
class HelloWorld3
{
/** @var ArrayIterator<int, string> */
private ArrayIterator $a;
/** @param list<string> $map */
public function __construct(private array $map) {
$a = new ArrayIterator($this->map);
assertType('ArrayIterator<int<0, max>, string>', $a);
$this->a = $a;
}
}
/** @implements IteratorAggregate<int<0, max>, non-empty-string> */
class HelloWorld2 implements IteratorAggregate
{
/** @param array<int<0, max>, non-empty-string> $map */
public function __construct(private array $map) {}
/** @return ArrayIterator<int<0, max>, non-empty-string> */
public function getIterator(): Traversable
{
$iterator = new ArrayIterator($this->map);
assertType('ArrayIterator<int<0, max>, non-empty-string>', $iterator);
return $iterator;
}
}