Skip to content

Commit ca4ca9e

Browse files
committed
remove deprecations in subscriptions
1 parent 9b9ae9f commit ca4ca9e

22 files changed

Lines changed: 31 additions & 302 deletions

baseline.xml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,6 @@
149149
<code><![CDATA[(int)$data['playhead']]]></code>
150150
</ArgumentTypeCoercion>
151151
</file>
152-
<file src="src/Subscription/Engine/DefaultSubscriptionEngine.php">
153-
<DeprecatedInterface>
154-
<code><![CDATA[SubscriberAccessor|null]]></code>
155-
</DeprecatedInterface>
156-
<DeprecatedMethod>
157-
<code><![CDATA[realSubscriber]]></code>
158-
</DeprecatedMethod>
159-
</file>
160152
<file src="src/Subscription/Engine/GapResolverStoreMessageLoader.php">
161153
<InvalidReturnType>
162154
<code><![CDATA[Generator<int, Message>]]></code>
@@ -191,10 +183,6 @@
191183
</PossiblyNullPropertyFetch>
192184
</file>
193185
<file src="src/Subscription/Subscriber/MetadataSubscriberAccessor.php">
194-
<DeprecatedInterface>
195-
<code><![CDATA[MetadataSubscriberAccessor]]></code>
196-
<code><![CDATA[MetadataSubscriberAccessor]]></code>
197-
</DeprecatedInterface>
198186
<MixedAssignment>
199187
<code><![CDATA[$arguments[]]]></code>
200188
</MixedAssignment>
@@ -209,17 +197,6 @@
209197
<code><![CDATA[Closure(Message, Throwable):void|null]]></code>
210198
</MixedReturnTypeCoercion>
211199
</file>
212-
<file src="src/Subscription/Subscriber/MetadataSubscriberAccessorRepository.php">
213-
<DeprecatedClass>
214-
<code><![CDATA[new AggregateIdArgumentResolver()]]></code>
215-
</DeprecatedClass>
216-
</file>
217-
<file src="src/Subscription/Subscriber/SubscriberAccessorRepository.php">
218-
<DeprecatedInterface>
219-
<code><![CDATA[SubscriberAccessor|null]]></code>
220-
<code><![CDATA[iterable<SubscriberAccessor>]]></code>
221-
</DeprecatedInterface>
222-
</file>
223200
<file src="src/Subscription/ThrowableToErrorContextTransformer.php">
224201
<MixedAssignment>
225202
<code><![CDATA[$value]]></code>

phpstan-baseline.neon

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -222,30 +222,6 @@ parameters:
222222
count: 1
223223
path: tests/Integration/BasicImplementation/BasicIntegrationTest.php
224224

225-
-
226-
message: '#^Property Patchlevel\\EventSourcing\\Tests\\Integration\\BasicImplementation\\Profile\:\:\$id is never read, only written\.$#'
227-
identifier: property.onlyWritten
228-
count: 1
229-
path: tests/Integration/BasicImplementation/Profile.php
230-
231-
-
232-
message: '#^Property Patchlevel\\EventSourcing\\Tests\\Integration\\BasicImplementation\\ProfileWithCommands\:\:\$id is never read, only written\.$#'
233-
identifier: property.onlyWritten
234-
count: 1
235-
path: tests/Integration/BasicImplementation/ProfileWithCommands.php
236-
237-
-
238-
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\.$#'
239-
identifier: staticMethod.alreadyNarrowedType
240-
count: 2
241-
path: tests/Integration/ChildAggregate/ChildAggregateIntegrationTest.php
242-
243-
-
244-
message: '#^Property Patchlevel\\EventSourcing\\Tests\\Integration\\ChildAggregate\\Profile\:\:\$id is never read, only written\.$#'
245-
identifier: property.onlyWritten
246-
count: 1
247-
path: tests/Integration/ChildAggregate/Profile.php
248-
249225
-
250226
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\.$#'
251227
identifier: staticMethod.alreadyNarrowedType
@@ -426,12 +402,6 @@ parameters:
426402
count: 1
427403
path: tests/Unit/Fixture/ProfileWithSuppressAll.php
428404

429-
-
430-
message: '#^Property Patchlevel\\EventSourcing\\Tests\\Unit\\Fixture\\WrongNormalizerBasicAggregate\:\:\$id is unused\.$#'
431-
identifier: property.unused
432-
count: 1
433-
path: tests/Unit/Fixture/WrongNormalizerBasicAggregate.php
434-
435405
-
436406
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\.$#'
437407
identifier: argument.type

src/Subscription/Engine/DefaultSubscriptionEngine.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
use Patchlevel\EventSourcing\Subscription\Store\SubscriptionStore;
1717
use Patchlevel\EventSourcing\Subscription\Subscriber\BatchableSubscriber;
1818
use Patchlevel\EventSourcing\Subscription\Subscriber\MetadataSubscriberAccessor;
19-
use Patchlevel\EventSourcing\Subscription\Subscriber\RealSubscriberAccessor;
20-
use Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberAccessor;
2119
use Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberAccessorRepository;
2220
use Patchlevel\EventSourcing\Subscription\Subscription;
2321
use Psr\Log\LoggerInterface;
@@ -875,7 +873,7 @@ private function handleMessage(int $index, Message $message, Subscription $subsc
875873
return null;
876874
}
877875

878-
private function subscriber(string $subscriberId): SubscriberAccessor|null
876+
private function subscriber(string $subscriberId): MetadataSubscriberAccessor|null
879877
{
880878
return $this->subscriberRepository->get($subscriberId);
881879
}
@@ -959,18 +957,18 @@ private function discoverNewSubscriptions(): void
959957

960958
foreach ($this->subscriberRepository->all() as $subscriber) {
961959
foreach ($subscriptions as $subscription) {
962-
if ($subscription->id() === $subscriber->id()) {
960+
if ($subscription->id() === $subscriber->metadata()->id) {
963961
continue 2;
964962
}
965963
}
966964

967965
$subscription = new Subscription(
968-
$subscriber->id(),
969-
$subscriber->group(),
970-
$subscriber->runMode(),
966+
$subscriber->metadata()->id,
967+
$subscriber->metadata()->group,
968+
$subscriber->metadata()->runMode,
971969
);
972970

973-
if ($subscriber->setupMethod() === null && $subscriber->runMode() === RunMode::FromNow) {
971+
if ($subscriber->setupMethod() === null && $subscriber->metadata()->runMode === RunMode::FromNow) {
974972
if ($latestIndex === null) {
975973
$latestIndex = $this->messageLoader->lastIndex();
976974
}
@@ -984,7 +982,7 @@ private function discoverNewSubscriptions(): void
984982
$this->logger?->info(
985983
sprintf(
986984
'Subscription Engine: New Subscriber "%s" was found and added to the subscription store.',
987-
$subscriber->id(),
985+
$subscriber->metadata()->id,
988986
),
989987
);
990988
}
@@ -1021,14 +1019,14 @@ private function handleFailed(Subscription $subscription, Throwable $throwable,
10211019

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

1024-
if (!$subscriber instanceof MetadataSubscriberAccessor) {
1022+
if (!$subscriber) {
10251023
$subscription->failed($throwable);
10261024
$this->subscriptionManager->update($subscription);
10271025

10281026
return;
10291027
}
10301028

1031-
if ($subscriber->realSubscriber() instanceof BatchableSubscriber) {
1029+
if ($subscriber->subscriber() instanceof BatchableSubscriber) {
10321030
$subscription->failed($throwable);
10331031
$this->subscriptionManager->update($subscription);
10341032

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

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

1141-
if (!$subscriber instanceof RealSubscriberAccessor) {
1139+
if (!$subscriber) {
11421140
return null;
11431141
}
11441142

1145-
$realSubscriber = $subscriber->realSubscriber();
1143+
$realSubscriber = $subscriber->subscriber();
11461144

11471145
if (!$realSubscriber instanceof BatchableSubscriber) {
11481146
return null;

src/Subscription/Subscriber/ArgumentResolver/AggregateIdArgumentResolver.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/Subscription/Subscriber/MetadataSubscriberAccessor.php

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Patchlevel\EventSourcing\Message\Message;
1010
use Patchlevel\EventSourcing\Metadata\Subscriber\SubscribeMethodMetadata;
1111
use Patchlevel\EventSourcing\Metadata\Subscriber\SubscriberMetadata;
12-
use Patchlevel\EventSourcing\Subscription\RunMode;
1312
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\ArgumentResolver;
1413
use Throwable;
1514

@@ -18,7 +17,7 @@
1817
use function array_map;
1918

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

48-
/** @deprecated use `->metadata()->id` instead */
49-
public function id(): string
50-
{
51-
return $this->metadata->id;
52-
}
53-
54-
/** @deprecated use `->metadata()->group` instead */
55-
public function group(): string
56-
{
57-
return $this->metadata->group;
58-
}
59-
60-
/** @deprecated use `->metadata()->runMode` instead */
61-
public function runMode(): RunMode
62-
{
63-
return $this->metadata->runMode;
64-
}
65-
6647
public function setupMethod(): Closure|null
6748
{
6849
$method = $this->metadata->setupMethod;
@@ -180,14 +161,4 @@ private function resolvers(string $eventClass, SubscribeMethodMetadata $method):
180161

181162
return $resolvers;
182163
}
183-
184-
/**
185-
* @deprecated use `->metadata()` instead
186-
*
187-
* @return T
188-
*/
189-
public function realSubscriber(): object
190-
{
191-
return $this->subscriber;
192-
}
193164
}

src/Subscription/Subscriber/MetadataSubscriberAccessorRepository.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Patchlevel\EventSourcing\Metadata\Subscriber\AttributeSubscriberMetadataFactory;
88
use Patchlevel\EventSourcing\Metadata\Subscriber\SubscriberMetadataFactory;
9-
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\AggregateIdArgumentResolver;
109
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\ArgumentResolver;
1110
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\EventArgumentResolver;
1211
use Patchlevel\EventSourcing\Subscription\Subscriber\ArgumentResolver\MessageArgumentResolver;
@@ -41,7 +40,6 @@ public function __construct(
4140
[
4241
new MessageArgumentResolver(),
4342
new EventArgumentResolver(),
44-
new AggregateIdArgumentResolver(),
4543
new RecordedOnArgumentResolver(),
4644
],
4745
);

src/Subscription/Subscriber/RealSubscriberAccessor.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/Subscription/Subscriber/SubscriberAccessor.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/Subscription/Subscriber/SubscriberAccessorRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
interface SubscriberAccessorRepository
88
{
9-
/** @return iterable<SubscriberAccessor> */
9+
/** @return iterable<MetadataSubscriberAccessor> */
1010
public function all(): iterable;
1111

12-
public function get(string $id): SubscriberAccessor|null;
12+
public function get(string $id): MetadataSubscriberAccessor|null;
1313
}

tests/Benchmark/BasicImplementation/Events/NameChanged.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
namespace Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events;
66

77
use Patchlevel\EventSourcing\Attribute\Event;
8+
use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\ProfileId;
89

910
#[Event('profile.name_changed')]
1011
final class NameChanged
1112
{
1213
public function __construct(
14+
public ProfileId $profileId,
1315
public string $name,
1416
) {
1517
}

0 commit comments

Comments
 (0)