title: Create class instance from within static method
body: <p>As the title says, I'm wanting to create an instance of a class from within a static method of the same class. I've figured out so far is that I can by doing something like this:</p>
  
  <pre><code>class Foo{
  
   public $val;
  
   public static function bar($val){
    $inst = new Foo;
    $inst-&gt;val = $val;
    return $inst;
   }
  
  }
  </code></pre>
  
  <p>Which therefore lets me do this.</p>
  
  <pre><code>$obj = Foo::bar("some variable");
  </code></pre>
  
  <p>Which is great.</p>
  
  <p>So now the questions. Is there an easier way of doing this that I'm not aware of, or any shortcuts to achieving the same result? Are there any advantages or disadvantages of creating an instance in this fashion?</p>
  
  <p>Thanks.</p>