-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
I ran the tests on PHP 5.4.0 and got an error.
Did some research and it looks like it's this bug, which was fixed in PHP 5.4.6: |
After some research, discovered the following: The error is actually a
It's caused by an exception of type
The stack trace for this inner exception reveals that the error is caused when calling |
Identified the problem. It lies in When PHP iterates an iterator, it follows the following algo: $iter->rewind();
while ($iter->valid()) {
$val = $iter->current();
$key = $iter->key();
// yield $val and $key
$iter->next();
} Was also surprised that it retrieves the value before the key - for some reason I'd thought it would be the other way around, but I digress. However, note that when PHP invokes The protected function _loop()
{
$iterator = $this->_getIterator();
$iterator->next();
$iteration = $this->_createIteration($iterator->key(), $iterator->current());
return $iteration;
} Effectively, the iteration object is created on Prior to PHP 5.4.6, reaching the end of a PHP iterator meant a notice would be triggered. After PHP 5.4.6, this was changed to yield a The solution is to amend the above method to, after invoking I will leave a formal review where it is applicable. tl;dr Prior to 5.4.6, As of 5.4.6, |
src/AbstractBaseMap.php
Outdated
$iterator = $this->_getIterator(); | ||
|
||
$iterator->next(); | ||
$iteration = $this->_createIteration($iterator->key(), $iterator->current()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if the $iterator
is still valid after advancing. If not, the key and value of the created iteration should be null
.
This change would make this package compatible with PHP 5.4.0, otherwise it is only compatible with PHP 5.4.6 or later.
... iterator reaches the end.
Adds the initial classes.