title: PHP traits - defining generic constants
body: <p>What is the best way to define constants that may be used by a number of classes within a namespace? I'm trying to avoid too much inheritance, so extending base classes is not an ideal solution, and I'm struggling to find a good solution using traits. Is this in any way possible in PHP 5.4 or should a different approach be taken?</p>
  
  <p>I have the following situation:</p>
  
  <pre><code>trait Base
  {
      // Generic functions
  }
  
  class A 
  {
      use Base;
  }
  
  class B 
  {
      use Base;
  }
  </code></pre>
  
  <p>The problem is that it is not possible to define constants in PHP traits. Ideally, I would want something like the following:</p>
  
  <pre><code>trait Base
  {
      const SOME_CONST = 'someconst';
      const SOME_OTHER_CONST = 'someotherconst';
  
      // Generic functions
  }
  </code></pre>
  
  <p>Then these could be accessed though the class that applies the trait:</p>
  
  <pre><code>echo A::SOME_CONST;
  echo B::SOME_OTHER_CONST;
  </code></pre>
  
  <p>But due to the limitations of traits this isn't possible. Any ideas?</p>