Commit df4a812
committed
Tokenizer/PHP: bug fix for missing parenthesis owner for method named "fn"
When a function is named "fn", the `function` keyword should be set as the parenthesis owner.
While this works on PHPCS 3.x, I found while making PHPCSUtils compatible with 4.x, that this was broken on PHPCS 4.x for PHP 7.2 and 7.3 since commit da0d224.
This was due to token being seen as a `T_FN` token after the initial tokenization fixing round, so the `Tokenizer::createTokenMap()` would receive the `T_FN` token and not set the parenthesis owner index.
The additional token processing run after that, would realize this is not in actual fact an arrow function and undo the retokenization (from `T_FN` back to `T_STRING`), which leaves the parentheses for this function declaration without an owner.
Fixed now by preventing the initial `T_STRING` to `T_FN` retokenization if the keyword is used in a context where the token should always be a `T_STRING`.1 parent 0e71305 commit df4a812
File tree
3 files changed
+21
-5
lines changed- src/Tokenizers
- tests/Core/Tokenizers/Tokenizer
3 files changed
+21
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2217 | 2217 | | |
2218 | 2218 | | |
2219 | 2219 | | |
| 2220 | + | |
| 2221 | + | |
2220 | 2222 | | |
2221 | 2223 | | |
2222 | 2224 | | |
| |||
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
65 | 71 | | |
66 | 72 | | |
67 | 73 | | |
| |||
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
143 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
144 | 152 | | |
145 | 153 | | |
146 | 154 | | |
| |||
276 | 284 | | |
277 | 285 | | |
278 | 286 | | |
279 | | - | |
| 287 | + | |
280 | 288 | | |
281 | 289 | | |
282 | 290 | | |
| |||
0 commit comments