File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
tests/PHPStan/Rules/Constants Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,21 @@ public function testRememberedConstructorScope(): void
108108 65 ,
109109 'Learn more at https://phpstan.org/user-guide/discovering-symbols ' ,
110110 ],
111+ [
112+ 'Constant XYZ22 not found. ' ,
113+ 87 ,
114+ 'Learn more at https://phpstan.org/user-guide/discovering-symbols ' ,
115+ ],
116+ [
117+ 'Constant XYZ not found. ' ,
118+ 88 ,
119+ 'Learn more at https://phpstan.org/user-guide/discovering-symbols ' ,
120+ ],
121+ [
122+ 'Constant XYZ33 not found. ' ,
123+ 98 ,
124+ 'Learn more at https://phpstan.org/user-guide/discovering-symbols ' ,
125+ ],
111126 ]);
112127 }
113128
Original file line number Diff line number Diff line change @@ -77,3 +77,24 @@ public function doFoo(): void {
7777 echo XYZ ;
7878 }
7979}
80+
81+ class StaticMethodScopeNotRemembered {
82+ static public function init () {
83+ define ('XYZ22 ' , '123 ' );
84+ }
85+
86+ public function doFoo (): void {
87+ echo XYZ22 ; // error because defined in static method
88+ echo XYZ ; // error, because should not mix scope of __constructor() scope of different class
89+ }
90+ }
91+
92+ class InstanceMethodScopeNotRemembered {
93+ public function init () {
94+ define ('XYZ33 ' , '123 ' );
95+ }
96+
97+ public function doFoo (): void {
98+ echo XYZ33 ; // error because defined in non-constructor method
99+ }
100+ }
You can’t perform that action at this time.
0 commit comments