website/errors/doctrine.mapping.md
<?php declare(strict_types = 1);
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class FooWithoutPK
{
#[ORM\Column]
private string $name;
}
This error is reported by phpstan/phpstan-doctrine.
Doctrine ORM detected a mapping configuration error in the entity class. The specific error message comes directly from Doctrine's metadata validation. Common causes include:
#[ORM\Id] column)inversedBy or mappedBy)These errors would cause Doctrine to throw an exception at runtime when it tries to load the entity metadata.
The fix depends on the specific Doctrine mapping error reported. For example, if a primary key is missing, add one:
<?php declare(strict_types = 1);
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class FooWithoutPK
{
+ #[ORM\Id]
+ #[ORM\GeneratedValue]
+ #[ORM\Column]
+ private ?int $id = null;
+
#[ORM\Column]
private string $name;
}
Consult the Doctrine ORM mapping documentation for details on the correct mapping configuration.