Home
last modified time | relevance | path

Searched refs:tokens (Results 1 – 25 of 26) sorted by relevance

12

/PHP-Parser/lib/PhpParser/Internal/
H A DTokenStream.php14 private array $tokens; variable in PhpParser\\Internal\\TokenStream
24 $this->tokens = $tokens;
62 $tokens = $this->tokens;
87 $tokens = $this->tokens;
103 $tokens = $this->tokens;
121 $tokens = $this->tokens;
144 $tokens = $this->tokens;
160 $tokens = $this->tokens;
171 $tokens = $this->tokens;
189 $tokens = $this->tokens;
[all …]
H A DTokenPolyfill.php127 $tokens = [];
138 $tokens[] = new static(\ord('"'), $token, $line, $pos);
141 $tokens[] = new static(\ord($token), $token, $line, $pos);
154 $tokens[] = new static($id, $text, $line, $pos);
163 $tokens[] = new static(\T_WHITESPACE, $trailingNewline, $line, $pos);
202 $tokens[] = new static($id, $newText, $line, $pos);
209 $tokens[] = new static($id, $text, $line, $pos);
214 return $tokens;
/PHP-Parser/lib/PhpParser/Lexer/TokenEmulator/
H A DKeywordEmulator.php15 /** @param Token[] $tokens */
17 $prevToken = $this->getPreviousNonSpaceToken($tokens, $pos);
25 public function emulate(string $code, array $tokens): array { argument
27 foreach ($tokens as $i => $token) {
29 && $this->isKeywordContext($tokens, $i)) {
34 return $tokens;
37 /** @param Token[] $tokens */
40 if ($tokens[$i]->id === T_WHITESPACE) {
44 return $tokens[$i];
52 foreach ($tokens as $token) {
[all …]
H A DAsymmetricVisibilityTokenEmulator.php26 $token = $tokens[$i];
28 $tokens[$i + 2]->id === \T_STRING && \strtolower($tokens[$i + 2]->text) === 'set' &&
29 $tokens[$i + 3]->text === ')' &&
32 array_splice($tokens, $i, 4, [
41 return $tokens;
51 $token = $tokens[$i];
57 array_splice($tokens, $i, 1, [
68 return $tokens;
71 /** @param Token[] $tokens */
81 /** @param Token[] $tokens */
[all …]
H A DExplicitOctalEmulator.php17 public function emulate(string $code, array $tokens): array { argument
18 for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
19 $token = $tokens[$i];
21 isset($tokens[$i + 1]) && $tokens[$i + 1]->id == \T_STRING &&
22 preg_match('/[oO][0-7]+(?:_[0-7]+)*/', $tokens[$i + 1]->text)
24 $tokenKind = $this->resolveIntegerOrFloatToken($tokens[$i + 1]->text);
25 array_splice($tokens, $i, 2, [
26 new Token($tokenKind, '0' . $tokens[$i + 1]->text, $token->line, $token->pos),
31 return $tokens;
41 public function reverseEmulate(string $code, array $tokens): array { argument
[all …]
H A DReadonlyTokenEmulator.php20 protected function isKeywordContext(array $tokens, int $pos): bool { argument
21 if (!parent::isKeywordContext($tokens, $pos)) {
25 return !(isset($tokens[$pos + 1]) &&
26 ($tokens[$pos + 1]->text === '(' ||
27 ($tokens[$pos + 1]->id === \T_WHITESPACE &&
28 isset($tokens[$pos + 2]) &&
29 $tokens[$pos + 2]->text === '(')));
H A DNullsafeTokenEmulator.php17 public function emulate(string $code, array $tokens): array { argument
20 for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
21 $token = $tokens[$i];
22 …if ($token->text === '?' && isset($tokens[$i + 1]) && $tokens[$i + 1]->id === \T_OBJECT_OPERATOR) {
23 array_splice($tokens, $i, 2, [
31 if ($token->id === \T_ENCAPSED_AND_WHITESPACE && isset($tokens[$i - 1])
32 && $tokens[$i - 1]->id === \T_VARIABLE
47 array_splice($tokens, $i, 1, $replacement);
53 return $tokens;
56 public function reverseEmulate(string $code, array $tokens): array { argument
[all …]
H A DAttributeEmulator.php17 public function emulate(string $code, array $tokens): array { argument
20 for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
21 $token = $tokens[$i];
22 if ($token->text === '#' && isset($tokens[$i + 1]) && $tokens[$i + 1]->text === '[') {
23 array_splice($tokens, $i, 2, [
31 return $tokens;
34 public function reverseEmulate(string $code, array $tokens): array { argument
36 return $tokens;
H A DEnumTokenEmulator.php20 protected function isKeywordContext(array $tokens, int $pos): bool { argument
21 return parent::isKeywordContext($tokens, $pos)
22 && isset($tokens[$pos + 2])
23 && $tokens[$pos + 1]->id === \T_WHITESPACE
24 && $tokens[$pos + 2]->id === \T_STRING;
H A DTokenEmulator.php15 * @param Token[] $tokens Original tokens
18 abstract public function emulate(string $code, array $tokens): array; argument
21 * @param Token[] $tokens Original tokens
24 abstract public function reverseEmulate(string $code, array $tokens): array; argument
H A DReverseEmulator.php26 public function emulate(string $code, array $tokens): array { argument
27 return $this->emulator->reverseEmulate($code, $tokens);
30 public function reverseEmulate(string $code, array $tokens): array { argument
31 return $this->emulator->emulate($code, $tokens);
H A DReadonlyFunctionTokenEmulator.php27 public function reverseEmulate(string $code, array $tokens): array { argument
29 return $tokens;
/PHP-Parser/lib/PhpParser/
H A DLexer.php31 $tokens = @Token::tokenize($code);
32 $this->postprocessTokens($tokens, $errorHandler);
38 return $tokens;
76 $numTokens = \count($tokens);
79 $tokens[] = new Token(0, "\0", 1, 0);
84 $token = $tokens[$i];
91 while (isset($tokens[$next]) && $tokens[$next]->id === \T_WHITESPACE) {
94 $followedByVarOrVarArg = isset($tokens[$next]) &&
95 $tokens[$next]->is([\T_VARIABLE, \T_ELLIPSIS]);
103 $lastToken = $tokens[$numTokens - 1];
[all …]
H A DParserAbstract.php134 protected array $tokens; variable in PhpParser\\ParserAbstract
216 return $this->tokens;
480 $startToken = $this->tokens[$tokenStartPos];
481 $afterEndToken = $this->tokens[$tokenEndPos + 1];
498 if ($tokenPos < \count($this->tokens) - 1) {
503 $token = $this->tokens[$tokenPos];
905 $token = $this->tokens[$tokenPos];
949 $nextToken = $this->tokens[$this->tokenPos + 1];
950 $this->tokenPos = \count($this->tokens) - 2;
958 $token = $this->tokens[$tokenPos];
[all …]
/PHP-Parser/lib/PhpParser/NodeVisitor/
H A DCommentAnnotatingVisitor.php14 private array $tokens; variable in PhpParser\\NodeVisitor\\CommentAnnotatingVisitor
21 * @param Token[] $tokens Token array
23 public function __construct(array $tokens) { argument
24 $this->tokens = $tokens;
28 foreach ($tokens as $i => $token) {
47 $token = $this->tokens[$pos];
/PHP-Parser/lib/PhpParser/Lexer/
H A DEmulative.php84 $tokens = parent::tokenize($code, $collector);
86 $tokens = $this->fixupTokens($tokens);
97 $tokens = $emulator->emulate($code, $tokens);
100 return $tokens;
125 private function fixupTokens(array $tokens): array { argument
127 return $tokens;
137 for ($i = 0, $c = \count($tokens); $i < $c; $i++) {
138 $token = $tokens[$i];
149 array_splice($tokens, $i, 1, []);
189 return $tokens;
/PHP-Parser/tools/fuzzing/
H A Dtarget.php39 private $tokens; variable in AnonymousClass0557d2a90100
42 public function setTokens(array $tokens): void { argument
43 $this->tokens = $tokens;
89 $this->tokens[$node->uses[0]->name->getStartTokenPos()]->is(\T_NAME_FULLY_QUALIFIED)
94 $this->tokens[$node->prefix->getStartTokenPos()]->is(\T_NAME_FULLY_QUALIFIED)
/PHP-Parser/doc/component/
H A DLexer.markdown4 The lexer is responsible for providing tokens to the parser. Typical use of the library does not re…
45 /** @var int Token ID, either T_* or ord($char) for single-character tokens. */
65 positioning attributes to allow mapping nodes back to lines, tokens or file offsets:
83 > tokens. However, the general idea behind the example still applies in other cases.
90 /** @param PhpParser\Token[] $tokens */
91 function isDeclaredUsingVar(array $tokens, PhpParser\Node\Stmt\Property $prop) {
93 return $tokens[$i]->id === T_VAR;
102 private $tokens;
103 public function setTokens(array $tokens) {
104 $this->tokens = $tokens;
[all …]
/PHP-Parser/test/PhpParser/
H A DLexerTest.php60 $tokens = $lexer->tokenize($code);
61 foreach ($tokens as $token) {
/PHP-Parser/test/PhpParser/Lexer/
H A DEmulativeTest.php121 private function assertSameTokens(array $expectedTokens, array $tokens): void { argument
123 foreach ($tokens as $token) {
/PHP-Parser/doc/
H A D0_Introduction.markdown19 all the different syntaxes from a stream of tokens.
44 As the parser is based on the tokens returned by `token_get_all` (which is only able to lex the PHP
45 version it runs on), additionally a wrapper for emulating tokens from newer versions is provided.
/PHP-Parser/
H A DCONTRIBUTING.md17 1. If necessary, add emulation support for new tokens.
H A DUPGRADE-2.0.md51 `Parser\Multiple`. Parser tokens are now defined in `Parser\Tokens`. If you use the `ParserFactory`
H A DCHANGELOG.md79 * Added check to detect use of PHP-Parser with libraries that define `T_*` compatibility tokens
140 there is a single method `tokenize()` returning the tokens.
348 * Fixed compatibility with PHP 8.1. `&` tokens are now canonicalized to the
349 `T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG` and `T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG` tokens
443 * Improved compatibility with other libraries that use forward compatibility defines for PHP tokens.
500 `T_NAME_*` tokens, using emulationg on older PHP versions. Full support for reserved keywords
514 * Comment tokens now always follow the PHP 8 interpretation, and do not include trailing
1007 * The emulative lexer now directly postprocesses tokens, instead of using `~__EMU__~` sequences.
H A DUPGRADE-3.0.md157 * The emulative lexer now directly postprocesses tokens, instead of using `~__EMU__~` sequences.

Completed in 35 milliseconds

12