doctrine / doctrine/annotations

Identifier ends with ::class from Traits has an invalid namespace

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

Description

**How to reproduce**
Create the following class and traits using doctrine/orm:

```php
namespace App\Behaviour;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Embeddable()
*/
class State
{
}
```

```php
namespace App\Behaviour;

use Doctrine\ORM\Mapping as ORM;

trait StateMachineTrait
{
/**
* @ORM\Embedded(class=State::class)
*/
private ?State $state;
}
```

```php
namespace App\Entity;

use App\Behaviour\StateMachineTrait;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
*/
class Article
{
use StateMachineTrait;
}
```

Trying to create a mapping for this setup will throw an MappingException:

```
Class 'App\Entity\State' does not exist
```

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.