Skip to content
Merged
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
23 changes: 0 additions & 23 deletions baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,6 @@
<code><![CDATA[(int)$data['playhead']]]></code>
</ArgumentTypeCoercion>
</file>
<file src="src/Subscription/Engine/DefaultSubscriptionEngine.php">
<DeprecatedInterface>
<code><![CDATA[SubscriberAccessor|null]]></code>
</DeprecatedInterface>
<DeprecatedMethod>
<code><![CDATA[realSubscriber]]></code>
</DeprecatedMethod>
</file>
<file src="src/Subscription/Engine/GapResolverStoreMessageLoader.php">
<InvalidReturnType>
<code><![CDATA[Generator<int, Message>]]></code>
Expand Down Expand Up @@ -191,10 +183,6 @@
</PossiblyNullPropertyFetch>
</file>
<file src="src/Subscription/Subscriber/MetadataSubscriberAccessor.php">
<DeprecatedInterface>
<code><![CDATA[MetadataSubscriberAccessor]]></code>
<code><![CDATA[MetadataSubscriberAccessor]]></code>
</DeprecatedInterface>
<MixedAssignment>
<code><![CDATA[$arguments[]]]></code>
</MixedAssignment>
Expand All @@ -209,17 +197,6 @@
<code><![CDATA[Closure(Message, Throwable):void|null]]></code>
</MixedReturnTypeCoercion>
</file>
<file src="src/Subscription/Subscriber/MetadataSubscriberAccessorRepository.php">
<DeprecatedClass>
<code><![CDATA[new AggregateIdArgumentResolver()]]></code>
</DeprecatedClass>
</file>
<file src="src/Subscription/Subscriber/SubscriberAccessorRepository.php">
<DeprecatedInterface>
<code><![CDATA[SubscriberAccessor|null]]></code>
<code><![CDATA[iterable<SubscriberAccessor>]]></code>
</DeprecatedInterface>
</file>
<file src="src/Subscription/ThrowableToErrorContextTransformer.php">
<MixedAssignment>
<code><![CDATA[$value]]></code>
Expand Down
30 changes: 0 additions & 30 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -222,30 +222,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: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Tests\\\\Integration\\\\ChildAggregate\\\\Profile'' and Patchlevel\\EventSourcing\\Tests\\Integration\\ChildAggregate\\Profile will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 2
path: tests/Integration/ChildAggregate/ChildAggregateIntegrationTest.php

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

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Patchlevel\\\\EventSourcing\\\\Tests\\\\Integration\\\\MicroAggregate\\\\Profile'' and Patchlevel\\EventSourcing\\Tests\\Integration\\MicroAggregate\\Profile will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
Expand Down Expand Up @@ -426,12 +402,6 @@ parameters:
count: 1
path: tests/Unit/Fixture/ProfileWithSuppressAll.php

-
message: '#^Property Patchlevel\\EventSourcing\\Tests\\Unit\\Fixture\\WrongNormalizerBasicAggregate\:\:\$id is unused\.$#'
identifier: property.unused
count: 1
path: tests/Unit/Fixture/WrongNormalizerBasicAggregate.php

-
message: '#^Parameter \#2 \$callable of class Patchlevel\\EventSourcing\\Message\\Translator\\ReplaceEventTranslator constructor expects callable\(Patchlevel\\EventSourcing\\Tests\\Unit\\Fixture\\MessagePublished\)\: object, Closure\(Patchlevel\\EventSourcing\\Tests\\Unit\\Fixture\\ProfileCreated\)\: Patchlevel\\EventSourcing\\Tests\\Unit\\Fixture\\ProfileVisited given\.$#'
identifier: argument.type
Expand Down
24 changes: 11 additions & 13 deletions src/Subscription/Engine/DefaultSubscriptionEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
use Patchlevel\EventSourcing\Subscription\Store\SubscriptionStore;
use Patchlevel\EventSourcing\Subscription\Subscriber\BatchableSubscriber;
use Patchlevel\EventSourcing\Subscription\Subscriber\MetadataSubscriberAccessor;
use Patchlevel\EventSourcing\Subscription\Subscriber\RealSubscriberAccessor;
use Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberAccessor;
use Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberAccessorRepository;
use Patchlevel\EventSourcing\Subscription\Subscription;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -875,7 +873,7 @@ private function handleMessage(int $index, Message $message, Subscription $subsc
return null;
}

