Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 2.0.0-BETA4
-
Fix Version/s: 2.0.0-BETA4
-
Component/s: Annotations
-
Labels:None
Description
It is currently impossible to skip annotations of the form:
@annotation(
When a doc block comment begins with an "@" and has an open parenthesis it is assumed to be an exist annotation even if the corresponding annotation class doesn't exist or can't be autoloaded. If you are trying to use the AnnotationReader on a file, you have to make sure all annotations are loaded or can be autoloaded - even the ones you don't care about
In a comment to DCOM-2, Roman stated that his recommended way to load annotations is to load them manually via a require call. This is done in Doctrine ORM and is absolutely necessary because ORM annotations are stored in an autoloader unfriendly way (multiple classes per file and namespace path different from filesystem path).
So, if I want to add my own annotations and store them in a non-autoloader friendly way as Doctrine ORM does, I need to ensure that every AnnotationReader acting on that file knows about my annotations. This is not always possible or desirable.
Removing the parenthesis check and relying solely on class_exists fixes this problem.
I have come across another case where this bug causes a fatal PHP Error when you nest a non existant annotation:
/**
*/
PHP Fatal error: Doctrine\Common\ClassLoader::loadClass(): Failed opening required 'Doctrine/Tests/Common/Annotations/InnerNonexistant.php'
Test case and fix provided in github: http://github.com/merk/common/commit/95388a5febee95dc0483cf35d991b2b227e89069