Automattic\WooCommerce\Vendor\Symfony\Polyfill\Php80

PhpToken::tokenizepublic staticWC 1.0

Method of the class: PhpToken{}

No Hooks.

Returns

list.

Usage

$result = PhpToken::tokenize( $code, $flags ): array;
$code(string) (required)
.
$flags(int)
.

PhpToken::tokenize() code WC 10.5.0

public static function tokenize(string $code, int $flags = 0): array
{
    $line = 1;
    $position = 0;
    $tokens = token_get_all($code, $flags);
    foreach ($tokens as $index => $token) {
        if (\is_string($token)) {
            $id = \ord($token);
            $text = $token;
        } else {
            [$id, $text, $line] = $token;
        }
        $tokens[$index] = new static($id, $text, $line, $position);
        $position += \strlen($text);
    }

    return $tokens;
}