function AttributeEmulator::emulate
Overrides TokenEmulator::emulate
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ Lexer/ TokenEmulator/ AttributeEmulator.php, line 17
Class
Namespace
PhpParser\Lexer\TokenEmulatorCode
public function emulate(string $code, array $tokens) : array {
// We need to manually iterate and manage a count because we'll change
// the tokens array on the way.
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
$token = $tokens[$i];
if ($token->text === '#' && isset($tokens[$i + 1]) && $tokens[$i + 1]->text === '[') {
array_splice($tokens, $i, 2, [
new Token(\T_ATTRIBUTE, '#[', $token->line, $token->pos),
]);
$c--;
continue;
}
}
return $tokens;
}