title: Why is recursive static function is not behaving like expected?
body: <p>The function below should return the next working day. It takes into account holidays and weekends.
  The problem is the weird behaviour at the end (see image below code)</p>
  
  <pre><code>class test{
  
     private static $i;
     static function getNextWorkingDay(DateTimeInterface $dateTime) {
          self::$i++;
          dump("Iteration n°: ".self::$i. " Date: ".$dateTime-&gt;format('d/m/Y'));
  
          $dateTime = (new DateTime())-&gt;setTimestamp($dateTime-&gt;getTimestamp());
          if (self::isWeekend($dateTime)) {
              dump("Iteration n°: ".self::$i." Weekend");
              self::getNextWorkingDay($dateTime-&gt;modify('next monday'));
          }
          if (self::isNotWorkable($dateTime)) {
              dump("Iteration n°: ".self::$i." Not workable");
              self::getNextWorkingDay($dateTime-&gt;modify('next day'));
          }
  
  
          dump("Iteration n°: ".self::$i. " This date should be returned and end the function: ".$dateTime-&gt;format('d/m/Y'));
  
  
          return $dateTime;
      }
  }
  
  
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/MO8lR.png" rel="nofollow noreferrer">Testing with date = 2020-05-01</a></p>
  
  <p>I expect 2020-05-04 but it returns 2020-05-02</p>