Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
"doctrine/dbal": "^4.4.0",
"doctrine/migrations": "^3.3.2",
"patchlevel/hydrator": "^1.8.0",
"patchlevel/hydrator": "^1.23.0",
"patchlevel/worker": "^1.4.0",
"psr/cache": "^2.0.0 || ^3.0.0",
"psr/clock": "^1.0",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 15 additions & 44 deletions docs/pages/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,9 @@ After we have defined everything, we still have to plug the whole thing together
```php
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Tools\DsnParser;
use Patchlevel\EventSourcing\Metadata\AggregateRoot\AttributeAggregateRootRegistryFactory;
use Patchlevel\EventSourcing\Repository\DefaultRepositoryManager;
use Patchlevel\EventSourcing\Serializer\DefaultEventSerializer;
use Patchlevel\EventSourcing\Store\DoctrineDbalStore;
use Patchlevel\EventSourcing\Subscription\Engine\DefaultSubscriptionEngine;
use Patchlevel\EventSourcing\Subscription\Repository\RunSubscriptionEngineRepositoryManager;
use Patchlevel\EventSourcing\Subscription\Store\DoctrineSubscriptionStore;
use Patchlevel\EventSourcing\Subscription\Subscriber\MetadataSubscriberAccessorRepository;

$connection = DriverManager::getConnection(
(new DsnParser())->parse('pdo-pgsql://user:secret@localhost/app'),
);
use Patchlevel\EventSourcing\Container\Configuration;
use Patchlevel\EventSourcing\Container\Factory;
use Patchlevel\EventSourcing\Repository\RepositoryManager;

$projectionConnection = DriverManager::getConnection(
(new DsnParser())->parse('pdo-pgsql://user:secret@localhost/projection'),
Expand All @@ -291,38 +282,18 @@ $projectionConnection = DriverManager::getConnection(
/* your own mailer */
$mailer;

$serializer = DefaultEventSerializer::createFromPaths(['src/Domain/Hotel/Event']);
$aggregateRegistry = (new AttributeAggregateRootRegistryFactory())->create(['src/Domain/Hotel']);

$eventStore = new DoctrineDbalStore(
$connection,
$serializer,
);

$hotelProjector = new HotelProjector($projectionConnection);

$subscriberRepository = new MetadataSubscriberAccessorRepository([
$hotelProjector,
new SendCheckInEmailProcessor($mailer),
]);

$subscriptionStore = new DoctrineSubscriptionStore($connection);

$engine = new DefaultSubscriptionEngine(
$eventStore,
$subscriptionStore,
$subscriberRepository,
);

$repositoryManager = new RunSubscriptionEngineRepositoryManager(
new DefaultRepositoryManager(
$aggregateRegistry,
$eventStore,
),
$engine,
);

$hotelRepository = $repositoryManager->get(Hotel::class);
$configuration = Configuration::createWithConnectionUrl('pdo-pgsql://user:secret@localhost/app')
->withDefaultSettings(
['src/Domain/Hotel'],
['src/Domain/Hotel/Event'],
)
->withSubscribers([
new HotelProjector($projectionConnection),
new SendCheckInEmailProcessor($mailer)
]);
$container = Factory::create($configuration);

$hotelRepository = $container->get(RepositoryManager::class)->get(Hotel::class);
```
!!! note

Expand Down
222 changes: 210 additions & 12 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,102 @@ parameters:
count: 1
path: src/Console/DoctrineHelper.php

-
message: '#^Anonymous function should return Doctrine\\DBAL\\Connection but returns mixed\.$#'
identifier: return.type
count: 1
path: src/Container/Factory.php

-
message: '#^Anonymous function should return Patchlevel\\EventSourcing\\EventBus\\EventBus but returns mixed\.$#'
identifier: return.type
count: 1
path: src/Container/Factory.php

-
message: '#^Anonymous function should return Patchlevel\\EventSourcing\\Store\\Store but returns mixed\.$#'
identifier: return.type
count: 1
path: src/Container/Factory.php

