Skip to content

Commit e99b27c

Browse files
committed
Add incorrect non static access of static property to AccessPropertiesRuleTest
1 parent 2d7dd08 commit e99b27c

File tree

2 files changed

+61
-58
lines changed

2 files changed

+61
-58
lines changed

tests/PHPStan/Rules/Properties/AccessPropertiesRuleTest.php

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -39,140 +39,140 @@ public function testAccessProperties(): void
3939
[
4040
[
4141
'Access to an undefined property TestAccessProperties\BarAccessProperties::$loremipsum.',
42-
24,
42+
26,
4343
$tipText,
4444
],
4545
[
4646
'Access to private property $foo of parent class TestAccessProperties\FooAccessProperties.',
47-
25,
47+
27,
4848
],
4949
[
5050
'Cannot access property $propertyOnString on string.',
51-
32,
51+
35,
5252
],
5353
[
5454
'Access to private property TestAccessProperties\FooAccessProperties::$foo.',
55-
43,
55+
46,
5656
],
5757
[
5858
'Access to protected property TestAccessProperties\FooAccessProperties::$bar.',
59-
44,
59+
47,
6060
],
6161
[
6262
'Access to an undefined property TestAccessProperties\FooAccessProperties::$baz.',
63-
50,
63+
53,
6464
$tipText,
6565
],
6666
[
6767
'Access to an undefined property TestAccessProperties\FooAccessProperties::$nonexistent.',
68-
53,
68+
56,
6969
$tipText,
7070
],
7171
[
7272
'Access to private property TestAccessProperties\FooAccessProperties::$foo.',
73-
59,
73+
62,
7474
],
7575
[
7676
'Access to protected property TestAccessProperties\FooAccessProperties::$bar.',
77-
60,
77+
63,
7878
],
7979
[
8080
'Access to property $foo on an unknown class TestAccessProperties\UnknownClass.',
81-
64,
81+
67,
8282
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
8383
],
8484
[
8585
'Access to an undefined property TestAccessProperties\FooAccessProperties::$emptyBaz.',
86-
69,
86+
72,
8787
$tipText,
8888
],
8989
[
9090
'Access to an undefined property TestAccessProperties\FooAccessProperties::$emptyNonexistent.',
91-
71,
91+
74,
9292
$tipText,
9393
],
9494
[
9595
'Access to an undefined property TestAccessProperties\FooAccessProperties::$anotherNonexistent.',
96-
77,
96+
80,
9797
$tipText,
9898
],
9999
[
100100
'Access to an undefined property TestAccessProperties\FooAccessProperties::$anotherNonexistent.',
101-
78,
101+
81,
102102
$tipText,
103103
],
104104
[
105105
'Access to an undefined property TestAccessProperties\FooAccessProperties::$anotherEmptyNonexistent.',
106-
81,
106+
84,
107107
$tipText,
108108
],
109109
[
110110
'Access to an undefined property TestAccessProperties\FooAccessProperties::$anotherEmptyNonexistent.',
111-
84,
111+
87,
112112
$tipText,
113113
],
114114
[
115115
'Access to property $test on an unknown class TestAccessProperties\FirstUnknownClass.',
116-
147,
116+
150,
117117
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
118118
],
119119
[
120120
'Access to property $test on an unknown class TestAccessProperties\SecondUnknownClass.',
121-
147,
121+
150,
122122
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
123123
],
124124
[
125125
'Access to an undefined property TestAccessProperties\WithFooAndBarProperty|TestAccessProperties\WithFooProperty::$bar.',
126-
177,
126+
180,
127127
$tipText,
128128
],
129129
[
130130
'Access to an undefined property TestAccessProperties\SomeInterface&TestAccessProperties\WithFooProperty::$bar.',
131-
194,
131+
197,
132132
$tipText,
133133
],
134134
[
135135
'Cannot access property $ipsum on TestAccessProperties\FooAccessProperties|null.',
136-
208,
136+
211,
137137
],
138138
[
139139
'Cannot access property $foo on null.',
140-
221,
140+
224,
141141
],
142142
[
143143
'Access to an undefined property TestAccessProperties\FooAccessProperties::$lorem.',
144-
248,
144+
251,
145145
$tipText,
146146
],
147147
[
148148
'Access to an undefined property TestAccessProperties\FooAccessProperties::$dolor.',
149-
251,
149+
254,
150150
$tipText,
151151
],
152152
[
153153
'Cannot access property $bar on TestAccessProperties\NullCoalesce|null.',
154-
274,
154+
277,
155155
],
156156
[
157157
'Cannot access property $foo on TestAccessProperties\NullCoalesce|null.',
158-
274,
158+
277,
159159
],
160160
[
161161
'Cannot access property $foo on TestAccessProperties\NullCoalesce|null.',
162-
274,
162+
277,
163163
],
164164
[
165-
'Access to an undefined property class@anonymous/tests/PHPStan/Rules/Properties/data/access-properties.php:297::$barProperty.',
166-
302,
165+
'Access to an undefined property class@anonymous/tests/PHPStan/Rules/Properties/data/access-properties.php:300::$barProperty.',
166+
305,
167167
$tipText,
168168
],
169169
[
170170
'Cannot access property $selfOrNull on TestAccessProperties\RevertNonNullabilityForIsset|null.',
171-
407,
171+
410,
172172
],
173173
[
174174
'Access to an undefined property object::$baz.',
175-
438,
175+
441,
176176
$tipText,
177177
],
178178
],
@@ -191,114 +191,114 @@ public function testAccessPropertiesWithoutUnionTypes(): void
191191
[
192192
[
193193
'Access to an undefined property TestAccessProperties\BarAccessProperties::$loremipsum.',
194-
24,
194+
26,
195195
$tipText,
196196
],
197197
[
198198
'Access to private property $foo of parent class TestAccessProperties\FooAccessProperties.',
199-
25,
199+
27,
200200
],
201201
[
202202
'Cannot access property $propertyOnString on string.',
203-
32,
203+
35,
204204
],
205205
[
206206
'Access to private property TestAccessProperties\FooAccessProperties::$foo.',
207-
43,
207+
46,
208208
],
209209
[
210210
'Access to protected property TestAccessProperties\FooAccessProperties::$bar.',
211-
44,
211+
47,
212212
],
213213
[
214214
'Access to an undefined property TestAccessProperties\FooAccessProperties::$baz.',
215-
50,
215+
53,
216216
$tipText,
217217
],
218218
[
219219
'Access to an undefined property TestAccessProperties\FooAccessProperties::$nonexistent.',
220-
53,
220+
56,
221221
$tipText,
222222
],
223223
[
224224
'Access to private property TestAccessProperties\FooAccessProperties::$foo.',
225-
59,
225+
62,
226226
],
227227
[
228228
'Access to protected property TestAccessProperties\FooAccessProperties::$bar.',
229-
60,
229+
63,
230230
],
231231
[
232232
'Access to property $foo on an unknown class TestAccessProperties\UnknownClass.',
233-
64,
233+
67,
234234
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
235235
],
236236
[
237237
'Access to an undefined property TestAccessProperties\FooAccessProperties::$emptyBaz.',
238-
69,
238+
72,
239239
$tipText,
240240
],
241241
[
242242
'Access to an undefined property TestAccessProperties\FooAccessProperties::$emptyNonexistent.',
243-
71,
243+
74,
244244
$tipText,
245245
],
246246
[
247247
'Access to an undefined property TestAccessProperties\FooAccessProperties::$anotherNonexistent.',
248-
77,
248+
80,
249249
$tipText,
250250
],
251251
[
252252
'Access to an undefined property TestAccessProperties\FooAccessProperties::$anotherNonexistent.',
253-
78,
253+
81,
254254
$tipText,
255255
],
256256
[
257257
'Access to an undefined property TestAccessProperties\FooAccessProperties::$anotherEmptyNonexistent.',
258-
81,
258+
84,
259259
$tipText,
260260
],
261261
[
262262
'Access to an undefined property TestAccessProperties\FooAccessProperties::$anotherEmptyNonexistent.',
263-
84,
263+
87,
264264
$tipText,
265265
],
266266
[
267267
'Access to property $test on an unknown class TestAccessProperties\FirstUnknownClass.',
268-
147,
268+
150,
269269
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
270270
],
271271
[
272272
'Access to property $test on an unknown class TestAccessProperties\SecondUnknownClass.',
273-
147,
273+
150,
274274
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
275275
],
276276
[
277277
'Access to an undefined property TestAccessProperties\SomeInterface&TestAccessProperties\WithFooProperty::$bar.',
278-
194,
278+
197,
279279
$tipText,
280280
],
281281
[
282282
'Cannot access property $foo on null.',
283-
221,
283+
224,
284284
],
285285
[
286286
'Access to an undefined property TestAccessProperties\FooAccessProperties::$lorem.',
287-
248,
287+
251,
288288
$tipText,
289289
],
290290
[
291291
'Access to an undefined property TestAccessProperties\FooAccessProperties::$dolor.',
292-
251,
292+
254,
293293
$tipText,
294294
],
295295
[
296296
'Cannot access property $bar on TestAccessProperties\NullCoalesce|null.',
297-
274,
297+
277,
298298
],
299299
[
300-
'Access to an undefined property class@anonymous/tests/PHPStan/Rules/Properties/data/access-properties.php:297::$barProperty.',
301-
302,
300+
'Access to an undefined property class@anonymous/tests/PHPStan/Rules/Properties/data/access-properties.php:300::$barProperty.',
301+
305,
302302
$tipText,
303303
],
304304
],
@@ -333,12 +333,12 @@ public function testAccessPropertiesOnThisOnly(): void
333333
[
334334
[
335335
'Access to an undefined property TestAccessProperties\BarAccessProperties::$loremipsum.',
336-
24,
336+
26,
337337
$tipText,
338338
],
339339
[
340340
'Access to private property $foo of parent class TestAccessProperties\FooAccessProperties.',
341-
25,
341+
27,
342342
],
343343
],
344344
);

tests/PHPStan/Rules/Properties/data/access-properties.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class FooAccessProperties
1212

1313
public $ipsum;
1414

15+
public static $staticFoo;
16+
1517
}
1618

1719
class BarAccessProperties extends FooAccessProperties
@@ -23,6 +25,7 @@ public function foo()
2325
{
2426
$this->loremipsum; // nonexistent
2527
$this->foo; // private from an ancestor
28+
$this->staticFoo;
2629
$this->bar;
2730
$this->ipsum;
2831
$this->foobar;

0 commit comments

Comments
 (0)