-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] feature/countable stream iterator #346
[WIP] feature/countable stream iterator #346
Conversation
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.
looks good.
use Countable; | ||
use Iterator; | ||
|
||
abstract class StreamIterator implements Countable, Iterator |
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.
I think this should be an interface extending the other two, as there is not any implementation here.
The iterator instance returned is an implementation detail. We guarantee only the iterator interface as return type, therefore this is not a bc. |
d48c946
to
c23e10d
Compare
@prolic This is what I came up with. As always naming is an issue, php isn't consistent when it comes to interface naming. IMO 'Iterator' should have been called 'Iterable'.
This PR;
implements
Iterator and Countable.Iterator
. It does not seem not possible to change theProoph\EventStore\ReadOnlyEventStore
interface to have a return type ofStreamIterator
without a BC break. :-( I do believe it is a minor BC as 'probably' will only break tests that use ArrayIterator or EmptyIterator (like you did).Q: Is there a reason you are utilizing the EmptyIterator over an empty ArrayIterator?
Although I also provided an EmptyStreamIterator (you were using EmptyIterator) I think an ArrayStreamIterator (with an empty array) would be just as good. Both are countable now, but it might be a possibly BC break. Probably anyone currently checking for
$i instanceof EmptyIterator
somewhere.