@@ -44,7 +44,7 @@ public function testBackfill($marker, $type, $value)
44
44
*
45
45
* @see testBackfill()
46
46
*
47
- * @return array
47
+ * @return array<string, array<string, string>>
48
48
*/
49
49
public static function dataTestBackfill ()
50
50
{
@@ -64,67 +64,67 @@ public static function dataTestBackfill()
64
64
}
65
65
66
66
return [
67
- [
67
+ ' decimal integer ' => [
68
68
'marker ' => '/* testSimpleLNumber */ ' ,
69
69
'type ' => 'T_LNUMBER ' ,
70
70
'value ' => '1_000_000_000 ' ,
71
71
],
72
- [
72
+ ' float ' => [
73
73
'marker ' => '/* testSimpleDNumber */ ' ,
74
74
'type ' => 'T_DNUMBER ' ,
75
75
'value ' => '107_925_284.88 ' ,
76
76
],
77
- [
77
+ ' float, scientific notation, negative exponent with sigh ' => [
78
78
'marker ' => '/* testFloat */ ' ,
79
79
'type ' => 'T_DNUMBER ' ,
80
80
'value ' => '6.674_083e-11 ' ,
81
81
],
82
- [
82
+ ' float, scientific notation, positive exponent with sign ' => [
83
83
'marker ' => '/* testFloat2 */ ' ,
84
84
'type ' => 'T_DNUMBER ' ,
85
85
'value ' => '6.674_083e+11 ' ,
86
86
],
87
- [
87
+ ' float, scientific notation, positive exponent without sign ' => [
88
88
'marker ' => '/* testFloat3 */ ' ,
89
89
'type ' => 'T_DNUMBER ' ,
90
90
'value ' => '1_2.3_4e1_23 ' ,
91
91
],
92
- [
92
+ ' hexidecimal integer/float ' => [
93
93
'marker ' => '/* testHex */ ' ,
94
94
'type ' => $ testHexType ,
95
95
'value ' => '0xCAFE_F00D ' ,
96
96
],
97
- [
97
+ ' hexidecimal integer/float with multiple underscores ' => [
98
98
'marker ' => '/* testHexMultiple */ ' ,
99
99
'type ' => $ testHexMultipleType ,
100
100
'value ' => '0x42_72_6F_77_6E ' ,
101
101
],
102
- [
102
+ ' hexidecimal integer ' => [
103
103
'marker ' => '/* testHexInt */ ' ,
104
104
'type ' => 'T_LNUMBER ' ,
105
105
'value ' => '0x42_72_6F ' ,
106
106
],
107
- [
107
+ ' binary integer ' => [
108
108
'marker ' => '/* testBinary */ ' ,
109
109
'type ' => 'T_LNUMBER ' ,
110
110
'value ' => '0b0101_1111 ' ,
111
111
],
112
- [
112
+ ' octal integer ' => [
113
113
'marker ' => '/* testOctal */ ' ,
114
114
'type ' => 'T_LNUMBER ' ,
115
115
'value ' => '0137_041 ' ,
116
116
],
117
- [
117
+ ' octal integer using explicit octal notation ' => [
118
118
'marker ' => '/* testExplicitOctal */ ' ,
119
119
'type ' => 'T_LNUMBER ' ,
120
120
'value ' => '0o137_041 ' ,
121
121
],
122
- [
122
+ ' octal integer using explicit octal notation with capital O ' => [
123
123
'marker ' => '/* testExplicitOctalCapitalised */ ' ,
124
124
'type ' => 'T_LNUMBER ' ,
125
125
'value ' => '0O137_041 ' ,
126
126
],
127
- [
127
+ ' integer more than PHP_INT_MAX becomes a float ' => [
128
128
'marker ' => '/* testIntMoreThanMax */ ' ,
129
129
'type ' => $ testIntMoreThanMaxType ,
130
130
'value ' => '10_223_372_036_854_775_807 ' ,
@@ -138,8 +138,8 @@ public static function dataTestBackfill()
138
138
* Test that numbers using numeric separators which are considered parse errors and/or
139
139
* which aren't relevant to the backfill, do not incorrectly trigger the backfill anyway.
140
140
*
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.
143
143
*
144
144
* @dataProvider dataNoBackfill
145
145
* @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize
@@ -165,14 +165,14 @@ public function testNoBackfill($testMarker, $expectedTokens)
165
165
*
166
166
* @see testBackfill()
167
167
*
168
- * @return array
168
+ * @return array<string, array<string, string|array<array<string, int|string>>>>
169
169
*/
170
170
public static function dataNoBackfill ()
171
171
{
172
172
return [
173
- [
174
- '/* testInvalid1 */ ' ,
175
- [
173
+ ' invalid: trailing underscore ' => [
174
+ 'testMarker ' => ' /* testInvalid1 */ ' ,
175
+ ' expectedTokens ' => [
176
176
[
177
177
'code ' => T_LNUMBER ,
178
178
'content ' => '100 ' ,
@@ -183,9 +183,9 @@ public static function dataNoBackfill()
183
183
],
184
184
],
185
185
],
186
- [
187
- '/* testInvalid2 */ ' ,
188
- [
186
+ ' invalid: two consecutive underscores ' => [
187
+ 'testMarker ' => ' /* testInvalid2 */ ' ,
188
+ ' expectedTokens ' => [
189
189
[
190
190
'code ' => T_LNUMBER ,
191
191
'content ' => '1 ' ,
@@ -196,9 +196,9 @@ public static function dataNoBackfill()
196
196
],
197
197
],
198
198
],
199
- [
200
- '/* testInvalid3 */ ' ,
201
- [
199
+ ' invalid: underscore directly before decimal point ' => [
200
+ 'testMarker ' => ' /* testInvalid3 */ ' ,
201
+ ' expectedTokens ' => [
202
202
[
203
203
'code ' => T_LNUMBER ,
204
204
'content ' => '1 ' ,
@@ -213,9 +213,9 @@ public static function dataNoBackfill()
213
213
],
214
214
],
215
215
],
216
- [
217
- '/* testInvalid4 */ ' ,
218
- [
216
+ ' invalid: underscore directly after decimal point ' => [
217
+ 'testMarker ' => ' /* testInvalid4 */ ' ,
218
+ ' expectedTokens ' => [
219
219
[
220
220
'code ' => T_DNUMBER ,
221
221
'content ' => '1. ' ,
@@ -226,9 +226,9 @@ public static function dataNoBackfill()
226
226
],
227
227
],
228
228
],
229
- [
230
- '/* testInvalid5 */ ' ,
231
- [
229
+ ' invalid: hex int - underscore directly after x ' => [
230
+ 'testMarker ' => ' /* testInvalid5 */ ' ,
231
+ ' expectedTokens ' => [
232
232
[
233
233
'code ' => T_LNUMBER ,
234
234
'content ' => '0 ' ,
@@ -239,9 +239,9 @@ public static function dataNoBackfill()
239
239
],
240
240
],
241
241
],
242
- [
243
- '/* testInvalid6 */ ' ,
244
- [
242
+ ' invalid: binary int - underscore directly after b ' => [
243
+ 'testMarker ' => ' /* testInvalid6 */ ' ,
244
+ ' expectedTokens ' => [
245
245
[
246
246
'code ' => T_LNUMBER ,
247
247
'content ' => '0 ' ,
@@ -252,9 +252,9 @@ public static function dataNoBackfill()
252
252
],
253
253
],
254
254
],
255
- [
256
- '/* testInvalid7 */ ' ,
257
- [
255
+ ' invalid: scientific float - underscore directly before e ' => [
256
+ 'testMarker ' => ' /* testInvalid7 */ ' ,
257
+ ' expectedTokens ' => [
258
258
[
259
259
'code ' => T_LNUMBER ,
260
260
'content ' => '1 ' ,
@@ -265,9 +265,9 @@ public static function dataNoBackfill()
265
265
],
266
266
],
267
267
],
268
- [
269
- '/* testInvalid8 */ ' ,
270
- [
268
+ ' invalid: scientific float - underscore directly after e ' => [
269
+ 'testMarker ' => ' /* testInvalid8 */ ' ,
270
+ ' expectedTokens ' => [
271
271
[
272
272
'code ' => T_LNUMBER ,
273
273
'content ' => '1 ' ,
@@ -278,9 +278,9 @@ public static function dataNoBackfill()
278
278
],
279
279
],
280
280
],
281
- [
282
- '/* testInvalid9 */ ' ,
283
- [
281
+ ' invalid: space between parts of the number ' => [
282
+ 'testMarker ' => ' /* testInvalid9 */ ' ,
283
+ ' expectedTokens ' => [
284
284
[
285
285
'code ' => T_LNUMBER ,
286
286
'content ' => '107_925_284 ' ,
@@ -295,9 +295,9 @@ public static function dataNoBackfill()
295
295
],
296
296
],
297
297
],
298
- [
299
- '/* testInvalid10 */ ' ,
300
- [
298
+ ' invalid: comment within the number ' => [
299
+ 'testMarker ' => ' /* testInvalid10 */ ' ,
300
+ ' expectedTokens ' => [
301
301
[
302
302
'code ' => T_LNUMBER ,
303
303
'content ' => '107_925_284 ' ,
@@ -312,9 +312,9 @@ public static function dataNoBackfill()
312
312
],
313
313
],
314
314
],
315
- [
316
- '/* testInvalid11 */ ' ,
317
- [
315
+ ' invalid: explicit octal int - underscore directly after o ' => [
316
+ 'testMarker ' => ' /* testInvalid11 */ ' ,
317
+ ' expectedTokens ' => [
318
318
[
319
319
'code ' => T_LNUMBER ,
320
320
'content ' => '0 ' ,
@@ -325,9 +325,9 @@ public static function dataNoBackfill()
325
325
],
326
326
],
327
327
],
328
- [
329
- '/* testInvalid12 */ ' ,
330
- [
328
+ ' invalid: explicit octal int - underscore directly after capital O ' => [
329
+ 'testMarker ' => ' /* testInvalid12 */ ' ,
330
+ ' expectedTokens ' => [
331
331
[
332
332
'code ' => T_LNUMBER ,
333
333
'content ' => '0 ' ,
@@ -338,9 +338,9 @@ public static function dataNoBackfill()
338
338
],
339
339
],
340
340
],
341
- [
342
- '/* testCalc1 */ ' ,
343
- [
341
+ ' calculations should be untouched - int - int ' => [
342
+ 'testMarker ' => ' /* testCalc1 */ ' ,
343
+ ' expectedTokens ' => [
344
344
[
345
345
'code ' => T_LNUMBER ,
346
346
'content ' => '667_083 ' ,
@@ -363,9 +363,9 @@ public static function dataNoBackfill()
363
363
],
364
364
],
365
365
],
366
- [
367
- '/* test Calc2 */ ' ,
368
- [
366
+ ' calculations should be untouched - scientific float + int ' => [
367
+ 'testMarker ' => ' /* test Calc2 */ ' ,
368
+ ' expectedTokens ' => [
369
369
[
370
370
'code ' => T_DNUMBER ,
371
371
'content ' => '6.674_08e3 ' ,
0 commit comments