-
-
Save dgierejkiewicz/bc2815ee1c6267d2f29e74f39adb95f9 to your computer and use it in GitHub Desktop.
Evil code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PHPTokenizer_Tokenizer_PHP53To536 extends PHPTokenizer_Tokenizer_Base | |
{ | |
public function tokenize($code) { | |
@$resetErrorMsg; | |
$tokens = @token_get_all($code); | |
$error = error_get_last(); | |
try { | |
$this->checkError($error['message']); | |
$count = count($tokens); | |
for ($i = 0; $i < $count; ++$i) { | |
if (T_HALT_COMPILER === $tokens[$i][0]) { | |
$needTokens = 3; | |
for (; $i < $count; ++$i) { | |
if (!isset(self::$dropTokens[$tokens[$i][0]]) && !--$needTokens) { | |
$tokens = array_slice($tokens, 0, $i); | |
$rest = ''; | |
for (; $i < $count; ++$i) { | |
if (isset($tokens[$i][1])) { | |
$rest .= $tokens[$i][1]; | |
} else { | |
$rest .= $tokens[$i]; | |
} | |
} | |
if ('' !== $rest) { | |
$tokens[] = array(T_INLINE_HTML, $rest, -1); // TODO: -1 | |
} | |
} | |
} | |
} | |
} | |
} catch (PHPTokenizer_Error $e) { | |
// TODO: everything | |
} | |
return $tokens; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment