Skip to content

Commit df0b17c

Browse files
committed
Fixed bug #2431 : Use function/const not tokenized as T_STRING when preceded by comment
1 parent 1d06964 commit df0b17c

File tree

5 files changed

+54
-38
lines changed

5 files changed

+54
-38
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
105105
- Fixed bug #2393 : The gitmodified filter will infinitely loop when encountering deleted file paths
106106
-- Thanks to Lucas Manzke for the patch
107107
- Fixed bug #2396 : Generic.WhiteSpace.ScopeIndent incorrect error when multi-line IF condition mixed with HTML
108+
- Fixed bug #2431 : Use function/const not tokenized as T_STRING when preceded by comment
108109
</notes>
109110
<contents>
110111
<dir name="/">

src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
*/
55
use Foo\{function bar, const BAZ};
66

7+
use /* comment */ function bar\math\{
8+
Msin,
9+
level\Mcos as BarCos,
10+
Mcosh,
11+
};
12+
713
include $blah;
814

915

src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc.fixed

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
*/
55
use Foo\{function bar, const BAZ};
66

7+
use /* comment */ function bar\math\{
8+
Msin,
9+
level\Mcos as BarCos,
10+
Mcosh,
11+
};
12+
713
include $blah;
814

915

src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,51 +30,51 @@ public function getErrorList($testFile='')
3030
switch ($testFile) {
3131
case 'FunctionSpacingUnitTest.1.inc':
3232
return [
33-
20 => 1,
34-
29 => 1,
35-
38 => 1,
36-
45 => 1,
37-
49 => 1,
33+
26 => 1,
34+
35 => 1,
35+
44 => 1,
36+
51 => 1,
3837
55 => 1,
39-
58 => 1,
40-
60 => 1,
41-
75 => 1,
42-
94 => 1,
43-
105 => 1,
44-
107 => 1,
45-
113 => 2,
46-
135 => 1,
47-
154 => 1,
48-
167 => 2,
49-
184 => 1,
50-
218 => 2,
51-
275 => 1,
52-
276 => 1,
53-
289 => 1,
54-
291 => 1,
38+
61 => 1,
39+
64 => 1,
40+
66 => 1,
41+
81 => 1,
42+
100 => 1,
43+
111 => 1,
44+
113 => 1,
45+
119 => 2,
46+
141 => 1,
47+
160 => 1,
48+
173 => 2,
49+
190 => 1,
50+
224 => 2,
51+
281 => 1,
52+
282 => 1,
53+
295 => 1,
5554
297 => 1,
56-
321 => 1,
57-
323 => 1,
58-
332 => 1,
55+
303 => 1,
56+
327 => 1,
57+
329 => 1,
5958
338 => 1,
60-
339 => 1,
61-
348 => 2,
62-
349 => 1,
63-
350 => 1,
59+
344 => 1,
60+
345 => 1,
6461
354 => 2,
6562
355 => 1,
6663
356 => 1,
67-
379 => 1,
68-
393 => 1,
69-
405 => 2,
70-
412 => 2,
71-
420 => 2,
72-
426 => 1,
73-
431 => 1,
64+
360 => 2,
65+
361 => 1,
66+
362 => 1,
67+
385 => 1,
68+
399 => 1,
69+
411 => 2,
70+
418 => 2,
71+
426 => 2,
7472
432 => 1,
75-
436 => 2,
73+
437 => 1,
7674
438 => 1,
77-
443 => 1,
75+
442 => 2,
76+
444 => 1,
77+
449 => 1,
7878
];
7979

8080
case 'FunctionSpacingUnitTest.2.inc':

src/Tokenizers/PHP.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,9 @@ protected function tokenize($string)
504504
echo ": $type => $content";
505505
}//end if
506506

507-
if ($newStackPtr > 0 && $finalTokens[($newStackPtr - 1)]['code'] !== T_WHITESPACE) {
507+
if ($newStackPtr > 0
508+
&& isset(Util\Tokens::$emptyTokens[$finalTokens[($newStackPtr - 1)]['code']]) === false
509+
) {
508510
$lastNotEmptyToken = ($newStackPtr - 1);
509511
}
510512

@@ -1281,6 +1283,7 @@ function return types. We want to keep the parenthesis map clean,
12811283
T_NAMESPACE => true,
12821284
T_PAAMAYIM_NEKUDOTAYIM => true,
12831285
];
1286+
12841287
if (isset($context[$finalTokens[$lastNotEmptyToken]['code']]) === true) {
12851288
// Special case for syntax like: return new self
12861289
// where self should not be a string.

0 commit comments

Comments
 (0)