实现多个接口的类如何被Doctrine中的任一接口引用?

  • Class A implements Foo and Bar.
  • Class P references a collection of Foos.
  • Class Q references a collection of Bars.

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.