doctrine / doctrine/annotations
Annotation imports are not parsed for nested traits
- Dominant language
- PHP
- Stars
- 6.7k
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
### Bug Report
When an entity uses a trait that itself also uses a trait with a doctrine annotation the mapper failes to recognize the imported annotation. Code example below if it's not clear.
| Q | A
|------------ | ------
| BC Break | no
| Version | 1.6.1
#### How to reproduce
Create the following class and traits using doctrine/orm:
```php
// ClassA.php
use Doctrine\Orm\Mapping\Entity;
/**
* @Entity
*/
class ClassA
{
use TraitA;
}
```
```php
// TraitA.php
trait TraitA
{
use TraitB;
}
```
```php
// TraitB.php
use Doctrine\ORM\Mapping\Column;
trait TraitB
{
/**
* @Column(name="column", type="string")
*/
protected $column;
}
```
Trying to create a mapping for this setup will throw an `AnnotationException`:
```
[Semantical Error] The annotation "@Column" in property Search\Model\ClassA::$column was never imported. Did you maybe forget to add a "use" statement for this annotation?
```
This will fail on any Doctrine annotation that is used in `TraitB` but not imported in `TraitA` or `ClassA`.
I expect the `@Column`-annotation imported in `TraitB` to stay also be valid for `ClassA` where it ends up in.
Contributor guide
Assessment
This issue has not been assessed yet.