Skip to content

Commit b363a7c

Browse files
author
MarkBaker
committed
Move code block down after the initial comment processing logic.
Check for lower- or upper-case 'o'. Don't adjust $token and $tokens variables; but set the token in $finalTokens, and adjust pointers.
1 parent a0bc9d6 commit b363a7c

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

src/Tokenizers/PHP.php

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -553,23 +553,6 @@ protected function tokenize($string)
553553
$lastNotEmptyToken = ($newStackPtr - 1);
554554
}
555555

556-
/*
557-
For Explicit Octal Notation prior to PHP 8.1 we need to combine the
558-
T_NUMBER and T_STRING token values into a single token value, and
559-
then ignore the T_STRING token.
560-
*/
561-
562-
if (PHP_VERSION_ID < 80100
563-
&& $tokenIsArray === true && $token[1] === '0'
564-
&& (isset($tokens[($stackPtr + 1)]) === true
565-
&& is_array($tokens[($stackPtr + 1)]) === true
566-
&& $tokens[($stackPtr + 1)][0] === T_STRING
567-
&& $tokens[($stackPtr + 1)][1][0] === 'o')
568-
) {
569-
$token[1] .= $tokens[($stackPtr + 1)][1];
570-
$tokens[($stackPtr + 1)] = '';
571-
}
572-
573556
/*
574557
If we are using \r\n newline characters, the \r and \n are sometimes
575558
split over two tokens. This normally occurs after comments. We need
@@ -663,6 +646,29 @@ protected function tokenize($string)
663646
}//end if
664647
}//end if
665648

649+
/*
650+
For Explicit Octal Notation prior to PHP 8.1 we need to combine the
651+
T_LNUMBER and T_STRING token values into a single token value, and
652+
then ignore the T_STRING token.
653+
*/
654+
655+
if (PHP_VERSION_ID < 80100
656+
&& $tokenIsArray === true && $token[1] === '0'
657+
&& (isset($tokens[($stackPtr + 1)]) === true
658+
&& is_array($tokens[($stackPtr + 1)]) === true
659+
&& $tokens[($stackPtr + 1)][0] === T_STRING
660+
&& strtolower($tokens[($stackPtr + 1)][1][0]) === 'o')
661+
) {
662+
$finalTokens[$newStackPtr] = [
663+
'code' => T_LNUMBER,
664+
'type' => 'T_LNUMBER',
665+
'content' => $token[1] .= $tokens[($stackPtr + 1)][1],
666+
];
667+
$stackPtr++;
668+
$newStackPtr++;
669+
continue;
670+
}
671+
666672
/*
667673
PHP 8.1 introduced two dedicated tokens for the & character.
668674
Retokenizing both of these to T_BITWISE_AND, which is the

0 commit comments

Comments
 (0)