File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -26,4 +26,9 @@ final class WeakReference
26
26
*/
27
27
final class WeakMap implements \ArrayAccess, \Countable, \IteratorAggregate
28
28
{
29
+ /**
30
+ * @param TKey $offset
31
+ * @return TValue
32
+ */
33
+ public function offsetGet($offset) {}
29
34
}
Original file line number Diff line number Diff line change
1
+ <?php // lint >= 8.0
2
+
3
+ declare (strict_types = 1 );
4
+
5
+ namespace weakMap ;
6
+
7
+ use WeakMap ;
8
+ use function PHPStan \Testing \assertType ;
9
+
10
+ interface Foo {}
11
+ interface Bar {}
12
+
13
+ /**
14
+ * @param WeakMap<Foo, Bar> $weakMap
15
+ */
16
+ function weakMapOffsetGetNotNullable (WeakMap $ weakMap , Foo $ foo ): void
17
+ {
18
+ $ bar = $ weakMap [$ foo ];
19
+
20
+ assertType (Bar::class, $ bar );
21
+ }
22
+
23
+
24
+ /**
25
+ * @param WeakMap<Foo, Bar|null> $weakMap
26
+ */
27
+ function weakMapOffsetGetNullable (WeakMap $ weakMap , Foo $ foo ): void
28
+ {
29
+ $ bar = $ weakMap [$ foo ];
30
+
31
+ assertType ( 'weakMap \\Bar|null ' , $ bar );
32
+ }
You can’t perform that action at this time.
0 commit comments