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

Breadcrumb

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

function PHP::resolveSimpleToken

Converts simple tokens into a format that conforms to complex tokens produced by token_get_all().

Simple tokens are tokens that are not in array form when produced from token_get_all().

Parameters

string $token The simple token to convert.:

Return value

array The new token in array format.

2 calls to PHP::resolveSimpleToken()
PHP::standardiseToken in vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php
Takes a token produced from <code>token_get_all()</code> and produces a more uniform token.
PHP::tokenize in vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php
Creates an array of tokens when given some PHP code.

File

vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php, line 3768

Class

PHP

Namespace

PHP_CodeSniffer\Tokenizers

Code

public static function resolveSimpleToken($token) {
    $newToken = [];
    switch ($token) {
        case '{':
            $newToken['type'] = 'T_OPEN_CURLY_BRACKET';
            break;
        case '}':
            $newToken['type'] = 'T_CLOSE_CURLY_BRACKET';
            break;
        case '[':
            $newToken['type'] = 'T_OPEN_SQUARE_BRACKET';
            break;
        case ']':
            $newToken['type'] = 'T_CLOSE_SQUARE_BRACKET';
            break;
        case '(':
            $newToken['type'] = 'T_OPEN_PARENTHESIS';
            break;
        case ')':
            $newToken['type'] = 'T_CLOSE_PARENTHESIS';
            break;
        case ':':
            $newToken['type'] = 'T_COLON';
            break;
        case '.':
            $newToken['type'] = 'T_STRING_CONCAT';
            break;
        case ';':
            $newToken['type'] = 'T_SEMICOLON';
            break;
        case '=':
            $newToken['type'] = 'T_EQUAL';
            break;
        case '*':
            $newToken['type'] = 'T_MULTIPLY';
            break;
        case '/':
            $newToken['type'] = 'T_DIVIDE';
            break;
        case '+':
            $newToken['type'] = 'T_PLUS';
            break;
        case '-':
            $newToken['type'] = 'T_MINUS';
            break;
        case '%':
            $newToken['type'] = 'T_MODULUS';
            break;
        case '^':
            $newToken['type'] = 'T_BITWISE_XOR';
            break;
        case '&':
            $newToken['type'] = 'T_BITWISE_AND';
            break;
        case '|':
            $newToken['type'] = 'T_BITWISE_OR';
            break;
        case '~':
            $newToken['type'] = 'T_BITWISE_NOT';
            break;
        case '<':
            $newToken['type'] = 'T_LESS_THAN';
            break;
        case '>':
            $newToken['type'] = 'T_GREATER_THAN';
            break;
        case '!':
            $newToken['type'] = 'T_BOOLEAN_NOT';
            break;
        case ',':
            $newToken['type'] = 'T_COMMA';
            break;
        case '@':
            $newToken['type'] = 'T_ASPERAND';
            break;
        case '$':
            $newToken['type'] = 'T_DOLLAR';
            break;
        case '`':
            $newToken['type'] = 'T_BACKTICK';
            break;
        default:
            $newToken['type'] = 'T_NONE';
            break;
    }
    
    //end switch
    $newToken['code'] = constant($newToken['type']);
    $newToken['content'] = $token;
    self::$resolveTokenCache[$token] = $newToken;
    return $newToken;
}
RSS feed
Powered by Drupal