diff --git a/baseline.xml b/baseline.xml
index 13a65ec8..f1994c1f 100644
--- a/baseline.xml
+++ b/baseline.xml
@@ -251,6 +251,14 @@
+
+
+ close()]]>
+
+
+
+
+
diff --git a/src/Message/Message.php b/src/Message/Message.php
index 0085354c..5d0162ed 100644
--- a/src/Message/Message.php
+++ b/src/Message/Message.php
@@ -10,7 +10,7 @@
use function is_a;
/**
- * @template-covariant T of object
+ * @template-covariant T of object = object
* @psalm-immutable
*/
final class Message
diff --git a/src/Store/Criteria/StreamCriterion.php b/src/Store/Criteria/StreamCriterion.php
index 1782e836..69bd6f05 100644
--- a/src/Store/Criteria/StreamCriterion.php
+++ b/src/Store/Criteria/StreamCriterion.php
@@ -4,10 +4,6 @@
namespace Patchlevel\EventSourcing\Store\Criteria;
-use Patchlevel\EventSourcing\Store\InvalidStreamName;
-
-use function preg_match;
-
final class StreamCriterion
{
/** @var list */
@@ -16,12 +12,6 @@ final class StreamCriterion
public function __construct(
string ...$streamName,
) {
- foreach ($streamName as $name) {
- if (!preg_match('/^[^*]*\*?$/', $name)) {
- throw new InvalidStreamName($name);
- }
- }
-
$this->streamName = $streamName;
}
diff --git a/src/Store/StreamDoctrineDbalStore.php b/src/Store/StreamDoctrineDbalStore.php
index f7bc2e15..9cfdc431 100644
--- a/src/Store/StreamDoctrineDbalStore.php
+++ b/src/Store/StreamDoctrineDbalStore.php
@@ -52,9 +52,9 @@
use function in_array;
use function is_int;
use function is_string;
-use function mb_substr;
use function sprintf;
-use function str_ends_with;
+use function str_contains;
+use function str_replace;
final class StreamDoctrineDbalStore implements StreamStore, SubscriptionStore, DoctrineSchemaConfigurator
{
@@ -159,9 +159,9 @@ private function applyCriteria(QueryBuilder $builder, Criteria $criteria): void
$streamFilters = [];
foreach ($criterion->streamName as $index => $streamName) {
- if (str_ends_with($streamName, '*')) {
+ if (str_contains($streamName, '*')) {
$streamFilters[] = 'stream LIKE :stream_' . $index;
- $builder->setParameter('stream_' . $index, mb_substr($streamName, 0, -1) . '%');
+ $builder->setParameter('stream_' . $index, str_replace('*', '%', $streamName));
} else {
$streamFilters[] = 'stream = :stream_' . $index;
$builder->setParameter('stream_' . $index, $streamName);
diff --git a/tests/Integration/Store/StreamDoctrineDbalStoreTest.php b/tests/Integration/Store/StreamDoctrineDbalStoreTest.php
index 892c265c..39e7fb51 100644
--- a/tests/Integration/Store/StreamDoctrineDbalStoreTest.php
+++ b/tests/Integration/Store/StreamDoctrineDbalStoreTest.php
@@ -381,6 +381,16 @@ public function testLoadWithWildcard(): void
} finally {
$stream?->close();
}
+
+ try {
+ $stream = $this->store->load(new Criteria(new StreamCriterion('*-*')));
+
+ $messages = iterator_to_array($stream);
+
+ self::assertCount(2, $messages);
+ } finally {
+ $stream?->close();
+ }
}
public function testStreams(): void
diff --git a/tests/Unit/Store/StreamDoctrineDbalStoreTest.php b/tests/Unit/Store/StreamDoctrineDbalStoreTest.php
index d5378901..668b3ea3 100644
--- a/tests/Unit/Store/StreamDoctrineDbalStoreTest.php
+++ b/tests/Unit/Store/StreamDoctrineDbalStoreTest.php
@@ -30,7 +30,6 @@
use Patchlevel\EventSourcing\Store\Header\PlayheadHeader;
use Patchlevel\EventSourcing\Store\Header\RecordedOnHeader;
use Patchlevel\EventSourcing\Store\Header\StreamNameHeader;
-use Patchlevel\EventSourcing\Store\InvalidStreamName;
use Patchlevel\EventSourcing\Store\MissingDataForStorage;
use Patchlevel\EventSourcing\Store\StreamDoctrineDbalStore;
use Patchlevel\EventSourcing\Store\UniqueConstraintViolation;
@@ -356,39 +355,6 @@ public function testLoadWithLikeAll(): void
self::assertSame(null, $stream->position());
}
- public function testLoadWithLikeInvalid(): void
- {
- $connection = $this->prophesize(Connection::class);
-
- $abstractPlatform = $this->prophesize(AbstractPlatform::class);
-
- $connection->getDatabasePlatform()->willReturn($abstractPlatform->reveal());
- $queryBuilder = new QueryBuilder($connection->reveal());
- $connection->createQueryBuilder()->willReturn($queryBuilder);
-
- $eventSerializer = $this->prophesize(EventSerializer::class);
- $headersSerializer = $this->prophesize(HeadersSerializer::class);
-
- $doctrineDbalStore = new StreamDoctrineDbalStore(
- $connection->reveal(),
- $eventSerializer->reveal(),
- $headersSerializer->reveal(),
- );
-
- $this->expectException(InvalidStreamName::class);
-
- $stream = $doctrineDbalStore->load(
- (new CriteriaBuilder())
- ->streamName('*-*')
- ->fromPlayhead(0)
- ->archived(false)
- ->build(),
- );
-
- self::assertSame(null, $stream->index());
- self::assertSame(null, $stream->position());
- }
-
public function testLoadMultipleStream(): void
{
$connection = $this->prophesize(Connection::class);