title: Only instantiate class from within itself
body: <p>I am looking for a way where you can call a static method in a class, which will create an instance of itself. I would like it so it isn't possible to instantiate the class outside of itself. I have tried this, but I get an error saying <strong>Cannot instantiate abstract class</strong> (Which I assumed would happen).</p>
  
  <pre><code>abstract class Test {
  
      public function __construct($item){
  
      }
  
      public static function from($item){
          return new Test($item);
      }
  
      public function testFunc(){
          // Do some stuff
          return $this;
      }
  
  }
  </code></pre>
  
  <p>It's usage would look something like this:</p>
  
  <pre><code>// Valid
  Test::from($myItem)-&gt;testFunc();
  
  // Invalid
  (new Test($myItem))-&gt;testFunc();
  </code></pre>
  
  <p>Is there any way to do something like this?</p>