function DocParser::findInitialTokenPosition

Same name in other branches
  1. 9 core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php \Drupal\Component\Annotation\Doctrine\DocParser::findInitialTokenPosition()
  2. 8.9.x core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php \Drupal\Component\Annotation\Doctrine\DocParser::findInitialTokenPosition()
  3. 11.x 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

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.