doctrine / doctrine/annotations
AnnotationReader may incorrectly throw exceptions
- Dominant language
- PHP
- Stars
- 6.7k
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
_From @arnaud-lb on July 6, 2012 17:11_
The AnnotationReader pre-parses classes' doc block with a PreParser that doesn't have import (_use_) informations.
Due to this, it can happen that an annotation resolves to a wrong class.
The parser will then attempt to validate the class and fail (no @Annotation, cannot be used on classes, etc).
Here is a test case: https://github.com/doctrine/common/pull/161
The ArrayObject annotation is resolved as \ArrayObject, which is not a valid annotation. This results in the following exception:
```
Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The class "ArrayObject" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "ArrayObject". If it is indeed no annotation, then you need to add @IgnoreAnnotation("ArrayObject") to the _class_ doc comment of class Doctrine\Tests\Common\Annotations\Issue159\ParseMe.
```
_Copied from original issue: doctrine/common#159_
Contributor guide
Assessment
This issue has not been assessed yet.