title: PHP trait method conflicts: trait "inheritance" and trait hierarchies
body: <p><strong>UPDATE:</strong> I am not alone in my pondering on this issue and it seems it is indeed a bug. See <a href="https://bugs.php.net/bug.php?id=63911" rel="noreferrer">here</a>. The day it is fixed is going to be a fantastic day! :)</p>
  
  <hr>
  
  <p>This started out as <code>I love PHP traits! I'm going to use them everywhere! ^_^</code> and now it has turned into a <code>Thought Exercise / Learning Experience &gt;_&lt;</code>.</p>
  
  <p>Consider the following example:</p>
  
  <pre><code>trait TheErrorOfYourWays{
  
     public function booboo(){
         echo 'You had a booboo :(';
     }
  }
  
  trait SpectacularStuff1 {
      use TheErrorOfYourWays; 
  }
  
  trait SpectacularStuff2 {
      use TheErrorOfYourWays;
  }
  
  class DoSomethingSpectacular {
      use SpectacularStuff1, SpectacularStuff2;
  }
  </code></pre>
  
  <p>This results in (<strike>obviously</strike> not so obviously):</p>
  
  <blockquote>
    <p>Fatal error: Trait method booboo has not been applied, because there are collisions with other trait methods on DoSomethingSpectacular.</p>
  </blockquote>
  
  <p><strong>So my question: How do I resolve method conflicts in traits? Is it possible to achieve overlapping trait "inheritance"? If so, what is the "right" way to do this?</strong></p>
  
  <p><strong>Why I want to do this:</strong> </p>
  
  <ol>
  <li>I want to create <strong>self contained</strong> traits and classes (mix and match style). <em>If it is at all possible</em>, I want to say "use" and then magic stuff must happen. No having to scratch my head and think, "Now what namespace was that trait in again?", etc, etc. </li>
  <li>No having to edit classes and traits on the fly when I do something "adventurous" and discover I have inadvertently created a conflict.</li>
  <li>Seemed like a good idea at the time.</li>
  </ol>
  
  <p><strong>What I have tried:</strong></p>
  
  <ol>
  <li>The PHP Manual.</li>
  <li>The Google.</li>
  <li>SO including <a href="https://stackoverflow.com/questions/11826064/referencing-the-same-trait-in-another-trait-and-class">this question</a> -> Not the correct answer for this scenario.</li>
  <li><a href="https://bugs.php.net/bug.php?id=64070" rel="noreferrer">Found this</a> but I am using PHP version 5.5.1. It's fixed, right? Right?</li>
  <li><p>A fantastic array of "as", aliases, even insteadof, in different places, times, universes, etc. Including, but not limited to:</p>
  
  <pre><code>trait SpectacularStuff1 {
     use TheErrorOfYourWays{
        TheErrorOfYourWays::booboo as booboo1;
     }
  }
  trait SpectacularStuff2 {
     use TheErrorOfYourWays{
        TheErrorOfYourWays::booboo as booboo2;
     }
  }
  class DoSomethingSpectacular {
     use SpectacularStuff1, SpectacularStuff2 {
        /* Tried separately, but included here for brevity's sake */
        SpectacularStuff1::booboo as booboo3;
        SpectacularStuff2::booboo as booboo4;
     }
  }
  </code></pre>
  
  <p>AND</p>
  
  <pre><code>use TheErrorOfYourWays as Erroneous1;
  trait SpectacularStuff1 {
      use Erroneous1{
          Erroneous1::booboo as booboo1;
      }
  }
  
  use TheErrorOfYourWays as Erroneous2;
  trait SpectacularStuff2 {
      use Erroneous2{
          Erroneous2::booboo as booboo2;
      }
  }
  </code></pre></li>
  </ol>
  
  <p><strong>I understand that:</strong></p>
  
  <ol>
  <li>I can change TheErrorOfYourWays to a class and make booboo() static but I would like to learn about this specific trait behaviour.</li>
  <li>I can remove TheErrorOfYourWays from the traits and use it in the class, but that's hardly "self-contained" then. Everytime I use the traits I have to remember to use TheErrorOfYourWays in the class even if I don't call booboo() directly from the class. Sounds dangerous.</li>
  <li>I have probably made some rookie syntax error or failed to understand aliasing on a profound level. If so, please... explain... slowly...</li>
  <li>There is probably a better way to do this. If so, please... explain... slowly...</li>
  <li>I may be prematurely enthusiastic and PHP doesn't do this yet. Let me down gently.</li>
  </ol>
  
  <p><strong>Thanks!</strong></p>