[DCOM-75] remove leading backslash from class name before comparing to namespace in annotation autoloading Created: 03/Nov/11 Updated: 06/Dec/13 Resolved: 06/Dec/13
|Reporter:||Guillaume ORIOL||Assignee:||Guilherme Blanco|
I am figuring a problem with Symfony Validator constraints (I use annotations to define the constraint rules).
As I don't use Symfony's framework, I create the validator service by myself.
Then, in my entities, I have annotations such as:
In this configuration, I get the following error:
I was able to trace it down to the Doctrine\Common\Annotations\AnnotationRegistry#loadAnnotationClass($class) where we can find the following test:
which means "if the namespace can be found at the beginning of the FQCN, require it".
Christophe Coevoet answered:
Benjamin Eberlei suggested to remove the leading backslash before comparing the class to the namespace.
When I add a use statement to my code for a class, I can then use its alias to get an instance of that class.
The same is true with:
This is not a fully qualified class name.
But I find the syntax of a fully-qualified annotation (@My\Annotation\Whatever) erroneous (or at least counter-intuitive) as it doesn't start with a backslash.
|Comment by Guilherme Blanco [ 06/Dec/13 ]|
Your referred problem is an internal namespace => directory mapping.
This has nothing to do with annotations.