title: php late static bindings: return static::CONST using reflection
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7506530/accessing-a-class-constant-using-a-simple-variable-which-contains-the-name-of-th">Accessing a class constant using a simple variable which contains the name of the constant</a>  </p>
  </blockquote>
  
  
  
  <p>I would like to use reflection to send an array of const as a result of a static call</p>
  
  <pre><code>class ArrowType extends AbstractAttributeType
  {
      const NORMAL = 'normal';
      const INV = 'inv';
  
      static function getPossibleValues()
      {
          $refl = new \ReflectionClass(__CLASS__);
          $class_vars = $refl-&gt;getConstants();
          $res = array();
          foreach ($class_vars as $name =&gt; $value) {
              $res[] = static::$$name;
          }
  
          return $res;
      }
  }
  </code></pre>
  
  <p>this gives me </p>
  
  <blockquote>
    <p>Fatal error: Access to undeclared static property: <strong>ArrowType::$NORMAL</strong> </p>
  </blockquote>
  
  <p>I would like to get </p>
  
  <blockquote>
    <p><em>ArrowType::NORMAL</em> </p>
  </blockquote>
  
  <p>When calling <em>$arrowType->getPossibleValues()</em></p>
  
  <p><strong>EDIT</strong></p>
  
  <p>In order to make my question a little more understable, I will give you the details.
  I am using the <a href="https://github.com/yethee/BiplaneEnumBundle" rel="nofollow noreferrer">https://github.com/yethee/BiplaneEnumBundle</a> and I am trying to make my life easier. For the moment, I have to produce the code below in order to follow the library requirements.</p>
  
  <pre><code>class ArrowType extends AbstractAttributeType
  {
      const NORMAL = 'normal';
      const INV = 'inv';
      const DOT = 'dot';
      const INVDOT = 'invdot';
      const ODOT = 'odot';
      const INVODOT = 'invodot';
      const NONE = 'none';
  
      static function getPossibleValues()
      {
          return array(
                      static::NORMAL,
                      static::INV,
                      static::DOT,
                      static::INVDOT,
                      static::ODOT,
                      static::INVODOT,
                      static::NONE
                      );
      }
  
      static function getReadables()
      {
          return array(
                      static::NORMAL =&gt; 'normal',
                      static::INV =&gt; 'inv',
                      static::DOT =&gt; 'dot',
                      static::INVDOT =&gt; 'invdot',
                      static::ODOT =&gt; 'odot',
                      static::INVODOT =&gt; 'invodot',
                      static::NONE =&gt; 'none'
                  );
      }
  
  }
  </code></pre>
  
  <p>what I am trying to achieve now, is to build dynamically the array in the two functions in order to put these functions in a parent class and just declare in my classes the const part. I hope that helps the kind reader understand what I want.</p>