You are here

private function DocParser::syntaxError in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php \Drupal\Component\Annotation\Doctrine\DocParser::syntaxError()

Generates a new syntax error.

Parameters

string $expected Expected string.:

array|null $token Optional token.:

Return value

void

Throws

AnnotationException

5 calls to DocParser::syntaxError()
DocParser::Identifier in core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php
Identifier ::= string
DocParser::match in core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php
Attempts to match the given token with the current lookahead token. If they match, updates the lookahead token; otherwise raises a syntax error.
DocParser::matchAny in core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php
Attempts to match the current lookahead token with any of the given tokens.
DocParser::PlainValue in core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php
PlainValue ::= integer | string | float | boolean | Array | Annotation
DocParser::Values in core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php
Values ::= Array | Value {"," Value}* [","]

File

core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php, line 411
This class is a near-copy of Doctrine\Common\Annotations\DocParser, which is part of the Doctrine project: <http://www.doctrine-project.org>. It was copied from version 1.2.7.

Class

DocParser
A parser for docblock annotations.

Namespace

Drupal\Component\Annotation\Doctrine

Code

private function syntaxError($expected, $token = null) {
  if ($token === null) {
    $token = $this->lexer->lookahead;
  }
  $message = sprintf('Expected %s, got ', $expected);
  $message .= $this->lexer->lookahead === null ? 'end of string' : sprintf("'%s' at position %s", $token['value'], $token['position']);
  if (strlen($this->context)) {
    $message .= ' in ' . $this->context;
  }
  $message .= '.';
  throw AnnotationException::syntaxError($message);
}