File tree Expand file tree Collapse file tree 2 files changed +76
-0
lines changed
tests/PHPStan/Rules/PhpDoc Expand file tree Collapse file tree 2 files changed +76
-0
lines changed Original file line number Diff line number Diff line change @@ -429,4 +429,9 @@ public function testBug10622(): void
429429 $ this ->analyse ([__DIR__ . '/data/bug-10622.php ' ], []);
430430 }
431431
432+ public function testBug10622B (): void
433+ {
434+ $ this ->analyse ([__DIR__ . '/data/bug-10622b.php ' ], []);
435+ }
436+
432437}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug10622B ;
4+
5+ /**
6+ * @template T of array<mixed>
7+ */
8+ class FooBoxedArray
9+ {
10+ /** @var T */
11+ private $ value ;
12+
13+ /**
14+ * @param T $value
15+ */
16+ public function __construct (array $ value )
17+ {
18+ $ this ->value = $ value ;
19+ }
20+
21+ /**
22+ * @return T
23+ */
24+ public function get (): array
25+ {
26+ return $ this ->value ;
27+ }
28+ }
29+
30+ /**
31+ * @template TKey of object|array<mixed>
32+ * @template TValue of object|array<mixed>
33+ */
34+ class FooMap
35+ {
36+ /**
37+ * @var array<int, array{
38+ * \WeakReference<(TKey is object ? TKey : FooBoxedArray<TKey>)>,
39+ * \WeakReference<(TValue is object ? TValue : FooBoxedArray<TValue>)>
40+ * }>
41+ */
42+ protected $ weakKvByIndex = [];
43+
44+ /**
45+ * @template T of TKey|TValue
46+ *
47+ * @param T $value
48+ *
49+ * @return (T is object ? T : FooBoxedArray<T>)
50+ */
51+ protected function boxValue ($ value ): object
52+ {
53+ return is_array ($ value )
54+ ? new FooBoxedArray ($ value )
55+ : $ value ;
56+ }
57+
58+ /**
59+ * @template T of TKey|TValue
60+ *
61+ * @param (T is object ? T : FooBoxedArray<T>) $value
62+ *
63+ * @return T
64+ */
65+ protected function unboxValue (object $ value )
66+ {
67+ return $ value instanceof FooBoxedArray
68+ ? $ value ->get ()
69+ : $ value ;
70+ }
71+ }
You can’t perform that action at this time.
0 commit comments