-
message: '#^Anonymous function should return Psr\\Log\\LoggerInterface but returns mixed\.$#'
identifier: return.type
count: 1
path: src/Container/Factory.php

-
message: '#^Parameter \#1 \$connection of class Patchlevel\\EventSourcing\\Console\\Command\\DatabaseCreateCommand constructor expects Doctrine\\DBAL\\Connection, object given\.$#'
identifier: argument.type
count: 1
path: src/Container/Factory.php

-
message: '#^Parameter \#1 \$connection of class Patchlevel\\EventSourcing\\Console\\Command\\DatabaseDropCommand constructor expects Doctrine\\DBAL\\Connection, object given\.$#'
identifier: argument.type
count: 1
path: src/Container/Factory.php

-
message: '#^Parameter \#1 \$connection of class Patchlevel\\EventSourcing\\Cryptography\\ExtensionDoctrineCipherKeyStore constructor expects Doctrine\\DBAL\\Connection, object given\.$#'
identifier: argument.type
count: 1
path: src/Container/Factory.php

-
message: '#^Parameter \#1 \$connection of class Patchlevel\\EventSourcing\\Schema\\DoctrineSchemaDirector constructor expects Doctrine\\DBAL\\Connection, object given\.$#'
identifier: argument.type
count: 1
path: src/Container/Factory.php

-
message: '#^Parameter \#1 \$connection of class Patchlevel\\EventSourcing\\Store\\StreamDoctrineDbalStore constructor expects Doctrine\\DBAL\\Connection, object given\.$#'
identifier: argument.type
count: 2
path: src/Container/Factory.php

-
message: '#^Parameter \#1 \$connection of class Patchlevel\\EventSourcing\\Subscription\\Store\\DoctrineSubscriptionStore constructor expects Doctrine\\DBAL\\Connection, object given\.$#'
identifier: argument.type
count: 1
path: src/Container/Factory.php

-
message: '#^Parameter \#1 \$strategies of class Patchlevel\\EventSourcing\\Subscription\\RetryStrategy\\RetryStrategyRepository constructor expects array\<string, Patchlevel\\EventSourcing\\Subscription\\RetryStrategy\\RetryStrategy\>, array\<string, mixed\> given\.$#'
identifier: argument.type
count: 1
path: src/Container/Factory.php

-
message: '#^Parameter \#2 \$baseDelay of class Patchlevel\\EventSourcing\\Subscription\\RetryStrategy\\ClockBasedRetryStrategy constructor expects int, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Container/Factory.php

-
message: '#^Parameter \#2 \$newStore of class Patchlevel\\EventSourcing\\Console\\Command\\StoreMigrateCommand constructor expects Patchlevel\\EventSourcing\\Store\\Store, object given\.$#'
identifier: argument.type
count: 1
path: src/Container/Factory.php

-
message: '#^Parameter \#3 \$delayFactor of class Patchlevel\\EventSourcing\\Subscription\\RetryStrategy\\ClockBasedRetryStrategy constructor expects float, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Container/Factory.php

-
message: '#^Parameter \#4 \$maxAttempts of class Patchlevel\\EventSourcing\\Subscription\\RetryStrategy\\ClockBasedRetryStrategy constructor expects int\<1, max\>, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Container/Factory.php

-
message: '#^Strict comparison using \!\=\= between ''custom'' and ''custom'' will always evaluate to false\.$#'
identifier: notIdentical.alwaysFalse
count: 1
path: src/Container/Factory.php

-
message: '#^Parameter \#1 \$key of class Patchlevel\\Hydrator\\Cryptography\\Cipher\\CipherKey constructor expects non\-empty\-string, string given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -246,18 +342,6 @@ parameters:
count: 1
path: tests/Integration/BasicImplementation/BasicIntegrationTest.php

-
message: '#^Property Patchlevel\\EventSourcing\\Tests\\Integration\\BasicImplementation\\Profile\:\:\$id is never read, only written\.$#'
identifier: property.onlyWritten
count: 1
path: tests/Integration/BasicImplementation/Profile.php

