Commit b00f2e4
committed
Tokenizer/PHP: change tokenization of long PHP open tags
... to no longer include whitespace (single space/new line).
This ensures the tokenization of all PHP open tags - long open tags `<?php`, short open tags `<?` and short open echo tags `<?=` - is consistent and should simplify handling of open tag tokens in sniffs and lower the cognitive load of sniff developers.
As per the detailed proposal in ticket 593.
Includes extensive unit tests, both ensuring the correct tokenization, as well as safeguarding consistency across the different open tags.
Includes the following additional updates to maintain the pre-existing behaviour:
* `AbstractPatternSniff`
The `AbstractPatternSniff` tokenizes an arbitrary code pattern to determine the token pattern to sniff for. This tokenization now to takes the change in the PHP open tag tokenization into account.
* `Generic/EmptyPHPStatement` - replace now redundant special condition for PHP open tags + update "fixed" file for improved output + add extra test.
* `PSR12/OpenTag` - allow for the changed tokenization.
The updated code also means that the fixer will no longer leave stray whitespace behind after a PHP open tag.
* `Squiz/CommentedOutCode` - allow for the changed tokenization.
* `Squiz/EmbeddedPhp` - code simplification.
* `FindStartOfStatementTest` - fixed token offset expectation as there is now an extra whitespace token.
* `ReplaceTabsInTokenMiscTest` - updated target finding
Fixes 5931 parent 268d6ad commit b00f2e4
File tree
15 files changed
+631
-41
lines changed- src
- Sniffs
- Standards
- Generic
- Sniffs/CodeAnalysis
- Tests/CodeAnalysis
- PSR12
- Sniffs/Files
- Tests/Files
- Squiz/Sniffs/PHP
- Tokenizers
- tests/Core
- File
- Tokenizers
- PHP
- Tokenizer
15 files changed
+631
-41
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
915 | 915 | | |
916 | 916 | | |
917 | 917 | | |
918 | | - | |
| 918 | + | |
919 | 919 | | |
920 | 920 | | |
921 | 921 | | |
922 | 922 | | |
923 | | - | |
| 923 | + | |
924 | 924 | | |
925 | 925 | | |
926 | 926 | | |
| |||
Lines changed: 7 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
126 | 120 | | |
127 | 121 | | |
128 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
129 | 125 | | |
130 | 126 | | |
131 | 127 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
| 59 | + | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
68 | 75 | | |
| 76 | + | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
200 | 201 | | |
201 | | - | |
| 202 | + | |
| 203 | + | |
202 | 204 | | |
203 | 205 | | |
204 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
| 350 | + | |
360 | 351 | | |
361 | 352 | | |
362 | 353 | | |
| |||
366 | 357 | | |
367 | 358 | | |
368 | 359 | | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
| 360 | + | |
| 361 | + | |
373 | 362 | | |
374 | 363 | | |
375 | | - | |
| 364 | + | |
376 | 365 | | |
377 | 366 | | |
378 | 367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
823 | 823 | | |
824 | 824 | | |
825 | 825 | | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
826 | 879 | | |
827 | 880 | | |
828 | 881 | | |
| |||
0 commit comments