symfony/symfony — Issue #2745: [Validator] when guessing type, obtains weird annotation data.
Author: jonathaningram
Created: 2011-11-29 08:18:19+00:00
State: open

`[Semantical Error] The annotation "@ORM\Entity" in class Jbi\CompanyBundle\Wizard\Form\Model\ProjectFormModel was never imported. Did you maybe forget to add a "use" statement for this annotation?`

The class looks like this:

```php
company = $company;

return $this;
}

public function getCompany()
{
return $this->company;
}

public function addSite(SiteInterface $site)
{
$this->sites[] = $site;

return $this;
}

public function getSites()
{
return $this->sites;
}

public function setName($name)
{
$this->name = $name;

return $this;
}

public function getName()
{
return $this->name;
}

public function setDeploymentType($deploymentType)
{
$this->deploymentType = $deploymentType;

return $this;
}

public function getDeploymentType()
{
return $this->deploymentType;
}

public function setHostedSubdomain($hostedSubdomain)
{
$this->hostedSubdomain = $hostedSubdomain;

return $this;
}

public function getHostedSubdomain()
{
return $this->hostedSubdomain;
}

public function setDownloadPath($downloadPath)
{
$this->downloadPath = $downloadPath;

return $this;
}

public function getDownloadPath()
{
return $this->downloadPath;
}
}
```

As you can see, there is no `@ORM` in there. Worse yet, in the stack trace is this:

```
at DocParser ->parse ('/** * @ORM\Entity * @ORM\Table(name="rule") */', 'class Jbi\CompanyBundle\Wizard\Form\Model\ProjectFormModel')
in /var/www/site.com/shared/vendor/doctrine-common/lib/Doctrine/Common/Annotations/AnnotationReader.php at line 149
```

The important part in that is `name="rule"`. I have a `Rule` entity with such a class annotation, but that's located at `Jbi\CoreBundle\Entity\Rule`, so I cannot see any relation here except that the validator guesser thinks my class is an Entity (no idea why it would pick rule though when there is a `Project` entity too).

Note: originally I called my class `Jbi\CompanyBundle\Wizard\Form\Model\Project`, but thought the name `Project` might conflict with the entity, so I changed it to `ProjectFormModel` and it still fails.