'startuml' => true, 'enduml' => true,
);
+ /**
+ * A list with annotations that are not causing exceptions when not resolved to an annotation class.
+ *
+ * The names are case sensitive.
+ *
+ * @var array
+ */
+ private static $globalIgnoredNamespaces = array();
+
/**
* Add a new annotation to the globally ignored annotation names with regard to exception handling.
*
self::$globalIgnoredNames[$name] = true;
}
+ /**
+ * Add a new annotation to the globally ignored annotation namespaces with regard to exception handling.
+ *
+ * @param string $namespace
+ */
+ static public function addGlobalIgnoredNamespace($namespace)
+ {
+ self::$globalIgnoredNamespaces[$namespace] = true;
+ }
+
/**
* Annotations parser.
*
* Constructor.
*
* Initializes a new AnnotationReader.
+ *
+ * @param DocParser $parser
*/
- public function __construct()
+ public function __construct(DocParser $parser = null)
{
if (extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.save_comments') === "0" || ini_get('opcache.save_comments') === "0")) {
throw AnnotationException::optimizerPlusSaveComments();
AnnotationRegistry::registerFile(__DIR__ . '/Annotation/IgnoreAnnotation.php');
- $this->parser = new DocParser;
+ $this->parser = $parser ?: new DocParser();
+
$this->preParser = new DocParser;
$this->preParser->setImports(self::$globalImports);
$this->parser->setTarget(Target::TARGET_CLASS);
$this->parser->setImports($this->getClassImports($class));
$this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
+ $this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
return $this->parser->parse($class->getDocComment(), 'class ' . $class->getName());
}
$this->parser->setTarget(Target::TARGET_PROPERTY);
$this->parser->setImports($this->getPropertyImports($property));
$this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
+ $this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
return $this->parser->parse($property->getDocComment(), $context);
}
$this->parser->setTarget(Target::TARGET_METHOD);
$this->parser->setImports($this->getMethodImports($method));
$this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
+ $this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
return $this->parser->parse($method->getDocComment(), $context);
}
*/
private function getIgnoredAnnotationNames(ReflectionClass $class)
{
- if (isset($this->ignoredAnnotationNames[$name = $class->getName()])) {
+ $name = $class->getName();
+ if (isset($this->ignoredAnnotationNames[$name])) {
return $this->ignoredAnnotationNames[$name];
}
*/
private function getClassImports(ReflectionClass $class)
{
- if (isset($this->imports[$name = $class->getName()])) {
+ $name = $class->getName();
+ if (isset($this->imports[$name])) {
return $this->imports[$name];
}