Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - #70 - allow tab character before first annotation in docblock #99

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/Doctrine/Common/Annotations/DocParser.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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