Skip to content

Commit

Permalink
Merge branch '2.15.x' into 3.0.x
Browse files Browse the repository at this point in the history
* 2.15.x:
  Deprecate undeclared entity inheritance (doctrine#10431)
  Psalm 5.5.0 (doctrine#10445)
  • Loading branch information
derrabus committed Jan 26, 2023
2 parents 5233a13 + 6568782 commit d8a2cca
Show file tree
Hide file tree
Showing 11 changed files with 548 additions and 363 deletions.
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,11 @@ Use `toIterable()` instead.

# Upgrade to 2.15

## Deprecated undeclared entity inheritance

As soon as an entity class inherits from another entity class, inheritance has to
be declared by adding the appropriate configuration for the root entity.

## Deprecated stubs for "concrete table inheritance"

This third way of mapping class inheritance was never implemented. Code stubs are
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"squizlabs/php_codesniffer": "3.7.1",
"symfony/cache": "^5.4 || ^6.0",
"symfony/var-exporter": "^5.4 || ^6.2",
"vimeo/psalm": "5.4.0"
"vimeo/psalm": "5.5.0"
},
"suggest": {
"ext-dom": "Provides support for XSD validation for XML mapping files",
Expand Down
12 changes: 12 additions & 0 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ protected function doLoadMetadata(
}

if (! $class->isMappedSuperclass) {
if ($rootEntityFound && $class->isInheritanceTypeNone()) {
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/10431',
"Entity class '%s' is a subclass of the root entity class '%s', but no inheritance mapping type was declared. This is a misconfiguration and will be an error in Doctrine ORM 3.0.",
$class->name,
end($nonSuperclassParents)
);
// enable this in 3.0
// throw MappingException::missingInheritanceTypeDeclaration(end($nonSuperclassParents), $class->name);
}

foreach ($class->embeddedClasses as $property => $embeddableClass) {
if (isset($embeddableClass['inherited'])) {
continue;
Expand Down
13 changes: 13 additions & 0 deletions lib/Doctrine/ORM/Mapping/MappingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,19 @@ public static function duplicateDiscriminatorEntry(string $className, array $ent
);
}

/**
* @param class-string $rootEntityClass
* @param class-string $childEntityClass
*/
//public static function missingInheritanceTypeDeclaration(string $rootEntityClass, string $childEntityClass): self
//{
// return new self(sprintf(
// "Entity class '%s' is a subclass of the root entity class '%s', but no inheritance mapping type was declared.",
// $childEntityClass,
// $rootEntityClass
// ));
//}

public static function missingDiscriminatorMap(string $className): self
{
return new self(sprintf(
Expand Down
Loading

0 comments on commit d8a2cca

Please sign in to comment.