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

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 committed Jan 13, 2023
1 parent c5e4e41 commit a221168
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/en/reference/inheritance-mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ appear in the middle of an otherwise mapped inheritance hierarchy
For further support of inheritance, the single or
joined table inheritance features have to be used.

.. note::

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.

Example:

Expand Down

0 comments on commit a221168

Please sign in to comment.