Commit de8442a
Tokenizer: T_USE tokens for closure use now contain parenthesis information
Closure `use` keywords will now be recognized as `parenthesis_owner`s and both the keyword, as well as the associated parenthesis will receive the `parenthesis_owner`, `parenthesis_opener` and `parenthesis_closer` indexes.
Includes:
* A tweak in the PHP tokenizer to handle return type recognition in combination with closures with `use` correctly.
This tweaks is covered by pre-existing tests.
* A dedicated set of tests for the handling of `T_USE` tokens in this context to safeguard that `use` keywords for import use statements and trait use statements do not get the `parenthesis_*` indexes.
Tests taken from PR squizlabs/PHP_CodeSniffer 3104 and updated to have named data sets and failure messages for all assertions.
* With this change in place, the tests for the `File::getMethodParameters()` method will start failing straight away, so this commit _also_ includes a fix to that method to allow for this change, while maintaining the pre-existing behaviour.
Includes some additional tests to document the method behaviour regarding closure `use` during live coding.
* With this change in place, the tests for the `Squiz/MemberVarScope` sniff would also start to fail.
This is fixed by the change in the `AbstractVariableSniff` class to allow for `T_USE` now being a parenthesis owner.
Fixes squizlabs/PHP_CodeSniffer 2593
Replaces squizlabs/PHP_CodeSniffer 3104 (made redundant by the previous PR)
Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>1 parent bd288db commit de8442a
File tree
14 files changed
+375
-24
lines changed- src
- Files
- Sniffs
- Tokenizers
- Util
- tests/Core
- File
- Tokenizers/Tokenizer
14 files changed
+375
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1313 | 1313 | | |
1314 | 1314 | | |
1315 | 1315 | | |
1316 | | - | |
1317 | | - | |
1318 | | - | |
1319 | | - | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
1323 | | - | |
1324 | | - | |
1325 | | - | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
1326 | 1321 | | |
1327 | | - | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
1328 | 1325 | | |
1329 | 1326 | | |
| 1327 | + | |
| 1328 | + | |
1330 | 1329 | | |
1331 | 1330 | | |
1332 | 1331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | 121 | | |
129 | 122 | | |
130 | 123 | | |
131 | 124 | | |
132 | 125 | | |
133 | 126 | | |
| 127 | + | |
134 | 128 | | |
135 | 129 | | |
136 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3207 | 3207 | | |
3208 | 3208 | | |
3209 | 3209 | | |
| 3210 | + | |
3210 | 3211 | | |
3211 | 3212 | | |
3212 | 3213 | | |
| |||
3215 | 3216 | | |
3216 | 3217 | | |
3217 | 3218 | | |
3218 | | - | |
3219 | 3219 | | |
3220 | 3220 | | |
3221 | 3221 | | |
3222 | 3222 | | |
3223 | 3223 | | |
3224 | 3224 | | |
3225 | 3225 | | |
3226 | | - | |
| 3226 | + | |
3227 | 3227 | | |
3228 | 3228 | | |
3229 | 3229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| 361 | + | |
361 | 362 | | |
362 | 363 | | |
363 | 364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
0 commit comments