Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation false positive(?): Embeddable reported to require inheritance mapping type #11843

Open
havvg opened this issue Feb 20, 2025 · 0 comments

Comments

@havvg
Copy link
Contributor

havvg commented Feb 20, 2025

Bug Report

Q A
Version 2.20.2

Summary

We are currently migrating a project to Doctrine 3 and are encountering the following deprecation.

Entity class 'App\Domain\Value\BoundedTimeframe' is a subclass of the root entity class 'App\Domain\Value\Timeframe', but no inheritance mapping type was declared. This is a misconfiguration and will be an error in Doctrine ORM 3.0. (ClassMetadataFactory.php:165 called by ClassMetadataFactory.php:18, https://github.com/doctrine/orm/pull/10431, package doctrine/orm)

Current behavior

The deprecation about entity inheritance is raised on embeddables.

Expected behavior

There has been no issue within Doctrine 2 using this pattern. As you cannot define inheritance types on embeddables, the deprecation should not be raised for them. In addition, the behavior should work in Doctrine 3, as well. Will it?

How to reproduce

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <embeddable name="App\Domain\Value\Timeframe">
        <field name="from" type="datetime_immutable" column="from" nullable="true" />
        <field name="to" type="datetime_immutable" column="to" nullable="true" />
    </embeddable>
</doctrine-mapping>
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <embeddable name="App\Domain\Value\BoundedTimeframe" />
</doctrine-mapping>
// Simplified

class Timeframe
{
    public function __construct(
        protected readonly \DateTimeImmutable|null $from,
        protected readonly \DateTimeImmutable|null $to,
    ) {
    }
}

class BoundedTimeframe extends Timeframe
{
    public function __construct(\DateTimeImmutable $from, \DateTimeImmutable $to)
    {
        parent::__construct($from, $to);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant