diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index f9aa4e696fa..6900718969e 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -26,6 +26,7 @@ use function array_diff; use function array_key_exists; +use function array_search; use function array_values; use function class_exists; use function class_parents; @@ -255,6 +256,12 @@ public function validateClass(ClassMetadataInfo $class) } } + if (! $class->isInheritanceTypeNone() && ! $class->isRootEntity() && array_search($class->name, $class->discriminatorMap) === false) { + $ce[] = "Entity class '" . $class->name . "' is part of inheritance hierarchy, but is " . + "not mapped in the root entity '" . $class->rootEntityName . "' discriminator map. " . + 'All subclasses must be listed in the discriminator map.'; + } + foreach ($class->subClasses as $subClass) { if (! in_array($class->name, class_parents($subClass))) { $ce[] = "According to the discriminator map class '" . $subClass . "' has to be a child " .