forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-4498.php
More file actions
50 lines (40 loc) · 1.19 KB
/
bug-4498.php
File metadata and controls
50 lines (40 loc) · 1.19 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
<?php
namespace Bug4498;
use function PHPStan\Testing\assertType;
class Foo
{
/**
* @param iterable<TKey, TValue> $iterable
*
* @return iterable<TKey, TValue>
*
* @template TKey
* @template TValue
*/
public function fcn(iterable $iterable): iterable
{
if ($iterable instanceof \Traversable) {
assertType('iterable<TKey (method Bug4498\Foo::fcn(), argument), TValue (method Bug4498\Foo::fcn(), argument)>&Traversable', $iterable);
return $iterable;
}
assertType('array<TKey (method Bug4498\Foo::fcn(), argument), TValue (method Bug4498\Foo::fcn(), argument)>', $iterable);
return $iterable;
}
/**
* @param iterable<TKey, TValue> $iterable
*
* @return iterable<TKey, TValue>
*
* @template TKey
* @template TValue
*/
public function bar(iterable $iterable): iterable
{
if (is_array($iterable)) {
assertType('array<(TKey of int (method Bug4498\Foo::bar(), argument)|TKey of string (method Bug4498\Foo::bar(), argument)), TValue (method Bug4498\Foo::bar(), argument)>', $iterable);
return $iterable;
}
assertType('Traversable<TKey (method Bug4498\Foo::bar(), argument), TValue (method Bug4498\Foo::bar(), argument)>', $iterable);
return $iterable;
}
}