Weird behaviour with triggering __callStatic() from non-static method
<p>I found this weird behaviour with PHP classes (v5.3.8).</p>

<p>You have:</p>

<pre><code>class foo {
  function __call($func, $args) {
    if ($func == 'bar')
      echo "non-static __call";
  }

  static function __callStatic($func, $args) {
    if ($func == 'bar')
      echo "__callStatic";
  }

  function callMe() {
    self::bar();
  }
}
</code></pre>

<p>Then you do:</p>

<pre><code>foo::bar() // outputs '__callStatic' as expected.
$f = new foo;
$f-&gt;callMe(); // outputs 'non-static __call', as I did not expect.
</code></pre>

<p>You see, a non-existent static method called from a non-static function triggers <code>__call()</code> instead of <code>__callStatic()</code>. I was wondering if this is supposed to work like this or is this some kind of bug?</p>

<p><strong>[EDIT]</strong></p>

<p>I forgot to try <code>static::bar();</code> on <code>callMe()</code> but no, it didn't work either.</p>

<p>I (think I) understand inhan's comment but still... if I'm calling the class itself, not the instance or object, immediate logic for me says it should trigger __callStatic(). Oh well.</p>

<p>Thank you for your answers/comments.</p>
