[DocParser] Fix trying include classes if its must be ignored. #233

Closed
wants to merge 2 commits into
from
@@ -620,10 +620,10 @@ private function Annotation()
$name = $this->imports[$loweredAlias];
}
$found = true;
- } elseif (isset($this->imports['__NAMESPACE__']) && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name)) {
+ } elseif (!isset($this->ignoredAnnotationNames[$name]) && isset($this->imports['__NAMESPACE__']) && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name)) {
$name = $this->imports['__NAMESPACE__'].'\\'.$name;
$found = true;
- } elseif ($this->classExists($name)) {
+ } elseif (!isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) {
$found = true;
}
@@ -253,6 +253,13 @@ public function testNonAnnotationProblem()
$this->assertInstanceOf($name, $annot);
}
+ public function testIncludeIgnoreAnnotation()
+ {
+ $reader = $this->getReader();
+ $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithIgnoreAnnotation', 'foo'));
+ $this->assertFalse(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\IgnoreAnnotationClass', false));
+ }
+
public function testImportWithConcreteAnnotation()
{
$reader = $this->getReader();
@@ -0,0 +1,14 @@
+<?php
+
+namespace Doctrine\Tests\Common\Annotations\Fixtures;
+
+/**
+ * @ignoreAnnotation("IgnoreAnnotationClass")
+ */
+class ClassWithIgnoreAnnotation
+{
+ /**
+ * @IgnoreAnnotationClass
+ */
+ public $foo;
+}
@@ -0,0 +1,5 @@
+<?php
+
+namespace Doctrine\Tests\Common\Annotations\Fixtures;
+
+class IgnoreAnnotationClass{}
@@ -69,6 +69,14 @@ public function testInvalidAnnotationUsageButIgnoredClass()
}
/**
+ * @expectedException Doctrine\Common\Annotations\AnnotationException
+ */
+ public function testIncludeIgnoreAnnotation()
+ {
+ parent::testIncludeIgnoreAnnotation();
+ }
+
+ /**
* @group DDC-1660
* @group regression
*