
- Class
A
implements Foo
and Bar
. - Class
P
references a collection of Foo
s. - Class
Q
references a collection of Bar
s.
How can class A
be referred to as a Foo
by P
and a Bar
by Q
using Doctrine association mapping annotations?
Problems:
- Interfaces and traits cannot be the target of entity relationships: only abstract or concrete classes are treated as entities by Doctrine.
- We cannot convert both interfaces to abstract classes because PHP does not support multiple inheritance.
- The interfaces cannot be merged into one because other classes (not shown) may implement only one of the interfaces.