File tree 2 files changed +61
-2
lines changed
tests/PHPStan/Rules/Generators/data
2 files changed +61
-2
lines changed Original file line number Diff line number Diff line change @@ -75,8 +75,7 @@ public function equals(Type $type): bool
75
75
{
76
76
return $ type instanceof self
77
77
&& $ type ->scope ->equals ($ this ->scope )
78
- && $ type ->name === $ this ->name
79
- && parent ::equals ($ type );
78
+ && $ type ->name === $ this ->name ;
80
79
}
81
80
82
81
public function getBound (): Type
Original file line number Diff line number Diff line change @@ -31,3 +31,63 @@ public function doArrayShape(): \Generator
31
31
}
32
32
33
33
}
34
+
35
+ /**
36
+ * @template TKey
37
+ * @template TValue
38
+ */
39
+ final class Map
40
+ {
41
+ /** @var TKey */
42
+ private $ key ;
43
+ /** @var TValue */
44
+ private $ value ;
45
+
46
+ /**
47
+ * @param TKey $key
48
+ * @param TValue $value
49
+ */
50
+ public function __construct ($ key , $ value )
51
+ {
52
+ $ this ->key = $ key ;
53
+ $ this ->value = $ value ;
54
+ }
55
+
56
+ /** @return TKey */
57
+ public function key ()
58
+ {
59
+ return $ this ->key ;
60
+ }
61
+
62
+ /** @return TValue */
63
+ public function value ()
64
+ {
65
+ return $ this ->value ;
66
+ }
67
+ }
68
+
69
+ class TestMap
70
+ {
71
+
72
+ /**
73
+ * @template TKey
74
+ * @template TValue
75
+ *
76
+ * @param iterable<TKey, TValue> $iterator
77
+ * @param callable(TValue, TKey):(TValue|Map<TKey, TValue>) $callback
78
+ *
79
+ * @return iterable<TKey, TValue>
80
+ */
81
+ function iterator_map (iterable $ iterator , callable $ callback ): iterable
82
+ {
83
+ foreach ($ iterator as $ key => $ value ) {
84
+ $ result = $ callback ($ value , $ key );
85
+ if ($ result instanceof Map) {
86
+ yield $ result ->key () => $ result ->value ();
87
+ continue ;
88
+ }
89
+ yield $ key => $ result ;
90
+ }
91
+ }
92
+
93
+ }
You can’t perform that action at this time.
0 commit comments