Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TokenPolyfill.php

function TokenPolyfill::init

Initialize private static state needed by tokenize().

1 call to TokenPolyfill::init()
TokenPolyfill::tokenize in vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php
Tokenize the given source code and return an array of tokens.

File

vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php, line 218

Class

TokenPolyfill
This is a polyfill for the PhpToken class introduced in PHP 8.0. We do not actually polyfill PhpToken, because composer might end up picking a different polyfill implementation, which does not meet our requirements.

Namespace

PhpParser\Internal

Code

private static function init() : void {
    if (isset(self::$identifierTokens)) {
        return;
    }
    // Based on semi_reserved production.
    self::$identifierTokens = \array_fill_keys([
        \T_STRING,
        \T_STATIC,
        \T_ABSTRACT,
        \T_FINAL,
        \T_PRIVATE,
        \T_PROTECTED,
        \T_PUBLIC,
        \T_READONLY,
        \T_INCLUDE,
        \T_INCLUDE_ONCE,
        \T_EVAL,
        \T_REQUIRE,
        \T_REQUIRE_ONCE,
        \T_LOGICAL_OR,
        \T_LOGICAL_XOR,
        \T_LOGICAL_AND,
        \T_INSTANCEOF,
        \T_NEW,
        \T_CLONE,
        \T_EXIT,
        \T_IF,
        \T_ELSEIF,
        \T_ELSE,
        \T_ENDIF,
        \T_ECHO,
        \T_DO,
        \T_WHILE,
        \T_ENDWHILE,
        \T_FOR,
        \T_ENDFOR,
        \T_FOREACH,
        \T_ENDFOREACH,
        \T_DECLARE,
        \T_ENDDECLARE,
        \T_AS,
        \T_TRY,
        \T_CATCH,
        \T_FINALLY,
        \T_THROW,
        \T_USE,
        \T_INSTEADOF,
        \T_GLOBAL,
        \T_VAR,
        \T_UNSET,
        \T_ISSET,
        \T_EMPTY,
        \T_CONTINUE,
        \T_GOTO,
        \T_FUNCTION,
        \T_CONST,
        \T_RETURN,
        \T_PRINT,
        \T_YIELD,
        \T_LIST,
        \T_SWITCH,
        \T_ENDSWITCH,
        \T_CASE,
        \T_DEFAULT,
        \T_BREAK,
        \T_ARRAY,
        \T_CALLABLE,
        \T_EXTENDS,
        \T_IMPLEMENTS,
        \T_NAMESPACE,
        \T_TRAIT,
        \T_INTERFACE,
        \T_CLASS,
        \T_CLASS_C,
        \T_TRAIT_C,
        \T_FUNC_C,
        \T_METHOD_C,
        \T_LINE,
        \T_FILE,
        \T_DIR,
        \T_NS_C,
        \T_HALT_COMPILER,
        \T_FN,
        \T_MATCH,
    ], true);
}
RSS feed
Powered by Drupal