-
message: '#^Property Patchlevel\\EventSourcing\\Tests\\Integration\\BasicImplementation\\ProfileWithCommands\:\:\$id is never read, only written\.$#'
identifier: property.onlyWritten
count: 1
path: tests/Integration/BasicImplementation/ProfileWithCommands.php

-
message: '#^Cannot access offset ''name'' on array\<string, mixed\>\|false\.$#'
identifier: offsetAccess.nonOffsetAccessible
Expand Down Expand Up @@ -372,6 +456,120 @@ parameters:
count: 5
path: tests/Unit/CommandBus/InstantRetryCommandBusTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Console\\\\Command\\\\DebugCommand'' and Patchlevel\\EventSourcing\\Console\\Command\\DebugCommand will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Console\\\\Command\\\\ShowAggregateCommand'' and Patchlevel\\EventSourcing\\Console\\Command\\ShowAggregateCommand will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Console\\\\Command\\\\ShowCommand'' and Patchlevel\\EventSourcing\\Console\\Command\\ShowCommand will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Console\\\\Command\\\\SubscriptionBootCommand'' and Patchlevel\\EventSourcing\\Console\\Command\\SubscriptionBootCommand will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Console\\\\Command\\\\SubscriptionPauseCommand'' and Patchlevel\\EventSourcing\\Console\\Command\\SubscriptionPauseCommand will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Console\\\\Command\\\\SubscriptionReactivateCommand'' and Patchlevel\\EventSourcing\\Console\\Command\\SubscriptionReactivateCommand will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Console\\\\Command\\\\SubscriptionRemoveCommand'' and Patchlevel\\EventSourcing\\Console\\Command\\SubscriptionRemoveCommand will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Console\\\\Command\\\\SubscriptionRunCommand'' and Patchlevel\\EventSourcing\\Console\\Command\\SubscriptionRunCommand will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Console\\\\Command\\\\SubscriptionSetupCommand'' and Patchlevel\\EventSourcing\\Console\\Command\\SubscriptionSetupCommand will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Console\\\\Command\\\\SubscriptionStatusCommand'' and Patchlevel\\EventSourcing\\Console\\Command\\SubscriptionStatusCommand will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Console\\\\Command\\\\SubscriptionTeardownCommand'' and Patchlevel\\EventSourcing\\Console\\Command\\SubscriptionTeardownCommand will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Console\\\\Command\\\\WatchCommand'' and Patchlevel\\EventSourcing\\Console\\Command\\WatchCommand will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Metadata\\\\AggregateRoot\\\\AggregateRootRegistry'' and Patchlevel\\EventSourcing\\Metadata\\AggregateRoot\\AggregateRootRegistry will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Metadata\\\\Event\\\\EventRegistry'' and Patchlevel\\EventSourcing\\Metadata\\Event\\EventRegistry will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Metadata\\\\Message\\\\MessageHeaderRegistry'' and Patchlevel\\EventSourcing\\Metadata\\Message\\MessageHeaderRegistry will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Repository\\\\MessageDecorator\\\\SplitStreamDecorator'' and Patchlevel\\EventSourcing\\Repository\\MessageDecorator\\SplitStreamDecorator will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Serializer\\\\DefaultEventSerializer'' and Patchlevel\\EventSourcing\\Serializer\\DefaultEventSerializer will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Store\\\\StreamDoctrineDbalStore'' and Patchlevel\\EventSourcing\\Store\\StreamDoctrineDbalStore will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 8
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Subscription\\\\RetryStrategy\\\\RetryStrategyRepository'' and Patchlevel\\EventSourcing\\Subscription\\RetryStrategy\\RetryStrategyRepository will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 1
path: tests/Unit/Container/FactoryTest.php

-
message: '#^Parameter \#1 \$data of static method Patchlevel\\EventSourcing\\Tests\\Unit\\Fixture\\Message\:\:fromArray\(\) expects array\{id\: string, text\: string, createdAt\: string\}, array\<mixed, mixed\> given\.$#'
identifier: argument.type
Expand Down
Loading
Loading