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
// test: multi-level generic collection resolves element type in foreach
// feature: completion
// Adapted from phpactor generics/gh-1800.test
// Three-level generic chain: interface -> abstract class -> concrete class
// expect: argMethod(
---
<?php
/**
* @template T
* @extends IteratorAggregate<T>
*/
interface ReflectionCollection extends IteratorAggregate
{
}
/**
* @template T
* @implements ReflectionCollection<T>
*/
abstract class AbstractReflectionCollection implements ReflectionCollection
{
}
/**
* @extends AbstractReflectionCollection<ReflectionArgument>
*/
class ReflectionArgumentCollection extends AbstractReflectionCollection
{
}
class ReflectionArgument
{
public function argMethod(): void {}
}
class ReflectionNode
{
public function arguments(): ReflectionArgumentCollection {}
}
$node = new ReflectionNode();
$collection = $node->arguments();
foreach ($collection as $item) {
$item-><>
}