title: Doctrine 2: How to resolve "targetEntity" and JoinTable "name" dynamically in trait?
body: <p>I want to create Entity which will implement following interface.</p>
  
  <pre><code>&lt;?php
  
  namespace App\Entity\Interfaces;
  #...
  
  interface FooInterface
  {
      /**
       * @param ArrayCollection|FooInterface[] $foo
       */
      public function setFoo($foo);
  
      /**
       * @return ArrayCollection|FooInterface[]
       */
      public function getFoo();
  }
  </code></pre>
  
  <p>To make it simple I want to use trait to inherit properties and methods from it. So finally my entities could look similar to these:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Entity\Entity;
  #...
  
  class Bar implements FooInterface
  {
      use FooTrait;
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;?php
  
  namespace App\Entity\Entity;
  #...
  
  class Baz implements FooInterface
  {
      use FooTrait;
  }
  </code></pre>
  
  <p>But I don't know how to resolve <code>targetEntity</code> and <code>name</code> dynamically
  in <code>@ORM</code> annotation.</p>
  
  <pre><code>&lt;?php
  
  namespace App\Entity\Traits;
  #...
  
  trait FooTrait
  {
      /**
       * Many Foo has Many Foo.
       *
       * @ORM\ManyToMany(targetEntity="...")
       * @ORM\JoinTable(
       *     name="..."
       *     joinColumns={@ORM\JoinColumn(name="foo_id", referencedColumnName="id")},
       *     inverseJoinColumns={@ORM\JoinColumn(name="foo_of_id", referencedColumnName="id")}
       * )
       * @ORM\OrderBy({"id" = "ASC"})
       *
       * @var FooInterface[]|ArrayCollection
       */
      protected $foo;
  
      #...
  }
  </code></pre>
  
  <p>Is the approach I chose a good one? If so how I can resolve my issue?</p>