prooph / event-store

PHP 7.4 EventStore Implementation
http://getprooph.org
BSD 3-Clause "New" or "Revised" License
547 stars 74 forks source link

Upcasting broken for projections in v7 #389

Closed marcuswinkler closed 4 years ago

marcuswinkler commented 4 years ago

After upgrading from 7.5.1 to 7.5.6 I'm getting the following error:

[TypeError] Argument 2 passed to Prooph\EventStore\StreamIterator\MergedStreamIterator::__construct() must implement i nterface Prooph\EventStore\StreamIterator\StreamIterator, instance of Prooph\EventStore\Upcasting\UpcastingIterator give n, called in /var/www/vendor/prooph/event-store/src/Projection/InMemoryEventStoreReadModelProjector.php on line 331

The introduction of the MergedStreamIterator into the projectors in #367 seems to have broken upcasting. When the upcasting plugin is enabled, the event store returns an UpcastingIterator, which does not implement the StreamIterator interface required by MergedStreamIterator.

All the StreamIterator does over Iterator is adding the Countable interface. Is there a reason why MergedStreamIterator must be countable? Seems like an easy fix to just drop the count() method and make it work with simple iterators.