File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
tests/PHPStan/Rules/Properties Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -122,4 +122,19 @@ public function testPrivatePropertyTagRead(): void
122122 ]);
123123 }
124124
125+ public function testBug11241 (): void
126+ {
127+ $ this ->checkThisOnly = false ;
128+ $ this ->analyse ([__DIR__ . '/data/bug-11241.php ' ], [
129+ [
130+ 'Property Bug11241\MagicProp::$id is not writable. ' ,
131+ 27 ,
132+ ],
133+ [
134+ 'Property Bug11241\ActualProp::$id is not writable. ' ,
135+ 30 ,
136+ ],
137+ ]);
138+ }
139+
125140}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug11241 ;
4+
5+ /** @property-read int $id */
6+ class MagicProp
7+ {
8+ /** @return mixed */
9+ public function __get (string $ name ) { echo $ this ->id ; }
10+ /** @param mixed $v */
11+ public function __set (string $ name , $ v ): void {}
12+ }
13+
14+ /** @property-read int $id */
15+ class ActualProp
16+ {
17+ private int $ id = 0 ;
18+
19+ /** @return mixed */
20+ public function __get (string $ name ) { echo $ this ->id ; }
21+ /** @param mixed $v */
22+ public function __set (string $ name , $ v ): void {}
23+ }
24+
25+ function (): void {
26+ $ x = new MagicProp ;
27+ $ x ->id = 1 ;
28+
29+ $ x = new ActualProp ;
30+ $ x ->id = 1 ;
31+ };
You can’t perform that action at this time.
0 commit comments