File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
tests/PHPStan/Rules/Arrays Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1024,4 +1024,11 @@ public function testBug13538(): void
10241024 ]);
10251025 }
10261026
1027+ public function testBug12805 (): void
1028+ {
1029+ $ this ->reportPossiblyNonexistentGeneralArrayOffset = true ;
1030+
1031+ $ this ->analyse ([__DIR__ . '/data/bug-12805.php ' ], []);
1032+ }
1033+
10271034}
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Bug12805 ;
4+
5+ /**
6+ * @param array<string, array{ rtx?: int }> $operations
7+ * @return array<string, array{ rtx: int }>
8+ */
9+ function bug (array $ operations ): array {
10+ $ base = [];
11+
12+ foreach ($ operations as $ operationName => $ operation ) {
13+ if (!isset ($ base [$ operationName ])) {
14+ $ base [$ operationName ] = [];
15+ }
16+ if (!isset ($ base [$ operationName ]['rtx ' ])) {
17+ $ base [$ operationName ]['rtx ' ] = 0 ;
18+ }
19+ $ base [$ operationName ]['rtx ' ] += $ operation ['rtx ' ] ?? 0 ;
20+ }
21+
22+ return $ base ;
23+ }
You can’t perform that action at this time.
0 commit comments