Skip to content

Commit

Permalink
Merge pull request #99 from doctrine/fix/#70-allow-tab-character-befo…
Browse files Browse the repository at this point in the history
…re-first-annotation-in-docblock

Fix - #70 - allow tab character before first annotation in docblock
  • Loading branch information
Ocramius committed Oct 24, 2016
2 parents dc44263 + ae36826 commit 58e3ca6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Doctrine/Common/Annotations/DocParser.php
Expand Up @@ -368,8 +368,9 @@ private function findInitialTokenPosition($input)
// search for first valid annotation
while (($pos = strpos($input, '@', $pos)) !== false) {
$preceding = substr($input, $pos - 1, 1);
// if the @ is preceded by a space or * it is valid
if ($pos === 0 || $preceding === ' ' || $preceding === '*') {

// if the @ is preceded by a space, a tab or * it is valid
if ($pos === 0 || $preceding === ' ' || $preceding === '*' || $preceding === "\t") {
return $pos;
}

Expand Down
14 changes: 14 additions & 0 deletions tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
Expand Up @@ -1282,6 +1282,20 @@ public function testTrailingCommaIsAllowed()
$this->assertEquals(array('Foo', 'Bar'), $annots[0]->value);
}

public function testTabPrefixIsAllowed()
{
$docblock = <<<DOCBLOCK
/**
* @Name
*/
DOCBLOCK;

$parser = $this->createTestParser();
$result = $parser->parse($docblock);
$this->assertCount(1, $result);
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $result[0]);
}

public function testDefaultAnnotationValueIsNotOverwritten()
{
$parser = $this->createTestParser();
Expand Down

0 comments on commit 58e3ca6

Please sign in to comment.