Lines Matching refs:tokens
19 public function emulate(string $code, array $tokens): array { argument
25 for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
26 $token = $tokens[$i];
27 if (isset($map[$token->id]) && $i + 3 < $c && $tokens[$i + 1]->text === '(' &&
28 $tokens[$i + 2]->id === \T_STRING && \strtolower($tokens[$i + 2]->text) === 'set' &&
29 $tokens[$i + 3]->text === ')' &&
30 $this->isKeywordContext($tokens, $i)
32 array_splice($tokens, $i, 4, [
34 $map[$token->id], $token->text . '(' . $tokens[$i + 2]->text . ')',
41 return $tokens;
44 public function reverseEmulate(string $code, array $tokens): array { argument
50 for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
51 $token = $tokens[$i];
57 array_splice($tokens, $i, 1, [
68 return $tokens;
71 /** @param Token[] $tokens */
72 protected function isKeywordContext(array $tokens, int $pos): bool { argument
73 $prevToken = $this->getPreviousNonSpaceToken($tokens, $pos);
81 /** @param Token[] $tokens */
82 private function getPreviousNonSpaceToken(array $tokens, int $start): ?Token { argument
84 if ($tokens[$i]->id === T_WHITESPACE) {
88 return $tokens[$i];