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 @@ -1017,4 +1017,11 @@ public function testBug13538(): void
10171017 ]);
10181018 }
10191019
1020+ public function testBug12805 (): void
1021+ {
1022+ $ this ->reportPossiblyNonexistentGeneralArrayOffset = true ;
1023+
1024+ $ this ->analyse ([__DIR__ . '/data/bug-12805.php ' ], []);
1025+ }
1026+
10201027}
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