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

Breadcrumb

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

class Token

Same name in this branch
  1. 11.1.x vendor/theseer/tokenizer/src/Token.php \TheSeer\Tokenizer\Token
  2. 11.1.x vendor/doctrine/lexer/src/Token.php \Doctrine\Common\Lexer\Token
  3. 11.1.x vendor/nikic/php-parser/lib/PhpParser/Token.php \PhpParser\Token
  4. 11.1.x vendor/twig/twig/src/Token.php \Twig\Token
  5. 11.1.x vendor/symfony/css-selector/Parser/Token.php \Symfony\Component\CssSelector\Parser\Token
  6. 11.1.x core/lib/Drupal/Core/Render/Element/Token.php \Drupal\Core\Render\Element\Token
  7. 11.1.x core/lib/Drupal/Core/Utility/Token.php \Drupal\Core\Utility\Token

A token emitted by the tokenizer.

@author Marco Marchiò <marco.mm89@gmail.com>

Hierarchy

  • class \Peast\Syntax\Token implements \Peast\Syntax\JSONSerializable

Expanded class hierarchy of Token

2 files declare their use of Token
Parser.php in vendor/mck89/peast/lib/Peast/Syntax/JSX/Parser.php
Scanner.php in vendor/mck89/peast/lib/Peast/Syntax/JSX/Scanner.php
15 string references to 'Token'
AbstractPatternSniff::createTokenPattern in vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php
Creates a token pattern.
AbstractPatternSniff::getPatternTokenTypes in vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php
Returns the token types that the specified pattern is checking for.
AbstractPatternSniff::processPattern in vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php
Processes the pattern and verifies the code at $stackPtr.
BatchStorage::schemaDefinition in core/lib/Drupal/Core/Batch/BatchStorage.php
Defines the schema for the batch table.
ContentTranslationHandler::entityFormSharedElements in core/modules/content_translation/src/ContentTranslationHandler.php
Process callback: determines which elements get clue in the form.

... See full list

File

vendor/mck89/peast/lib/Peast/Syntax/Token.php, line 17

Namespace

Peast\Syntax
View source
class Token implements \JSONSerializable {
    
    //Type constants
    
    /**
     * Boolean literal
     */
    const TYPE_BOOLEAN_LITERAL = "Boolean";
    
    /**
     * Identifier
     */
    const TYPE_IDENTIFIER = "Identifier";
    
    /**
     * Private identifier
     */
    const TYPE_PRIVATE_IDENTIFIER = "PrivateIdentifier";
    
    /**
     * Keyword
     */
    const TYPE_KEYWORD = "Keyword";
    
    /**
     * Null literal
     */
    const TYPE_NULL_LITERAL = "Null";
    
    /**
     * Numeric literal
     */
    const TYPE_NUMERIC_LITERAL = "Numeric";
    
    /**
     * BigInt literal
     */
    const TYPE_BIGINT_LITERAL = "BigInt";
    
    /**
     * Punctuator
     */
    const TYPE_PUNCTUATOR = "Punctuator";
    
    //This constant is kept only for backward compatibility since it was
    
    //first written with a typo
    const TYPE_PUNCTUTATOR = "Punctuator";
    
    /**
     * String literal
     */
    const TYPE_STRING_LITERAL = "String";
    
    /**
     * Regular expression
     */
    const TYPE_REGULAR_EXPRESSION = "RegularExpression";
    
    /**
     * Template
     */
    const TYPE_TEMPLATE = "Template";
    
    /**
     * Comment
     */
    const TYPE_COMMENT = "Comment";
    
    /**
     * JSX text
     */
    const TYPE_JSX_TEXT = "JSXText";
    
    /**
     * JSX identifier
     */
    const TYPE_JSX_IDENTIFIER = "JSXIdentifier";
    
    /**
     * Tokens' type that is one of the type constants
     * 
     * @var string 
     */
    public $type;
    
    /**
     * Token's value
     * 
     * @var string 
     */
    public $value;
    
    /**
     * Token's location in the source code
     * 
     * @var SourceLocation 
     */
    public $location;
    
    /**
     * Class constructor
     * 
     * @param string $type  Token's type
     * @param string $value Token's value
     */
    public function __construct($type, $value) {
        $this->type = $type;
        $this->value = $value;
        $this->location = new SourceLocation();
    }
    
    /**
     * Returns the token's type
     *
     * @return string
     */
    public function getType() {
        return $this->type;
    }
    
    /**
     * Returns the token's value
     *
     * @return string
     */
    public function getValue() {
        return $this->value;
    }
    
    /**
     * Returns the token's location in the source code
     * 
     * @return SourceLocation
     */
    public function getLocation() {
        return $this->location;
    }
    
    /**
     * Sets the start position of the token in the source code
     * 
     * @param Position $position Start position
     * 
     * @return $this
     */
    public function setStartPosition(Position $position) {
        $this->location->start = $position;
        return $this;
    }
    
    /**
     * Sets the end position of the token in the source code
     * 
     * @param Position $position End position
     * 
     * @return $this
     */
    public function setEndPosition(Position $position) {
        $this->location->end = $position;
        return $this;
    }
    
    /**
     * Returns a serializable version of the node
     * 
     * @return array
     */
    public function jsonSerialize() {
        return array(
            "type" => $this->type,
            "value" => $this->value,
            "location" => $this->location,
        );
    }

}

Members

Title Sort descending Modifiers Object type Summary
Token::$location public property Token&#039;s location in the source code
Token::$type public property Tokens&#039; type that is one of the type constants
Token::$value public property Token&#039;s value
Token::getLocation public function Returns the token&#039;s location in the source code
Token::getType public function Returns the token&#039;s type
Token::getValue public function Returns the token&#039;s value
Token::jsonSerialize public function Returns a serializable version of the node
Token::setEndPosition public function Sets the end position of the token in the source code
Token::setStartPosition public function Sets the start position of the token in the source code
Token::TYPE_BIGINT_LITERAL constant BigInt literal
Token::TYPE_BOOLEAN_LITERAL constant Boolean literal
Token::TYPE_COMMENT constant Comment
Token::TYPE_IDENTIFIER constant Identifier
Token::TYPE_JSX_IDENTIFIER constant JSX identifier
Token::TYPE_JSX_TEXT constant JSX text
Token::TYPE_KEYWORD constant Keyword
Token::TYPE_NULL_LITERAL constant Null literal
Token::TYPE_NUMERIC_LITERAL constant Numeric literal
Token::TYPE_PRIVATE_IDENTIFIER constant Private identifier
Token::TYPE_PUNCTUATOR constant Punctuator
Token::TYPE_PUNCTUTATOR constant
Token::TYPE_REGULAR_EXPRESSION constant Regular expression
Token::TYPE_STRING_LITERAL constant String literal
Token::TYPE_TEMPLATE constant Template
Token::__construct public function Class constructor

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal