File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed
tests/PHPStan/Rules/Properties Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ final class NewAssignedToPropertyVisitor extends NodeVisitorAbstract
1212
1313 public function enterNode (Node $ node ): ?Node
1414 {
15- if ($ node instanceof Node \Expr \Assign || $ node instanceof Node \Expr \AssignRef) {
15+ if ($ node instanceof Node \Expr \Assign || $ node instanceof Node \Expr \AssignRef || $ node instanceof Node \ Expr \ AssignOp \Coalesce ) {
1616 if (
1717 ($ node ->var instanceof Node \Expr \PropertyFetch || $ node ->var instanceof Node \Expr \StaticPropertyFetch)
1818 && $ node ->expr instanceof Node \Expr \New_
Original file line number Diff line number Diff line change @@ -651,6 +651,11 @@ public function testBug11275(): void
651651 ]);
652652 }
653653
654+ public function testBug12250 (): void
655+ {
656+ $ this ->analyse ([__DIR__ . '/data/bug-12250.php ' ], []);
657+ }
658+
654659 public function testBug11617 (): void
655660 {
656661 $ this ->checkExplicitMixed = true ;
Original file line number Diff line number Diff line change 1+ <?php // lint >= 7.4
2+
3+ namespace Bug12250 ;
4+
5+ class Model {}
6+
7+ /**
8+ * @template T of object|array<mixed>
9+ */
10+ class WeakAnalysingMap
11+ {
12+ /** @var list<T> */
13+ public array $ values = [];
14+ }
15+
16+ class Reference
17+ {
18+ /** @var WeakAnalysingMap<Model> */
19+ private static WeakAnalysingMap $ analysingTheirModelMap ;
20+
21+ public function createAnalysingTheirModel (): Model
22+ {
23+ self ::$ analysingTheirModelMap ??= new WeakAnalysingMap ();
24+
25+ $ theirModel = new Model ();
26+
27+ self ::$ analysingTheirModelMap ->values [] = $ theirModel ;
28+
29+ return end (self ::$ analysingTheirModelMap ->values );
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments