symfony/symfony — Issue #2796: functional test: Reflection parse wrong class
Author: buxx
Created: 2011-12-07 10:57:38+00:00
State: open

[!]: I'm using sf 2.0.1, i don't now if this problem has been fix.

Hello guys,
I had a strange problem in my functional test processus (no problem in dev):
I've a form (search form).
I've a search action.
When (in my test) the form is binded i have this error:
```
> [Semantical Error] The annotation "@ORM\Entity" in class Muzich\CoreBundle\Searcher\UserAndGroupSearcher was never imported.
```
But, my class UserAndGroupSearcher never use @ORM\Entity.
If a take a look in stack trace, i can find this:
```
[...]
> at DocParser ->parse ('/** * Le groupe est une sorte de liste de diffusion, a laquelle les * users peuvent s'abonner (follow). Un groupe peut tout aussi bien * être "Les fans de la tek du sud est" qu'un sound système, * un artiste ... * * @ORM\Entity * @ORM\Table(name="m_group") * @ORM\Entity(repositoryClass="Muzich\CoreBundle\Repository\GroupRepository") * @UniqueEntity("name") */', 'class Muzich\CoreBundle\Searcher\UserAndGroupSearcher')
> in /home/bux/projets/muzich/vendor/doctrine-common/lib/Doctrine/Common/Annotations/AnnotationReader.php at line 227 -
> at AnnotationReader ->getClassAnnotations (object(ReflectionClass))
> in /home/bux/projets/muzich/vendor/doctrine-common/lib/Doctrine/Common/Annotations/FileCacheReader.php at line 63 -
> at FileCacheReader ->getClassAnnotations (object(ReflectionClass))
> in /home/bux/projets/muzich/vendor/symfony/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php at line 38 -
> at AnnotationLoader ->loadClassMetadata (object(ClassMetadata))
> in /home/bux/projets/muzich/vendor/symfony/src/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php at line 57 -
> at LoaderChain ->loadClassMetadata (object(ClassMetadata))
> in /home/bux/projets/muzich/vendor/symfony/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php at line 64 -
> at ClassMetadataFactory ->getClassMetadata ('Muzich\CoreBundle\Searcher\UserAndGroupSearcher')
> in /home/bux/projets/muzich/vendor/symfony/src/Symfony/Component/Validator/GraphWalker.php at line 162 -
> at GraphWalker ->walkReference (object(UserAndGroupSearcher), 'Default', 'data', true)
> in /home/bux/projets/muzich/vendor/symfony/src/Symfony/Component/Form/Extension/Validator/Validator/DelegatingValidator.php at line 125
> at DelegatingValidator ::validateFormData (object(Form), object(ExecutionContext))
> in at line -
> at call_user_func (array('Symfony\Component\Form\Extension\Validator\Validator\DelegatingValidator', 'validateFormData'), object(Form), object(ExecutionContext))
> in /home/bux/projets/muzich/vendor/symfony/src/Symfony/Component/Validator/Constraints/CallbackValidator.php at line 65 -
> at CallbackValidator ->isValid (object(Form), object(Callback))
> in /home/bux/projets/muzich/vendor/symfony/src/Symfony/Component/Validator/GraphWalker.php at line 177 -
```
At the bottom of trace: isValid; at GraphWalker ->walkReference it's work with UserAndGroupSearcher.
But in DocParser ->parse it's the comment of an other class (Muzich/CoreBundle/Entity/Group), not the comment of Muzich\CoreBundle\Searcher\UserAndGroupSearcher.

How i fix it:
I've notice what UserAndGroupSearcher did not comment:
```
>
> class UserAndGroupSearcher extends Searcher implements SearcherInterface
> {
```
I've added one:
```
> /**
> * Objet de recherche
> */
> class UserAndGroupSearcher extends Searcher implements SearcherInterface
> {
```
And the problem disapear.

If my issue can help ...
bux.