diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 5e57b05d83a..4f6a2edd532 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -776,8 +776,9 @@ protected function getDriver() */ protected function isEntity(ClassMetadataInterface $class) { - return isset($class->isMappedSuperclass) && $class->isMappedSuperclass === false - && isset($class->isEmbeddedClass) && $class->isEmbeddedClass === false; + assert($class instanceof ClassMetadata); + + return $class->isMappedSuperclass === false && $class->isEmbeddedClass === false; } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8031Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8031Test.php index 5815791ef99..37dd4d38b50 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8031Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8031Test.php @@ -36,6 +36,28 @@ public function testEntityIsFetched() $this->_em->getRepository(GH8031Invoice::class)->findBy([], ['code.number' => 'ASC']) ); } + + public function testEmbeddableWithAssociationNotAllowed() + { + $cm = $this->_em->getClassMetadata(GH8031EmbeddableWithAssociation::class); + + $this->assertArrayHasKey('invoice', $cm->associationMappings); + + $cm = $this->_em->getClassMetadata(GH8031Invoice::class); + + $this->assertCount(0, $cm->associationMappings); + } +} + +/** + * @Embeddable + */ +class GH8031EmbeddableWithAssociation +{ + /** + * @ManyToOne(targetEntity=GH8031Invoice::class) + */ + public $invoice; } /** @@ -123,6 +145,11 @@ class GH8031Invoice */ private $code; + /** + * @Embedded(class=GH8031EmbeddableWithAssociation::class) + */ + private $embeddedAssoc; + public function __construct(GH8031InvoiceCode $code) { $this->code = $code;