@@ -19,14 +19,15 @@ final class BackfillReadonlyTest extends AbstractMethodUnitTest
1919 * Test that the "readonly" keyword is tokenized as such.
2020 *
2121 * @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".
2324 *
2425 * @dataProvider dataReadonly
2526 * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional
2627 *
2728 * @return void
2829 */
29- public function testReadonly ($ testMarker , $ testContent )
30+ public function testReadonly ($ testMarker , $ testContent= ' readonly ' )
3031 {
3132 $ tokens = self ::$ phpcsFile ->getTokens ();
3233
@@ -49,143 +50,110 @@ public static function dataReadonly()
4950 return [
5051 [
5152 '/* testReadonlyProperty */ ' ,
52- 'readonly ' ,
5353 ],
5454 [
5555 '/* testVarReadonlyProperty */ ' ,
56- 'readonly ' ,
5756 ],
5857 [
5958 '/* testReadonlyVarProperty */ ' ,
60- 'readonly ' ,
6159 ],
6260 [
6361 '/* testStaticReadonlyProperty */ ' ,
64- 'readonly ' ,
6562 ],
6663 [
6764 '/* testReadonlyStaticProperty */ ' ,
68- 'readonly ' ,
6965 ],
7066 [
7167 '/* testConstReadonlyProperty */ ' ,
72- 'readonly ' ,
7368 ],
7469 [
7570 '/* testReadonlyPropertyWithoutType */ ' ,
76- 'readonly ' ,
7771 ],
7872 [
7973 '/* testPublicReadonlyProperty */ ' ,
80- 'readonly ' ,
8174 ],
8275 [
8376 '/* testProtectedReadonlyProperty */ ' ,
84- 'readonly ' ,
8577 ],
8678 [
8779 '/* testPrivateReadonlyProperty */ ' ,
88- 'readonly ' ,
8980 ],
9081 [
9182 '/* testPublicReadonlyPropertyWithReadonlyFirst */ ' ,
92- 'readonly ' ,
9383 ],
9484 [
9585 '/* testProtectedReadonlyPropertyWithReadonlyFirst */ ' ,
96- 'readonly ' ,
9786 ],
9887 [
9988 '/* testPrivateReadonlyPropertyWithReadonlyFirst */ ' ,
100- 'readonly ' ,
10189 ],
10290 [
10391 '/* testReadonlyWithCommentsInDeclaration */ ' ,
104- 'readonly ' ,
10592 ],
10693 [
10794 '/* testReadonlyWithNullableProperty */ ' ,
108- 'readonly ' ,
10995 ],
11096 [
11197 '/* testReadonlyNullablePropertyWithUnionTypeHintAndNullFirst */ ' ,
112- 'readonly ' ,
11398 ],
11499 [
115100 '/* testReadonlyNullablePropertyWithUnionTypeHintAndNullLast */ ' ,
116- 'readonly ' ,
117101 ],
118102 [
119103 '/* testReadonlyPropertyWithArrayTypeHint */ ' ,
120- 'readonly ' ,
121104 ],
122105 [
123106 '/* testReadonlyPropertyWithSelfTypeHint */ ' ,
124- 'readonly ' ,
125107 ],
126108 [
127109 '/* testReadonlyPropertyWithParentTypeHint */ ' ,
128- 'readonly ' ,
129110 ],
130111 [
131112 '/* testReadonlyPropertyWithFullyQualifiedTypeHint */ ' ,
132- 'readonly ' ,
133113 ],
134114 [
135115 '/* testReadonlyIsCaseInsensitive */ ' ,
136116 'ReAdOnLy ' ,
137117 ],
138118 [
139119 '/* testReadonlyConstructorPropertyPromotion */ ' ,
140- 'readonly ' ,
141120 ],
142121 [
143122 '/* testReadonlyConstructorPropertyPromotionWithReference */ ' ,
144123 'ReadOnly ' ,
145124 ],
146125 [
147126 '/* testReadonlyPropertyInAnonymousClass */ ' ,
148- 'readonly ' ,
149127 ],
150128 [
151129 '/* testReadonlyPropertyDNFTypeUnqualified */ ' ,
152- 'readonly ' ,
153130 ],
154131 [
155132 '/* testReadonlyPropertyDNFTypeFullyQualified */ ' ,
156- 'readonly ' ,
157133 ],
158134 [
159135 '/* testReadonlyPropertyDNFTypePartiallyQualified */ ' ,
160- 'readonly ' ,
161136 ],
162137 [
163138 '/* testReadonlyPropertyDNFTypeRelativeName */ ' ,
164- 'readonly ' ,
165139 ],
166140 [
167141 '/* testReadonlyPropertyDNFTypeMultipleSets */ ' ,
168- 'readonly ' ,
169142 ],
170143 [
171144 '/* testReadonlyPropertyDNFTypeWithArray */ ' ,
172- 'readonly ' ,
173145 ],
174146 [
175147 '/* testReadonlyPropertyDNFTypeWithSpacesAndComments */ ' ,
176- 'readonly ' ,
177148 ],
178149 [
179150 '/* testReadonlyConstructorPropertyPromotionWithDNF */ ' ,
180- 'readonly ' ,
181151 ],
182152 [
183153 '/* testReadonlyConstructorPropertyPromotionWithDNFAndReference */ ' ,
184- 'readonly ' ,
185154 ],
186155 [
187156 '/* testParseErrorLiveCoding */ ' ,
188- 'readonly ' ,
189157 ],
190158 ];
191159
@@ -196,14 +164,15 @@ public static function dataReadonly()
196164 * Test that "readonly" when not used as the keyword is still tokenized as `T_STRING`.
197165 *
198166 * @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".
200169 *
201170 * @dataProvider dataNotReadonly
202171 * @covers PHP_CodeSniffer\Tokenizers\PHP::processAdditional
203172 *
204173 * @return void
205174 */
206- public function testNotReadonly ($ testMarker , $ testContent )
175+ public function testNotReadonly ($ testMarker , $ testContent= ' readonly ' )
207176 {
208177 $ tokens = self ::$ phpcsFile ->getTokens ();
209178
@@ -230,23 +199,18 @@ public static function dataNotReadonly()
230199 ],
231200 [
232201 '/* testReadonlyUsedAsMethodName */ ' ,
233- 'readonly ' ,
234202 ],
235203 [
236204 '/* testReadonlyUsedAsPropertyName */ ' ,
237- 'readonly ' ,
238205 ],
239206 [
240207 '/* testReadonlyPropertyInTernaryOperator */ ' ,
241- 'readonly ' ,
242208 ],
243209 [
244210 '/* testReadonlyUsedAsFunctionName */ ' ,
245- 'readonly ' ,
246211 ],
247212 [
248213 '/* testReadonlyUsedAsFunctionNameWithReturnByRef */ ' ,
249- 'readonly ' ,
250214 ],
251215 [
252216 '/* testReadonlyUsedAsNamespaceName */ ' ,
@@ -258,39 +222,33 @@ public static function dataNotReadonly()
258222 ],
259223 [
260224 '/* testReadonlyAsFunctionCall */ ' ,
261- 'readonly ' ,
262225 ],
263226 [
264227 '/* testReadonlyAsNamespacedFunctionCall */ ' ,
265- 'readonly ' ,
266228 ],
267229 [
268230 '/* testReadonlyAsNamespaceRelativeFunctionCall */ ' ,
269231 'ReadOnly ' ,
270232 ],
271233 [
272234 '/* testReadonlyAsMethodCall */ ' ,
273- 'readonly ' ,
274235 ],
275236 [
276237 '/* testReadonlyAsNullsafeMethodCall */ ' ,
277238 'readOnly ' ,
278239 ],
279240 [
280241 '/* testReadonlyAsStaticMethodCallWithSpace */ ' ,
281- 'readonly ' ,
282242 ],
283243 [
284244 '/* testClassConstantFetchWithReadonlyAsConstantName */ ' ,
285245 'READONLY ' ,
286246 ],
287247 [
288248 '/* testReadonlyUsedAsFunctionCallWithSpaceBetweenKeywordAndParens */ ' ,
289- 'readonly ' ,
290249 ],
291250 [
292251 '/* testReadonlyUsedAsMethodNameWithDNFParam */ ' ,
293- 'readonly ' ,
294252 ],
295253 ];
296254
0 commit comments