private function subscriber(string $subscriberId): SubscriberAccessor|null
private function subscriber(string $subscriberId): MetadataSubscriberAccessor|null
{
return $this->subscriberRepository->get($subscriberId);
}
Expand Down Expand Up @@ -959,18 +957,18 @@ private function discoverNewSubscriptions(): void

foreach ($this->subscriberRepository->all() as $subscriber) {
foreach ($subscriptions as $subscription) {
if ($subscription->id() === $subscriber->id()) {
if ($subscription->id() === $subscriber->metadata()->id) {
continue 2;
}
}

$subscription = new Subscription(
$subscriber->id(),
$subscriber->group(),
$subscriber->runMode(),
$subscriber->metadata()->id,
$subscriber->metadata()->group,
$subscriber->metadata()->runMode,
);

if ($subscriber->setupMethod() === null && $subscriber->runMode() === RunMode::FromNow) {
if ($subscriber->setupMethod() === null && $subscriber->metadata()->runMode === RunMode::FromNow) {
if ($latestIndex === null) {
$latestIndex = $this->messageLoader->lastIndex();
}
Expand All @@ -984,7 +982,7 @@ private function discoverNewSubscriptions(): void
$this->logger?->info(
sprintf(
'Subscription Engine: New Subscriber "%s" was found and added to the subscription store.',
$subscriber->id(),
$subscriber->metadata()->id,
),
);
}
Expand Down Expand Up @@ -1021,14 +1019,14 @@ private function handleFailed(Subscription $subscription, Throwable $throwable,

$subscriber = $this->subscriber($subscription->id());

if (!$subscriber instanceof MetadataSubscriberAccessor) {
if (!$subscriber) {
$subscription->failed($throwable);
$this->subscriptionManager->update($subscription);

return;
}

if ($subscriber->realSubscriber() instanceof BatchableSubscriber) {
if ($subscriber->subscriber() instanceof BatchableSubscriber) {
$subscription->failed($throwable);
$this->subscriptionManager->update($subscription);

Expand Down Expand Up @@ -1138,11 +1136,11 @@ private function checkAndBeginBatch(Subscription $subscription): Error|null

$subscriber = $this->subscriber($subscription->id());

if (!$subscriber instanceof RealSubscriberAccessor) {
if (!$subscriber) {
return null;
}

$realSubscriber = $subscriber->realSubscriber();
$realSubscriber = $subscriber->subscriber();

if (!$realSubscriber instanceof BatchableSubscriber) {
return null;
Expand Down

This file was deleted.

31 changes: 1 addition & 30 deletions src/Subscription/Subscriber/MetadataSubscriberAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Metadata\Subscriber\SubscribeMethodMetadata;
use Patchlevel\EventSourcing\Metadata\Subscriber\SubscriberMetadata;
use Patchlevel\EventSourcing\Subscription\RunMode;
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\ArgumentResolver;
use Throwable;

Expand All @@ -18,7 +17,7 @@
use function array_map;

/** @template T of object */
final class MetadataSubscriberAccessor implements SubscriberAccessor, RealSubscriberAccessor
final class MetadataSubscriberAccessor
{
/** @var array<class-string, list<Closure(Message):void>> */
private array $subscribeCache = [];
Expand All @@ -45,24 +44,6 @@ public function subscriber(): object
return $this->subscriber;
}

/** @deprecated use `->metadata()->id` instead */
public function id(): string
{
return $this->metadata->id;
}

/** @deprecated use `->metadata()->group` instead */
public function group(): string
{
return $this->metadata->group;
}

/** @deprecated use `->metadata()->runMode` instead */
public function runMode(): RunMode
{
return $this->metadata->runMode;
}

public function setupMethod(): Closure|null
{
$method = $this->metadata->setupMethod;
Expand Down Expand Up @@ -180,14 +161,4 @@ private function resolvers(string $eventClass, SubscribeMethodMetadata $method):

return $resolvers;
}

/**
* @deprecated use `->metadata()` instead
*
* @return T
*/
public function realSubscriber(): object
{
return $this->subscriber;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Patchlevel\EventSourcing\Metadata\Subscriber\AttributeSubscriberMetadataFactory;
use Patchlevel\EventSourcing\Metadata\Subscriber\SubscriberMetadataFactory;
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\AggregateIdArgumentResolver;
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\ArgumentResolver;
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\EventArgumentResolver;
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\MessageArgumentResolver;
Expand Down Expand Up @@ -41,7 +40,6 @@ public function __construct(
[
new MessageArgumentResolver(),
new EventArgumentResolver(),
new AggregateIdArgumentResolver(),
new RecordedOnArgumentResolver(),
],
);
Expand Down
11 changes: 0 additions & 11 deletions src/Subscription/Subscriber/RealSubscriberAccessor.php

This file was deleted.

30 changes: 0 additions & 30 deletions src/Subscription/Subscriber/SubscriberAccessor.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Subscription/Subscriber/SubscriberAccessorRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

interface SubscriberAccessorRepository
{
/** @return iterable<SubscriberAccessor> */
/** @return iterable<MetadataSubscriberAccessor> */
public function all(): iterable;

public function get(string $id): SubscriberAccessor|null;
public function get(string $id): MetadataSubscriberAccessor|null;
}
2 changes: 2 additions & 0 deletions tests/Benchmark/BasicImplementation/Events/NameChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
namespace Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events;

use Patchlevel\EventSourcing\Attribute\Event;
use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\ProfileId;

#[Event('profile.name_changed')]
final class NameChanged
{
public function __construct(
public ProfileId $profileId,
public string $name,
) {
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Benchmark/BasicImplementation/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function create(ProfileId $id, string $name, string|null $email =

public function changeName(string $name): void
{
$this->recordThat(new NameChanged($name));
$this->recordThat(new NameChanged($this->id, $name));
}

public function changeEmail(string $email): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberUtil;
use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events\NameChanged;
use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events\ProfileCreated;
use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\ProfileId;

#[Projector('profile')]
final class BatchProfileProjector implements BatchableSubscriber
Expand Down Expand Up @@ -53,9 +52,9 @@ public function onProfileCreated(ProfileCreated $profileCreated): void
}

#[Subscribe(NameChanged::class)]
public function onNameChanged(NameChanged $nameChanged, ProfileId $profileId): void
public function onNameChanged(NameChanged $nameChanged): void
{
$this->nameChanged[$profileId->toString()] = $nameChanged->name;
$this->nameChanged[$nameChanged->profileId->toString()] = $nameChanged->name;
}

public function table(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberUtil;
use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events\NameChanged;
use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events\ProfileCreated;
use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\ProfileId;

#[Projector('profile')]
final class ProfileProjector
Expand Down Expand Up @@ -49,12 +48,12 @@ public function onProfileCreated(ProfileCreated $profileCreated): void
}

#[Subscribe(NameChanged::class)]
public function onNameChanged(NameChanged $nameChanged, ProfileId $profileId): void
public function onNameChanged(NameChanged $nameChanged): void
{
$this->connection->update(
$this->table(),
['name' => $nameChanged->name],
['id' => $profileId->toString()],
['id' => $nameChanged->profileId->toString()],
);
}

Expand Down
Loading
Loading