Skip to content

Commit

Permalink
deprecate subscriber accessor interface and remove experimantel trace…
Browse files Browse the repository at this point in the history
… feature
  • Loading branch information
DavidBadura committed Dec 5, 2024
1 parent a9660a0 commit 3cdc4b4
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 353 deletions.
23 changes: 23 additions & 0 deletions baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@
<code><![CDATA[$data['playhead'] === null ? null : (int)$data['playhead']]]></code>
</ArgumentTypeCoercion>
</file>
<file src="src/Subscription/Engine/DefaultSubscriptionEngine.php">
<DeprecatedInterface>
<code><![CDATA[SubscriberAccessor|null]]></code>
</DeprecatedInterface>
</file>
<file src="src/Subscription/Store/DoctrineSubscriptionStore.php">
<MixedArgument>
<code><![CDATA[$context]]></code>
Expand All @@ -126,6 +131,10 @@
</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 @@ -135,6 +144,12 @@
<code><![CDATA[$methodName]]></code>
</MixedMethodCall>
</file>
<file src="src/Subscription/Subscriber/SubscriberAccessorRepository.php">
<DeprecatedInterface>
<code><![CDATA[SubscriberAccessor|null]]></code>
<code><![CDATA[iterable<SubscriberAccessor>]]></code>
</DeprecatedInterface>
</file>
<file src="tests/Benchmark/PersonalDataBench.php">
<MissingConstructor>
<code><![CDATA[$multipleEventsId]]></code>
Expand Down Expand Up @@ -354,4 +369,12 @@
<code><![CDATA[$update1]]></code>
</PossiblyUndefinedArrayOffset>
</file>
<file src="tests/Unit/Subscription/Subscriber/MetadataSubscriberAccessorTest.php">
<DeprecatedMethod>
<code><![CDATA[group]]></code>
<code><![CDATA[id]]></code>
<code><![CDATA[realSubscriber]]></code>
<code><![CDATA[runMode]]></code>
</DeprecatedMethod>
</file>
</files>
15 changes: 0 additions & 15 deletions src/Debug/Trace/Trace.php

This file was deleted.

38 changes: 0 additions & 38 deletions src/Debug/Trace/TraceDecorator.php

This file was deleted.

15 changes: 0 additions & 15 deletions src/Debug/Trace/TraceHeader.php

This file was deleted.

35 changes: 0 additions & 35 deletions src/Debug/Trace/TraceStack.php

This file was deleted.

78 changes: 0 additions & 78 deletions src/Debug/Trace/TraceableSubscriberAccessor.php

This file was deleted.

52 changes: 0 additions & 52 deletions src/Debug/Trace/TraceableSubscriberAccessorRepository.php

This file was deleted.

2 changes: 0 additions & 2 deletions src/Metadata/Message/MessageHeaderRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Patchlevel\EventSourcing\Metadata\Message;

use Patchlevel\EventSourcing\Aggregate\AggregateHeader;
use Patchlevel\EventSourcing\Debug\Trace\TraceHeader;
use Patchlevel\EventSourcing\Store\ArchivedHeader;
use Patchlevel\EventSourcing\Store\StreamHeader;
use Patchlevel\EventSourcing\Store\StreamStartHeader;
Expand Down Expand Up @@ -76,7 +75,6 @@ public static function createWithInternalHeaders(array $headerNameToClassMap = [
$internalHeaders = [
'stream' => StreamHeader::class,
'aggregate' => AggregateHeader::class,
'trace' => TraceHeader::class,
'archived' => ArchivedHeader::class,
'newStreamStart' => StreamStartHeader::class,
];
Expand Down
25 changes: 24 additions & 1 deletion src/Subscription/Subscriber/MetadataSubscriberAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,47 @@
use function array_map;
use function array_merge;

/** @template T of object */
final class MetadataSubscriberAccessor implements SubscriberAccessor, RealSubscriberAccessor
{
/** @var array<class-string, list<Closure(Message):void>> */
private array $subscribeCache = [];

/** @param list<ArgumentResolver> $argumentResolvers */
/**
* @param T $subscriber
* @param list<ArgumentResolver> $argumentResolvers
*/
public function __construct(
private readonly object $subscriber,
private readonly SubscriberMetadata $metadata,
private readonly array $argumentResolvers,
) {
}

public function metadata(): SubscriberMetadata
{
return $this->metadata;
}

/** @return T */
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;
Expand Down Expand Up @@ -139,6 +157,11 @@ private function resolvers(string $eventClass, SubscribeMethodMetadata $method):
return $resolvers;
}

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

final class MetadataSubscriberAccessorRepository implements SubscriberAccessorRepository
{
/** @var array<string, SubscriberAccessor> */
/** @var array<string, MetadataSubscriberAccessor> */
private array $subscribersMap = [];

/** @var list<ArgumentResolver> $argumentResolvers */
Expand All @@ -47,20 +47,20 @@ public function __construct(
);
}

/** @return iterable<SubscriberAccessor> */
/** @return iterable<MetadataSubscriberAccessor> */
public function all(): iterable
{
return array_values($this->subscriberAccessorMap());
}

public function get(string $id): SubscriberAccessor|null
public function get(string $id): MetadataSubscriberAccessor|null
{
$map = $this->subscriberAccessorMap();

return $map[$id] ?? null;
}

/** @return array<string, SubscriberAccessor> */
/** @return array<string, MetadataSubscriberAccessor> */
private function subscriberAccessorMap(): array
{
if ($this->subscribersMap !== []) {
Expand Down
Loading

0 comments on commit 3cdc4b4

Please sign in to comment.