I currently manage a library which has a lot of public usage, and I had a question about semantic versioning. I want to refactor one fairly important part of the library which is implemented incorrectly - and has always been implemented incorrectly. But doing this would mean changes to the public API, which is a major decision.
The change I want to make revolves around how iterators are used. Currently, users have to do this:
while ($element = $iterator->next()) {
// ...
}
Which is incorrect, at least in PHP's native Iterator interface. I want to replace with this:
while ($iterator->valid()) {
$element = $iterator->current();
// ...
$iterator->next();
}
which is analogous to:
foreach ($iterator as $element) {
// ...
}
If you look at Tom's guide to semantic versioning, he clearly states that any changes to the public API (i.e. those which are not backward compatible), should justify a major release. So the library would jump from 1.7.3 to 2.0.0 which, for me, is a step too far. We're only talking about one feature being fixed.
I do have plans to eventually release 2.0.0, but I thought this was when you completely rewrote the library and implemented numerous public API changes. Does the introduction of this refactoring warrant a major version release? I really can't see how it does - I feel more comfortable releasing it as 1.8.0 or 1.7.4. Does anybody have some advice?
next()
method is used to retrieve the current element AND move the internal pointer forward. Which is wrong.next()
should move the pointer, andcurrent()
is used to retrieve...next()
only that is moves the pointer, this really doesn't break compatibility