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

[DCOM-86] Fix DCOM-86 #90

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/Doctrine/Common/Annotations/DocParser.php
Expand Up @@ -552,6 +552,9 @@ private function Annotation()
$name .= '\\'.$this->lexer->token['value'];
}

if (isset($this->ignoredAnnotationNames[$name])) {
return false;
}
// only process names which are not fully qualified, yet
// fully qualified names must start with a \
$originalName = $name;
Expand Down Expand Up @@ -582,7 +585,7 @@ private function Annotation()
}

if (!$found) {
if ($this->ignoreNotImportedAnnotations || isset($this->ignoredAnnotationNames[$name])) {
if ($this->ignoreNotImportedAnnotations) {
return false;
}

Expand Down
22 changes: 22 additions & 0 deletions tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
Expand Up @@ -848,6 +848,28 @@ public function testAutoloadAnnotation()
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]);
}

/**
* @group DCOM-86
*/
public function testDoNotTryToLoadIgnoredAnnotations()
{
$parser = $this->createTestParser();
$classes = (object)array('list'=>null);
$loader = function($class) use ($classes) {
$classes->list[] = $class;
return false;
};

AnnotationRegistry::registerLoader($loader);
$parser->setIgnoredAnnotationNames(array('IgnoreThisOne'=>true));

$parser->parse('@IgnoreThisOne');
$parser->parse('@Doctrine\Tests\Common\Annotations\Name(foo="bar")');

$this->assertNotContains('IgnoreThisOne', $classes->list);
$this->assertContains('Doctrine\Tests\Common\Annotations\Doctrine\Tests\Common\Annotations\Name', $classes->list);
}

public function createTestParser()
{
$parser = new DocParser();
Expand Down