File tree Expand file tree Collapse file tree 3 files changed +42
-5
lines changed
tests/PHPStan/Rules/Properties Expand file tree Collapse file tree 3 files changed +42
-5
lines changed Original file line number Diff line number Diff line change @@ -5609,11 +5609,20 @@ private function processAssignVar(
5609
5609
} else {
5610
5610
$ varForSetOffsetValue = $ var ->var ;
5611
5611
}
5612
- $ assignedPropertyExpr = new SetOffsetValueTypeExpr (
5613
- $ varForSetOffsetValue ,
5614
- $ var ->dim ,
5615
- $ assignedPropertyExpr ,
5616
- );
5612
+
5613
+ if ($ scope ->hasExpressionType ($ var )->yes ()) {
5614
+ $ assignedPropertyExpr = new SetExistingOffsetValueTypeExpr (
5615
+ $ varForSetOffsetValue ,
5616
+ $ var ->dim ,
5617
+ $ assignedPropertyExpr ,
5618
+ );
5619
+ } else {
5620
+ $ assignedPropertyExpr = new SetOffsetValueTypeExpr (
5621
+ $ varForSetOffsetValue ,
5622
+ $ var ->dim ,
5623
+ $ assignedPropertyExpr ,
5624
+ );
5625
+ }
5617
5626
$ dimFetchStack [] = $ var ;
5618
5627
$ var = $ var ->var ;
5619
5628
}
Original file line number Diff line number Diff line change @@ -935,4 +935,11 @@ public function testBug11777(): void
935
935
$ this ->analyse ([__DIR__ . '/data/bug-11777.php ' ], []);
936
936
}
937
937
938
+ public function testBug13035 (): void
939
+ {
940
+ $ this ->checkExplicitMixed = true ;
941
+ $ this ->checkImplicitMixed = true ;
942
+ $ this ->analyse ([__DIR__ . '/data/bug-13035.php ' ], []);
943
+ }
944
+
938
945
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug13035 ;
4
+
5
+ use function PHPStan \debugScope ;
6
+ use function PHPStan \Testing \assertType ;
7
+
8
+ class HelloWorld
9
+ {
10
+ /**
11
+ * @var list<int>
12
+ */
13
+ public array $ list = [];
14
+
15
+ public function bug (int $ offset ): void
16
+ {
17
+ if (isset ($ this ->list [$ offset ])) {
18
+ $ this ->list [$ offset ] = 123 ;
19
+ }
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments