File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
tests/PHPStan/Rules/Properties Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -1165,4 +1165,29 @@ public function testBug12645(): void
11651165 ]);
11661166 }
11671167
1168+ public function testBug8668 (): void
1169+ {
1170+ $ this ->checkThisOnly = false ;
1171+ $ this ->checkUnionTypes = true ;
1172+ $ this ->checkDynamicProperties = false ;
1173+ $ this ->analyse ([__DIR__ . '/data/bug-8668.php ' ], [
1174+ [
1175+ 'Non-static access to static property Bug8668\Sample::$sample. ' ,
1176+ 9 ,
1177+ ],
1178+ [
1179+ 'Non-static access to static property Bug8668\Sample::$sample. ' ,
1180+ 10 ,
1181+ ],
1182+ [
1183+ 'Non-static access to static property Bug8668\Sample2::$sample. ' ,
1184+ 20 ,
1185+ ],
1186+ [
1187+ 'Non-static access to static property Bug8668\Sample2::$sample. ' ,
1188+ 21 ,
1189+ ],
1190+ ]);
1191+ }
1192+
11681193}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug8668 ;
4+
5+ class Sample {
6+ private static string $ sample = 'abc ' ;
7+
8+ public function test (): void {
9+ echo $ this ->sample ;
10+ echo isset ($ this ->sample );
11+
12+ echo self ::$ sample ; // ok
13+ }
14+ }
15+
16+ class Sample2 {
17+ private static $ sample = 'abc ' ;
18+
19+ public function test (): void {
20+ echo $ this ->sample ;
21+ echo isset ($ this ->sample );
22+
23+ echo self ::$ sample ; // ok
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments