Skip to content

Commit 4d6af0b

Browse files
committed
Fix SA
1 parent 2b67a80 commit 4d6af0b

7 files changed

+20
-14
lines changed

Diff for: baseline.xml

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="6.7.1@a2f190972555ea01b0cfcc1913924d6c5fc1a64e">
2+
<files psalm-version="6.8.4@7ee919229d510c5834af3112072f4b12cd7bb51a">
33
<file src="src/Aggregate/AggregateRootBehaviour.php">
44
<UnsafeInstantiation>
55
<code><![CDATA[new static()]]></code>
@@ -83,6 +83,15 @@
8383
<code><![CDATA[require_once $file]]></code>
8484
</UnresolvableInclude>
8585
</file>
86+
<file src="src/QueryBus/ServiceHandlerProvider.php">
87+
<MixedArgument>
88+
<code><![CDATA[$service::{$handler->method}(...)]]></code>
89+
</MixedArgument>
90+
<MixedMethodCall>
91+
<code><![CDATA[$handler->method]]></code>
92+
<code><![CDATA[$service::{$handler->method}(...)]]></code>
93+
</MixedMethodCall>
94+
</file>
8695
<file src="src/Repository/DefaultRepository.php">
8796
<PossiblyNullArgument>
8897
<code><![CDATA[$streamName]]></code>

Diff for: src/Attribute/Answer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#[Attribute(Attribute::TARGET_METHOD)]
1010
final class Answer
1111
{
12-
/** @param class-string $queryClass */
12+
/** @param class-string|null $queryClass */
1313
public function __construct(
14-
public readonly string $queryClass,
14+
public readonly string|null $queryClass = null,
1515
) {
1616
}
1717
}

Diff for: src/QueryBus/ChainHandlerProvider.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Patchlevel\EventSourcing\QueryBus;
66

7-
87
final class ChainHandlerProvider implements HandlerProvider
98
{
109
/** @param iterable<HandlerProvider> $providers */
@@ -25,7 +24,7 @@ public function handlerForQuery(string $queryClass): iterable
2524
foreach ($this->providers as $provider) {
2625
$handlers = [
2726
...$handlers,
28-
...$provider->handlerForCommand($queryClass),
27+
...$provider->handlerForQuery($queryClass),
2928
];
3029
}
3130

Diff for: src/QueryBus/HandlerFinder.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ public static function findInClass(string $classString): iterable
2222
$reflectionClass = new ReflectionClass($classString);
2323

2424
foreach ($reflectionClass->getMethods() as $reflectionMethod) {
25-
$handleAttributes = $reflectionMethod->getAttributes(Answer::class);
25+
$answerAttributes = $reflectionMethod->getAttributes(Answer::class);
2626

27-
if ($handleAttributes === []) {
27+
if ($answerAttributes === []) {
2828
continue;
2929
}
3030

31-
$handle = $handleAttributes[0]->newInstance();
31+
$answer = $answerAttributes[0]->newInstance();
3232

33-
if ($handle->queryClass !== null) {
33+
if ($answer->queryClass !== null) {
3434
yield new HandlerReference(
35-
$handle->queryClass,
35+
$answer->queryClass,
3636
$reflectionMethod->getName(),
3737
$reflectionMethod->isStatic(),
3838
);

Diff for: src/QueryBus/HandlerProvider.php

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace Patchlevel\EventSourcing\QueryBus;
66

7-
use Patchlevel\EventSourcing\CommandBus\HandlerDescriptor;
8-
97
interface HandlerProvider
108
{
119
/**

Diff for: src/QueryBus/HandlerReference.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
final class HandlerReference
88
{
9-
/** @param class-string $commandClass */
9+
/** @param class-string $queryClass */
1010
public function __construct(
1111
public readonly string $queryClass,
1212
public readonly string $method,

Diff for: src/QueryBus/SyncQueryBus.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(
2626
}
2727
}
2828

29-
/** @throws HandlerNotFound */
29+
/** @throws InvalidQueryHandler */
3030
public function dispatch(object $query): mixed
3131
{
3232
$this->logger?->debug('QueryBus: dispatch query', ['query' => $query::class]);

0 commit comments

Comments
 (0)