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

Author: hasonCreated Nov 5, 2020Updated Nov 5, 2020

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