Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Worksheet;
   4  
   5  use Iterator;
   6  use PhpOffice\PhpSpreadsheet\Cell\Cell;
   7  
   8  /**
   9   * @template TKey
  10   * @implements Iterator<TKey, Cell>
  11   */
  12  abstract class CellIterator implements Iterator
  13  {
  14      /**
  15       * Worksheet to iterate.
  16       *
  17       * @var Worksheet
  18       */
  19      protected $worksheet;
  20  
  21      /**
  22       * Iterate only existing cells.
  23       *
  24       * @var bool
  25       */
  26      protected $onlyExistingCells = false;
  27  
  28      /**
  29       * Destructor.
  30       */
  31      public function __destruct()
  32      {
  33          // @phpstan-ignore-next-line
  34          $this->worksheet = null;
  35      }
  36  
  37      /**
  38       * Get loop only existing cells.
  39       */
  40      public function getIterateOnlyExistingCells(): bool
  41      {
  42          return $this->onlyExistingCells;
  43      }
  44  
  45      /**
  46       * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary.
  47       */
  48      abstract protected function adjustForExistingOnlyRange();
  49  
  50      /**
  51       * Set the iterator to loop only existing cells.
  52       */
  53      public function setIterateOnlyExistingCells(bool $value): void
  54      {
  55          $this->onlyExistingCells = (bool) $value;
  56  
  57          $this->adjustForExistingOnlyRange();
  58      }
  59  }