Skip to content

Commit

Permalink
fix: allow iterators to go out of bounds with prev()
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarlovi committed Aug 7, 2018
1 parent 125f462 commit bb3ada1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Upcoming

### Fixed

- Allow iterators to go out of bounds with prev - [#587](https://github.com/PHPOffice/PhpSpreadsheet/issues/587)

## [1.4.0] - 2018-08-06

### Added
Expand Down
4 changes: 0 additions & 4 deletions src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ public function next()
*/
public function prev()
{
if ($this->currentRow <= $this->startRow) {
throw new PhpSpreadsheetException("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})");
}

do {
--$this->currentRow;
} while (($this->onlyExistingCells) &&
Expand Down
6 changes: 0 additions & 6 deletions src/PhpSpreadsheet/Worksheet/RowIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,9 @@ public function next()

/**
* Set the iterator to its previous value.
*
* @throws PhpSpreadsheetException
*/
public function prev()
{
if ($this->position <= $this->startRow) {
throw new PhpSpreadsheetException("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})");
}

--$this->position;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ public function testSeekOutOfRange()

public function testPrevOutOfRange()
{
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);

$iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4);
$iterator->prev();
}
Expand Down
2 changes: 0 additions & 2 deletions tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ public function testSeekOutOfRange()

public function testPrevOutOfRange()
{
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);

$iterator = new RowIterator($this->mockWorksheet, 2, 4);
$iterator->prev();
}
Expand Down

0 comments on commit bb3ada1

Please sign in to comment.