title: Static method that calls itself on an object
body: <p>I want to have a class that i can use it this way:</p>
  
  <pre><code>Thing::doThis()-&gt;doThat()-&gt;doImportantThing();
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>Thing::doThat()-&gt;doImportantThing();
  </code></pre>
  
  <p>OR </p>
  
  <pre><code>Thing::doImportantThing();
  </code></pre>
  
  <p>But currently i can only use it this way:</p>
  
  <pre><code>$thing = new Thing();
  $thing-&gt;doThis()-&gt;doThat()-&gt;doImportantThing();
  </code></pre>
  
  <p>What do i have to change in the class so i can use it the way i want? I already return a <code>Thing</code> instance in every function call.</p>
  
  <p>I want to use that for a simple reason, imagine a mail class, in the constructor you define a default from and to, but you might want to change it, so you do <code>Mail::setFrom()-&gt;send()</code>. If you want to change the to, you use <code>Mail::setTo()-&gt;send()</code>. It just makes it easier to use if it's going to be used in different projects by different people.</p>
  
  <p>I want by calling <code>Mail::{something}</code> to have like a constructor call and then run the <code>{something}</code> function.</p>