title: How to terminate last function in chaining method php
body: <p>I got some problem and I don't know how to fix it.</p>
  <p>this is sample for the problem</p>
  <pre><code>class DancingClass {
      private static $associate = [];
      private static $first;
  
      public static function first($param) {
          self::$first = $param;
  
          return new self;
      }
  
      public function second($param) {
          self::$associate[&quot;second&quot;] = $param;
  
          return new self;
      }
  
      public function finish() {
          var_dump(self::$associate[&quot;second&quot;]);
          $sec = self::$associate[&quot;second&quot;] | &quot;&quot;;
  
          $all = self::$first . &quot; ditemani oleh &quot; . $sec;
  
          return $all;
      }
  }
  </code></pre>
  <p>Then I call with chaining method</p>
  <pre><code>$callingClass = new DancingClass;
  
  echo $callingClass::first(&quot;lucky&quot;)-&gt;second(&quot;adhitya&quot;)-&gt;finish(); // Return &quot;lucky ditemani oleh adhitya&quot;
  echo &quot;&lt;br/&gt;&quot;;
  
  echo $callingClass::first(&quot;fatur&quot;)-&gt;finish(); // Return &quot;fatur ditemani oleh&quot;
  </code></pre>
  <p>but I got result like this
  <img src="https://i.stack.imgur.com/JYu2N.png" alt="the result" /></p>