doctrine / doctrine/annotations

AnnotationRegistry fallback to class_exists doesn't seem to work

Open
#321 5 comments 1 reaction 0 assignees View on GitHub
Dominant language
PHP
Stars
6.7k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

I noticed in our codebase after updating to 1.10.1 and removing the deprecated `registerLoader('class_exists')` call that our custom annotations were not recognized anymore. Getting a _"The annotation [...] was never imported. Did you maybe forget to add a "use" statement for this annotation?"_ error message, though there is in fact a use statement.

I thought pull request #271 would fix that, but it appears that class_exists is not called.

I think I narrowed down the cause to the `registerFileUsed` flag. In the `AnnotationReader` constructor is a call to registerFile, which means registerFileUsed is always true, which results in the [class_exists](https://github.com/doctrine/annotations/blob/233e36632422cfc5cc499f14ad6c1476b50cb7b1/lib/Doctrine/Common/Annotations/AnnotationRegistry.php#L172) fallback never being called.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.