You are here

private function DocParser::findInitialTokenPosition 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::findInitialTokenPosition()
  2. 10 core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php \Drupal\Component\Annotation\Doctrine\DocParser::findInitialTokenPosition()

Finds the first valid annotation

Parameters

string $input The docblock string to parse:

Return value

int|null

1 call to DocParser::findInitialTokenPosition()
DocParser::parse in core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php
Parses the given docblock string for annotations.

File

core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php, line 348
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 findInitialTokenPosition($input) {
  $pos = 0;

  // search for first valid annotation
  while (($pos = strpos($input, '@', $pos)) !== false) {

    // if the @ is preceded by a space or * it is valid
    if ($pos === 0 || $input[$pos - 1] === ' ' || $input[$pos - 1] === '*') {
      return $pos;
    }
    $pos++;
  }
  return null;
}