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

Breadcrumb

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

function AbstractLexer::getLiteral

Gets the literal for a given token.

Parameters

T $token:

Return value

int|string

File

vendor/doctrine/lexer/src/AbstractLexer.php, line 288

Class

AbstractLexer
Base class for writing simple lexers, i.e. for creating small DSLs.

Namespace

Doctrine\Common\Lexer

Code

public function getLiteral($token) {
    if ($token instanceof UnitEnum) {
        return get_class($token) . '::' . $token->name;
    }
    $className = static::class;
    $reflClass = new ReflectionClass($className);
    $constants = $reflClass->getConstants();
    foreach ($constants as $name => $value) {
        if ($value === $token) {
            return $className . '::' . $name;
        }
    }
    return $token;
}

API Navigation

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