Skip to content

Commit

Permalink
Put up a warning sign that mapping may not be inherited from transien…
Browse files Browse the repository at this point in the history
…t classes (#10392)

This _seems_ to work, but...

To my understanding, that is only because `ReflectionClass::getProperties` will report `protected` properties also for subclasses, including DocBlocks etc. The mapping drivers are unable to tell where a field comes from, so they pick up the mapping and treat it as originating from the inheriting class.

If that is indeed outside of what the ORM was designed for (sombody please confirm?), then we should explicitly discourage it.

Yes, I have seen examples of this in the wild.
  • Loading branch information
mpdude authored Feb 8, 2023
1 parent 01f139d commit 31ff969
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/en/reference/inheritance-mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ need not have an ``#[Id]`` property.
For further support of inheritance, the single or
joined table inheritance features have to be used.

.. warning::

At least when using attributes or annotations to specify your mapping,
it _seems_ as if you could inherit from a base class that is neither
an entity nor a mapped superclass, but has properties with mapping configuration
on them that would also be used in the inheriting class.

This, however, is due to how the corresponding mapping
drivers work and what the PHP reflection API reports for inherited fields.

Such a configuration is explicitly not supported. To give just one example,
it will break for ``private`` properties.

.. note::

You may be tempted to use traits to mix mapped fields or relationships
Expand Down

0 comments on commit 31ff969

Please sign in to comment.