code: public function clearEmptyTokens()
      {
          $limit = $this->count();
          $index = 0;
  
          for (; $index < $limit; ++$index) {
              if ($this->isEmptyAt($index)) {
                  break;
              }
          }
  
          // no empty token found, therefore there is no need to override collection
          if ($limit === $index) {
              return;
          }
  
          for ($count = $index; $index < $limit; ++$index) {
              if (!$this->isEmptyAt($index)) {
                  $this[$count++] = $this[$index];
              }
          }
  
          $this->setSize($count);
      }
docs: Clear empty tokens.
  
  Empty tokens can occur e.g. after calling clear on item of collection.