@@ -19,14 +19,15 @@ final class BackfillReadonlyTest extends AbstractMethodUnitTest
19
19
* Test that the "readonly" keyword is tokenized as such.
20
20
*
21
21
* @param string $testMarker The comment which prefaces the target token in the test file.
22
- * @param string $testContent The token content to look for.
22
+ * @param string $testContent Optional. The token content to look for.
23
+ * Defaults to lowercase "readonly".
23
24
*
24
25
* @dataProvider dataReadonly
25
26
* @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional
26
27
*
27
28
* @return void
28
29
*/
29
- public function testReadonly ($ testMarker , $ testContent )
30
+ public function testReadonly ($ testMarker , $ testContent= ' readonly ' )
30
31
{
31
32
$ tokens = self ::$ phpcsFile ->getTokens ();
32
33
@@ -49,143 +50,110 @@ public static function dataReadonly()
49
50
return [
50
51
[
51
52
'/* testReadonlyProperty */ ' ,
52
- 'readonly ' ,
53
53
],
54
54
[
55
55
'/* testVarReadonlyProperty */ ' ,
56
- 'readonly ' ,
57
56
],
58
57
[
59
58
'/* testReadonlyVarProperty */ ' ,
60
- 'readonly ' ,
61
59
],
62
60
[
63
61
'/* testStaticReadonlyProperty */ ' ,
64
- 'readonly ' ,
65
62
],
66
63
[
67
64
'/* testReadonlyStaticProperty */ ' ,
68
- 'readonly ' ,
69
65
],
70
66
[
71
67
'/* testConstReadonlyProperty */ ' ,
72
- 'readonly ' ,
73
68
],
74
69
[
75
70
'/* testReadonlyPropertyWithoutType */ ' ,
76
- 'readonly ' ,
77
71
],
78
72
[
79
73
'/* testPublicReadonlyProperty */ ' ,
80
- 'readonly ' ,
81
74
],
82
75
[
83
76
'/* testProtectedReadonlyProperty */ ' ,
84
- 'readonly ' ,
85
77
],
86
78
[
87
79
'/* testPrivateReadonlyProperty */ ' ,
88
- 'readonly ' ,
89
80
],
90
81
[
91
82
'/* testPublicReadonlyPropertyWithReadonlyFirst */ ' ,
92
- 'readonly ' ,
93
83
],
94
84
[
95
85
'/* testProtectedReadonlyPropertyWithReadonlyFirst */ ' ,
96
- 'readonly ' ,
97
86
],
98
87
[
99
88
'/* testPrivateReadonlyPropertyWithReadonlyFirst */ ' ,
100
- 'readonly ' ,
101
89
],
102
90
[
103
91
'/* testReadonlyWithCommentsInDeclaration */ ' ,
104
- 'readonly ' ,
105
92
],
106
93
[
107
94
'/* testReadonlyWithNullableProperty */ ' ,
108
- 'readonly ' ,
109
95
],
110
96
[
111
97
'/* testReadonlyNullablePropertyWithUnionTypeHintAndNullFirst */ ' ,
112
- 'readonly ' ,
113
98
],
114
99
[
115
100
'/* testReadonlyNullablePropertyWithUnionTypeHintAndNullLast */ ' ,
116
- 'readonly ' ,
117
101
],
118
102
[
119
103
'/* testReadonlyPropertyWithArrayTypeHint */ ' ,
120
- 'readonly ' ,
121
104
],
122
105
[
123
106
'/* testReadonlyPropertyWithSelfTypeHint */ ' ,
124
- 'readonly ' ,
125
107
],
126
108
[
127
109
'/* testReadonlyPropertyWithParentTypeHint */ ' ,
128
- 'readonly ' ,
129
110
],
130
111
[
131
112
'/* testReadonlyPropertyWithFullyQualifiedTypeHint */ ' ,
132
- 'readonly ' ,
133
113
],
134
114
[
135
115
'/* testReadonlyIsCaseInsensitive */ ' ,
136
116
'ReAdOnLy ' ,
137
117
],
138
118
[
139
119
'/* testReadonlyConstructorPropertyPromotion */ ' ,
140
- 'readonly ' ,
141
120
],
142
121
[
143
122
'/* testReadonlyConstructorPropertyPromotionWithReference */ ' ,
144
123
'ReadOnly ' ,
145
124
],
146
125
[
147
126
'/* testReadonlyPropertyInAnonymousClass */ ' ,
148
- 'readonly ' ,
149
127
],
150
128
[
151
129
'/* testReadonlyPropertyDNFTypeUnqualified */ ' ,
152
- 'readonly ' ,
153
130
],
154
131
[
155
132
'/* testReadonlyPropertyDNFTypeFullyQualified */ ' ,
156
- 'readonly ' ,
157
133
],
158
134
[
159
135
'/* testReadonlyPropertyDNFTypePartiallyQualified */ ' ,
160
- 'readonly ' ,
161
136
],
162
137
[
163
138
'/* testReadonlyPropertyDNFTypeRelativeName */ ' ,
164
- 'readonly ' ,
165
139
],
166
140
[
167
141
'/* testReadonlyPropertyDNFTypeMultipleSets */ ' ,
168
- 'readonly ' ,
169
142
],
170
143
[
171
144
'/* testReadonlyPropertyDNFTypeWithArray */ ' ,
172
- 'readonly ' ,
173
145
],
174
146
[
175
147
'/* testReadonlyPropertyDNFTypeWithSpacesAndComments */ ' ,
176
- 'readonly ' ,
177
148
],
178
149
[
179
150
'/* testReadonlyConstructorPropertyPromotionWithDNF */ ' ,
180
- 'readonly ' ,
181
151
],
182
152
[
183
153
'/* testReadonlyConstructorPropertyPromotionWithDNFAndReference */ ' ,
184
- 'readonly ' ,
185
154
],
186
155
[
187
156
'/* testParseErrorLiveCoding */ ' ,
188
- 'readonly ' ,
189
157
],
190
158
];
191
159
@@ -196,14 +164,15 @@ public static function dataReadonly()
196
164
* Test that "readonly" when not used as the keyword is still tokenized as `T_STRING`.
197
165
*
198
166
* @param string $testMarker The comment which prefaces the target token in the test file.
199
- * @param string $testContent The token content to look for.
167
+ * @param string $testContent Optional. The token content to look for.
168
+ * Defaults to lowercase "readonly".
200
169
*
201
170
* @dataProvider dataNotReadonly
202
171
* @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional
203
172
*
204
173
* @return void
205
174
*/
206
- public function testNotReadonly ($ testMarker , $ testContent )
175
+ public function testNotReadonly ($ testMarker , $ testContent= ' readonly ' )
207
176
{
208
177
$ tokens = self ::$ phpcsFile ->getTokens ();
209
178
@@ -230,23 +199,18 @@ public static function dataNotReadonly()
230
199
],
231
200
[
232
201
'/* testReadonlyUsedAsMethodName */ ' ,
233
- 'readonly ' ,
234
202
],
235
203
[
236
204
'/* testReadonlyUsedAsPropertyName */ ' ,
237
- 'readonly ' ,
238
205
],
239
206
[
240
207
'/* testReadonlyPropertyInTernaryOperator */ ' ,
241
- 'readonly ' ,
242
208
],
243
209
[
244
210
'/* testReadonlyUsedAsFunctionName */ ' ,
245
- 'readonly ' ,
246
211
],
247
212
[
248
213
'/* testReadonlyUsedAsFunctionNameWithReturnByRef */ ' ,
249
- 'readonly ' ,
250
214
],
251
215
[
252
216
'/* testReadonlyUsedAsNamespaceName */ ' ,
@@ -258,39 +222,33 @@ public static function dataNotReadonly()
258
222
],
259
223
[
260
224
'/* testReadonlyAsFunctionCall */ ' ,
261
- 'readonly ' ,
262
225
],
263
226
[
264
227
'/* testReadonlyAsNamespacedFunctionCall */ ' ,
265
- 'readonly ' ,
266
228
],
267
229
[
268
230
'/* testReadonlyAsNamespaceRelativeFunctionCall */ ' ,
269
231
'ReadOnly ' ,
270
232
],
271
233
[
272
234
'/* testReadonlyAsMethodCall */ ' ,
273
- 'readonly ' ,
274
235
],
275
236
[
276
237
'/* testReadonlyAsNullsafeMethodCall */ ' ,
277
238
'readOnly ' ,
278
239
],
279
240
[
280
241
'/* testReadonlyAsStaticMethodCallWithSpace */ ' ,
281
- 'readonly ' ,
282
242
],
283
243
[
284
244
'/* testClassConstantFetchWithReadonlyAsConstantName */ ' ,
285
245
'READONLY ' ,
286
246
],
287
247
[
288
248
'/* testReadonlyUsedAsFunctionCallWithSpaceBetweenKeywordAndParens */ ' ,
289
- 'readonly ' ,
290
249
],
291
250
[
292
251
'/* testReadonlyUsedAsMethodNameWithDNFParam */ ' ,
293
- 'readonly ' ,
294
252
],
295
253
];
296
254
0 commit comments