title: __callStatic(): instantiating objects from static context?
body: <p>I am confused about how "static" and "dynamic" functions and objects in PHP work together especially with regards to __callStatic().</p>
  
  <blockquote>
    <p><strong>How __callStatic() works:</strong></p>
    
    <p>You can have a normal class MyClass, where within the class you can
    put a static function called __callStatic(), which gets called only
    when MyClass doesn't have a static function by the name you want.  </p>
    
    <p>i.e. I call <code>MyClass::newFunction();</code></p>
    
    <p><code>newFunction()</code> is called statically but <code>MyClass</code> does not
    have it declared.  So, then <code>__callStatic()</code> gets called and
    inside you can say </p>
  
  <pre><code>$myObject=new SomeOtherClass();
  $myObject-&gt;newFunction();
  </code></pre>
    
    <p>which calls the function you wanted but on some other object.</p>
  </blockquote>
  
  <p><strong>Short Version:</strong></p>
  
  <p>In other words, __callStatic() does this:</p>
  
  <pre><code>MyClass::newFunction();
  </code></pre>
  
  <p>which is hiding this:</p>
  
  <pre><code>(new SomeOtherClass())-&gt;newFunction();
  </code></pre>
  
  <p>Say what now?  What looks like code calling a static function from a class, turns out to be calling that function from some other class and calling it via instantiation, and not statically.</p>
  
  <p><strong>Explain this, please!</strong></p>
  
  <p>Why was it done?  Can you do anything like this elsewhere, like C++ or Java?  I am looking for short &amp; concise, but informative explanation on static and dynamic functions in languages, and in this case whether __callStatic() <code>violates</code> or <code>conforms</code> to the big picture of Language constructs.  Or is it a new language construct entirely.</p>