@@ -44,7 +44,7 @@ public function testBackfill($marker, $type, $value)
4444 *
4545 * @see testBackfill()
4646 *
47- * @return array
47+ * @return array<string, array<string, string>>
4848 */
4949 public static function dataTestBackfill ()
5050 {
@@ -64,67 +64,67 @@ public static function dataTestBackfill()
6464 }
6565
6666 return [
67- [
67+ ' decimal integer ' => [
6868 'marker ' => '/* testSimpleLNumber */ ' ,
6969 'type ' => 'T_LNUMBER ' ,
7070 'value ' => '1_000_000_000 ' ,
7171 ],
72- [
72+ ' float ' => [
7373 'marker ' => '/* testSimpleDNumber */ ' ,
7474 'type ' => 'T_DNUMBER ' ,
7575 'value ' => '107_925_284.88 ' ,
7676 ],
77- [
77+ ' float, scientific notation, negative exponent with sigh ' => [
7878 'marker ' => '/* testFloat */ ' ,
7979 'type ' => 'T_DNUMBER ' ,
8080 'value ' => '6.674_083e-11 ' ,
8181 ],
82- [
82+ ' float, scientific notation, positive exponent with sign ' => [
8383 'marker ' => '/* testFloat2 */ ' ,
8484 'type ' => 'T_DNUMBER ' ,
8585 'value ' => '6.674_083e+11 ' ,
8686 ],
87- [
87+ ' float, scientific notation, positive exponent without sign ' => [
8888 'marker ' => '/* testFloat3 */ ' ,
8989 'type ' => 'T_DNUMBER ' ,
9090 'value ' => '1_2.3_4e1_23 ' ,
9191 ],
92- [
92+ ' hexidecimal integer/float ' => [
9393 'marker ' => '/* testHex */ ' ,
9494 'type ' => $ testHexType ,
9595 'value ' => '0xCAFE_F00D ' ,
9696 ],
97- [
97+ ' hexidecimal integer/float with multiple underscores ' => [
9898 'marker ' => '/* testHexMultiple */ ' ,
9999 'type ' => $ testHexMultipleType ,
100100 'value ' => '0x42_72_6F_77_6E ' ,
101101 ],
102- [
102+ ' hexidecimal integer ' => [
103103 'marker ' => '/* testHexInt */ ' ,
104104 'type ' => 'T_LNUMBER ' ,
105105 'value ' => '0x42_72_6F ' ,
106106 ],
107- [
107+ ' binary integer ' => [
108108 'marker ' => '/* testBinary */ ' ,
109109 'type ' => 'T_LNUMBER ' ,
110110 'value ' => '0b0101_1111 ' ,
111111 ],
112- [
112+ ' octal integer ' => [
113113 'marker ' => '/* testOctal */ ' ,
114114 'type ' => 'T_LNUMBER ' ,
115115 'value ' => '0137_041 ' ,
116116 ],
117- [
117+ ' octal integer using explicit octal notation ' => [
118118 'marker ' => '/* testExplicitOctal */ ' ,
119119 'type ' => 'T_LNUMBER ' ,
120120 'value ' => '0o137_041 ' ,
121121 ],
122- [
122+ ' octal integer using explicit octal notation with capital O ' => [
123123 'marker ' => '/* testExplicitOctalCapitalised */ ' ,
124124 'type ' => 'T_LNUMBER ' ,
125125 'value ' => '0O137_041 ' ,
126126 ],
127- [
127+ ' integer more than PHP_INT_MAX becomes a float ' => [
128128 'marker ' => '/* testIntMoreThanMax */ ' ,
129129 'type ' => $ testIntMoreThanMaxType ,
130130 'value ' => '10_223_372_036_854_775_807 ' ,
@@ -138,8 +138,8 @@ public static function dataTestBackfill()
138138 * Test that numbers using numeric separators which are considered parse errors and/or
139139 * which aren't relevant to the backfill, do not incorrectly trigger the backfill anyway.
140140 *
141- * @param string $testMarker The comment which prefaces the target token in the test file.
142- * @param array $expectedTokens The token type and content of the expected token sequence.
141+ * @param string $testMarker The comment which prefaces the target token in the test file.
142+ * @param array<array<string, int|string>> $expectedTokens The token type and content of the expected token sequence.
143143 *
144144 * @dataProvider dataNoBackfill
145145 * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize
@@ -165,14 +165,14 @@ public function testNoBackfill($testMarker, $expectedTokens)
165165 *
166166 * @see testBackfill()
167167 *
168- * @return array
168+ * @return array<string, array<string, string|array<array<string, int|string>>>>
169169 */
170170 public static function dataNoBackfill ()
171171 {
172172 return [
173- [
174- '/* testInvalid1 */ ' ,
175- [
173+ ' invalid: trailing underscore ' => [
174+ 'testMarker ' => ' /* testInvalid1 */ ' ,
175+ ' expectedTokens ' => [
176176 [
177177 'code ' => T_LNUMBER ,
178178 'content ' => '100 ' ,
@@ -183,9 +183,9 @@ public static function dataNoBackfill()
183183 ],
184184 ],
185185 ],
186- [
187- '/* testInvalid2 */ ' ,
188- [
186+ ' invalid: two consecutive underscores ' => [
187+ 'testMarker ' => ' /* testInvalid2 */ ' ,
188+ ' expectedTokens ' => [
189189 [
190190 'code ' => T_LNUMBER ,
191191 'content ' => '1 ' ,
@@ -196,9 +196,9 @@ public static function dataNoBackfill()
196196 ],
197197 ],
198198 ],
199- [
200- '/* testInvalid3 */ ' ,
201- [
199+ ' invalid: underscore directly before decimal point ' => [
200+ 'testMarker ' => ' /* testInvalid3 */ ' ,
201+ ' expectedTokens ' => [
202202 [
203203 'code ' => T_LNUMBER ,
204204 'content ' => '1 ' ,
@@ -213,9 +213,9 @@ public static function dataNoBackfill()
213213 ],
214214 ],
215215 ],
216- [
217- '/* testInvalid4 */ ' ,
218- [
216+ ' invalid: underscore directly after decimal point ' => [
217+ 'testMarker ' => ' /* testInvalid4 */ ' ,
218+ ' expectedTokens ' => [
219219 [
220220 'code ' => T_DNUMBER ,
221221 'content ' => '1. ' ,
@@ -226,9 +226,9 @@ public static function dataNoBackfill()
226226 ],
227227 ],
228228 ],
229- [
230- '/* testInvalid5 */ ' ,
231- [
229+ ' invalid: hex int - underscore directly after x ' => [
230+ 'testMarker ' => ' /* testInvalid5 */ ' ,
231+ ' expectedTokens ' => [
232232 [
233233 'code ' => T_LNUMBER ,
234234 'content ' => '0 ' ,
@@ -239,9 +239,9 @@ public static function dataNoBackfill()
239239 ],
240240 ],
241241 ],
242- [
243- '/* testInvalid6 */ ' ,
244- [
242+ ' invalid: binary int - underscore directly after b ' => [
243+ 'testMarker ' => ' /* testInvalid6 */ ' ,
244+ ' expectedTokens ' => [
245245 [
246246 'code ' => T_LNUMBER ,
247247 'content ' => '0 ' ,
@@ -252,9 +252,9 @@ public static function dataNoBackfill()
252252 ],
253253 ],
254254 ],
255- [
256- '/* testInvalid7 */ ' ,
257- [
255+ ' invalid: scientific float - underscore directly before e ' => [
256+ 'testMarker ' => ' /* testInvalid7 */ ' ,
257+ ' expectedTokens ' => [
258258 [
259259 'code ' => T_LNUMBER ,
260260 'content ' => '1 ' ,
@@ -265,9 +265,9 @@ public static function dataNoBackfill()
265265 ],
266266 ],
267267 ],
268- [
269- '/* testInvalid8 */ ' ,
270- [
268+ ' invalid: scientific float - underscore directly after e ' => [
269+ 'testMarker ' => ' /* testInvalid8 */ ' ,
270+ ' expectedTokens ' => [
271271 [
272272 'code ' => T_LNUMBER ,
273273 'content ' => '1 ' ,
@@ -278,9 +278,9 @@ public static function dataNoBackfill()
278278 ],
279279 ],
280280 ],
281- [
282- '/* testInvalid9 */ ' ,
283- [
281+ ' invalid: space between parts of the number ' => [
282+ 'testMarker ' => ' /* testInvalid9 */ ' ,
283+ ' expectedTokens ' => [
284284 [
285285 'code ' => T_LNUMBER ,
286286 'content ' => '107_925_284 ' ,
@@ -295,9 +295,9 @@ public static function dataNoBackfill()
295295 ],
296296 ],
297297 ],
298- [
299- '/* testInvalid10 */ ' ,
300- [
298+ ' invalid: comment within the number ' => [
299+ 'testMarker ' => ' /* testInvalid10 */ ' ,
300+ ' expectedTokens ' => [
301301 [
302302 'code ' => T_LNUMBER ,
303303 'content ' => '107_925_284 ' ,
@@ -312,9 +312,9 @@ public static function dataNoBackfill()
312312 ],
313313 ],
314314 ],
315- [
316- '/* testInvalid11 */ ' ,
317- [
315+ ' invalid: explicit octal int - underscore directly after o ' => [
316+ 'testMarker ' => ' /* testInvalid11 */ ' ,
317+ ' expectedTokens ' => [
318318 [
319319 'code ' => T_LNUMBER ,
320320 'content ' => '0 ' ,
@@ -325,9 +325,9 @@ public static function dataNoBackfill()
325325 ],
326326 ],
327327 ],
328- [
329- '/* testInvalid12 */ ' ,
330- [
328+ ' invalid: explicit octal int - underscore directly after capital O ' => [
329+ 'testMarker ' => ' /* testInvalid12 */ ' ,
330+ ' expectedTokens ' => [
331331 [
332332 'code ' => T_LNUMBER ,
333333 'content ' => '0 ' ,
@@ -338,9 +338,9 @@ public static function dataNoBackfill()
338338 ],
339339 ],
340340 ],
341- [
342- '/* testCalc1 */ ' ,
343- [
341+ ' calculations should be untouched - int - int ' => [
342+ 'testMarker ' => ' /* testCalc1 */ ' ,
343+ ' expectedTokens ' => [
344344 [
345345 'code ' => T_LNUMBER ,
346346 'content ' => '667_083 ' ,
@@ -363,9 +363,9 @@ public static function dataNoBackfill()
363363 ],
364364 ],
365365 ],
366- [
367- '/* test Calc2 */ ' ,
368- [
366+ ' calculations should be untouched - scientific float + int ' => [
367+ 'testMarker ' => ' /* test Calc2 */ ' ,
368+ ' expectedTokens ' => [
369369 [
370370 'code ' => T_DNUMBER ,
371371 'content ' => '6.674_08e3 ' ,
0 commit comments