-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
This is:
- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
What is the expected behavior?
RowIterator::prev()
not throwing an exception if you go out of bounds.
What is the current behavior?
RowIterator::prev()
throwing an exception if you go out of bounds.
What are the steps to reproduce?
I've implemented an RowIterator
decorator which allows me to iterate in reverse,
https://github.com/dkarlovi/xls-transmailifier/blob/command/src/Transmailifier/ReverseRowIterator.php#L63
The way current code works, it will throw an exception if you try to go out of bounds:
PhpSpreadsheet/src/PhpSpreadsheet/Worksheet/RowIterator.php
Lines 160 to 162 in 043327b
if ($this->position <= $this->startRow) { | |
throw new PhpSpreadsheetException("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})"); | |
} |
But, how iterators work, they WILL go out of bounds and then call valid()
. You can see this by having next()
not check if it's out of bounds, it just does.
I believe this to be a bug.
Which versions of PhpSpreadsheet and PHP are affected?
Latest master, as linked.
Metadata
Metadata
Assignees
Labels
No labels