File tree 2 files changed +36
-0
lines changed
tests/PHPStan/Rules/Constants
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
108
108
65 ,
109
109
'Learn more at https://phpstan.org/user-guide/discovering-symbols ' ,
110
110
],
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
+ ],
111
126
]);
112
127
}
113
128
Original file line number Diff line number Diff line change @@ -77,3 +77,24 @@ public function doFoo(): void {
77
77
echo XYZ ;
78
78
}
79
79
}
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