Skip to content

Commit b24cedf

Browse files
committed
Fix psalm issues
1 parent 1a282de commit b24cedf

10 files changed

Lines changed: 160 additions & 17 deletions

File tree

psalm-baseline.xml

Lines changed: 123 additions & 6 deletions
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.10.0@9c0add4eb88d4b169ac04acb7c679918cbb9c252">
2+
<files psalm-version="6.12.0@cf420941d061a57050b6c468ef2c778faf40aee2">
33
<file src="src/Activity.php">
44
<ImplicitToStringCast>
55
<code><![CDATA[$type]]></code>
@@ -115,6 +115,11 @@
115115
<code><![CDATA[$workflowType]]></code>
116116
</PropertyNotSetInConstructor>
117117
</file>
118+
<file src="src/Client/Schedule/ScheduleHandle.php">
119+
<RawObjectIteration>
120+
<code><![CDATA[$response->getStartTime()]]></code>
121+
</RawObjectIteration>
122+
</file>
118123
<file src="src/Client/Schedule/ScheduleOptions.php">
119124
<DeprecatedProperty>
120125
<code><![CDATA[$this->namespace]]></code>
@@ -134,13 +139,22 @@
134139
<code><![CDATA[$options->namespace]]></code>
135140
<code><![CDATA[$options->namespace]]></code>
136141
</DeprecatedProperty>
142+
<RawObjectIteration>
143+
<code><![CDATA[$response->getSchedules()]]></code>
144+
</RawObjectIteration>
145+
</file>
146+
<file src="src/Client/Workflow/WorkflowExecutionHistory.php">
147+
<RawObjectIteration>
148+
<code><![CDATA[$history->getEvents()]]></code>
149+
</RawObjectIteration>
137150
</file>
138151
<file src="src/Client/WorkflowClient.php">
139152
<ArgumentTypeCoercion>
140153
<code><![CDATA[$counter]]></code>
154+
<code><![CDATA[$runID]]></code>
141155
<code><![CDATA[$signal]]></code>
142-
<code><![CDATA[$workflowType]]></code>
143-
<code><![CDATA[$workflowType]]></code>
156+
<code><![CDATA[$workflow->getID()]]></code>
157+
<code><![CDATA[$workflow->getID()]]></code>
144158
</ArgumentTypeCoercion>
145159
<DeprecatedClass>
146160
<code><![CDATA[new AnnotationReader()]]></code>
@@ -170,6 +184,9 @@
170184
<MoreSpecificReturnType>
171185
<code><![CDATA[static]]></code>
172186
</MoreSpecificReturnType>
187+
<RawObjectIteration>
188+
<code><![CDATA[$response->getExecutions()]]></code>
189+
</RawObjectIteration>
173190
<RedundantFunctionCall>
174191
<code><![CDATA[\sprintf]]></code>
175192
<code><![CDATA[\sprintf]]></code>
@@ -216,6 +233,11 @@
216233
<code><![CDATA[RetryOptions]]></code>
217234
</MissingImmutableAnnotation>
218235
</file>
236+
<file src="src/Common/Priority.php">
237+
<ArgumentTypeCoercion>
238+
<code><![CDATA[$priorityKey]]></code>
239+
</ArgumentTypeCoercion>
240+
</file>
219241
<file src="src/Common/RetryOptions.php">
220242
<PossiblyNullArgument>
221243
<code><![CDATA[DateInterval::toDuration($this->initialInterval)]]></code>
@@ -285,6 +307,10 @@
285307
</MoreSpecificImplementedParamType>
286308
</file>
287309
<file src="src/DataConverter/EncodedValues.php">
310+
<InvalidArgument>
311+
<code><![CDATA[$payloads->getPayloads()]]></code>
312+
<code><![CDATA[$payloads->getPayloads()]]></code>
313+
</InvalidArgument>
288314
<PossiblyNullIterator>
289315
<code><![CDATA[$this->values]]></code>
290316
</PossiblyNullIterator>
@@ -354,6 +380,39 @@
354380
<code><![CDATA[new static('', $e->getCode(), $e)]]></code>
355381
</UnsafeInstantiation>
356382
</file>
383+
<file src="src/Exception/Client/MultyOperation/OperationStatus.php">
384+
<InvalidArgument>
385+
<code><![CDATA[$message->getDetails()]]></code>
386+
</InvalidArgument>
387+
<MismatchingDocblockParamType>
388+
<code><![CDATA[\ArrayAccess<int, Any>&RepeatedField]]></code>
389+
</MismatchingDocblockParamType>
390+
<MismatchingDocblockPropertyType>
391+
<code><![CDATA[\ArrayAccess<int, Any>&RepeatedField]]></code>
392+
</MismatchingDocblockPropertyType>
393+
<MismatchingDocblockReturnType>
394+
<code><![CDATA[\ArrayAccess<int, Any>&RepeatedField]]></code>
395+
</MismatchingDocblockReturnType>
396+
</file>
397+
<file src="src/Exception/Client/ServiceClientException.php">
398+
<ImplementedReturnTypeMismatch>
399+
<code><![CDATA[RepeatedField]]></code>
400+
</ImplementedReturnTypeMismatch>
401+
<InvalidReturnStatement>
402+
<code><![CDATA[$this->status->getDetails()]]></code>
403+
</InvalidReturnStatement>
404+
<InvalidReturnType>
405+
<code><![CDATA[RepeatedField]]></code>
406+
</InvalidReturnType>
407+
</file>
408+
<file src="src/Exception/Client/UnpackDetailsTrait.php">
409+
<RawObjectIteration>
410+
<code><![CDATA[$details]]></code>
411+
</RawObjectIteration>
412+
<UndefinedInterfaceMethod>
413+
<code><![CDATA[count]]></code>
414+
</UndefinedInterfaceMethod>
415+
</file>
357416
<file src="src/Exception/Client/WorkflowException.php">
358417
<UnsafeInstantiation>
359418
<code><![CDATA[new static(null, $execution, $workflowType, $previous)]]></code>
@@ -373,6 +432,10 @@
373432
</MoreSpecificReturnType>
374433
</file>
375434
<file src="src/Exception/Failure/FailureConverter.php">
435+
<ArgumentTypeCoercion>
436+
<code><![CDATA[$execution->getRunId()]]></code>
437+
<code><![CDATA[$execution->getWorkflowId()]]></code>
438+
</ArgumentTypeCoercion>
376439
<DocblockTypeContradiction>
377440
<code><![CDATA[\is_array($frame)]]></code>
378441
</DocblockTypeContradiction>
@@ -442,7 +505,26 @@
442505
<code><![CDATA[$details]]></code>
443506
</MissingParamType>
444507
</file>
508+
<file src="src/Internal/Client/ResponseToResultMapper.php">
509+
<ArgumentTypeCoercion>
510+
<code><![CDATA[$execution->getRunId()]]></code>
511+
<code><![CDATA[$execution->getWorkflowId()]]></code>
512+
<code><![CDATA[$updateRef->getWorkflowExecution()?->getRunId()]]></code>
513+
<code><![CDATA[(string) $updateRef->getWorkflowExecution()?->getWorkflowId()]]></code>
514+
</ArgumentTypeCoercion>
515+
</file>
445516
<file src="src/Internal/Client/WorkflowStarter.php">
517+
<ArgumentTypeCoercion>
518+
<code><![CDATA[$f->getRunId()]]></code>
519+
<code><![CDATA[$f->getRunId()]]></code>
520+
<code><![CDATA[$input->workflowStartInput->workflowId]]></code>
521+
<code><![CDATA[$input->workflowStartInput->workflowId]]></code>
522+
<code><![CDATA[$options->workflowId]]></code>
523+
<code><![CDATA[$request->getWorkflowId()]]></code>
524+
<code><![CDATA[$request->getWorkflowId()]]></code>
525+
<code><![CDATA[$response->getRunId()]]></code>
526+
<code><![CDATA[$startResponse->getRunId()]]></code>
527+
</ArgumentTypeCoercion>
446528
<InvalidArgument>
447529
<code><![CDATA[0]]></code>
448530
<code><![CDATA[1]]></code>
@@ -461,6 +543,11 @@
461543
</UndefinedInterfaceMethod>
462544
</file>
463545
<file src="src/Internal/Client/WorkflowStub.php">
546+
<ArgumentTypeCoercion>
547+
<code><![CDATA[$closeEvent
548+
->getWorkflowExecutionContinuedAsNewEventAttributes()
549+
->getNewExecutionRunId()]]></code>
550+
</ArgumentTypeCoercion>
464551
<PossiblyInvalidArgument>
465552
<code><![CDATA[$closeEvent->getTaskId()]]></code>
466553
</PossiblyInvalidArgument>
@@ -597,6 +684,25 @@
597684
<code><![CDATA[$retry !== null]]></code>
598685
</RedundantConditionGivenDocblockType>
599686
</file>
687+
<file src="src/Internal/Declaration/WorkflowInstance/QueryDispatcher.php">
688+
<PropertyNotSetInConstructor>
689+
<code><![CDATA[$queryExecutor]]></code>
690+
</PropertyNotSetInConstructor>
691+
</file>
692+
<file src="src/Internal/Declaration/WorkflowInstance/SignalDispatcher.php">
693+
<InvalidReturnStatement>
694+
<code><![CDATA[$this->push($name, $values)]]></code>
695+
</InvalidReturnStatement>
696+
<PropertyNotSetInConstructor>
697+
<code><![CDATA[$onSignal]]></code>
698+
</PropertyNotSetInConstructor>
699+
</file>
700+
<file src="src/Internal/Declaration/WorkflowInstance/UpdateDispatcher.php">
701+
<PropertyNotSetInConstructor>
702+
<code><![CDATA[$updateExecutor]]></code>
703+
<code><![CDATA[$updateValidator]]></code>
704+
</PropertyNotSetInConstructor>
705+
</file>
600706
<file src="src/Internal/Events/EventEmitterInterface.php">
601707
<InvalidTemplateParam>
602708
<code><![CDATA[T]]></code>
@@ -660,6 +766,8 @@
660766
</file>
661767
<file src="src/Internal/Mapper/WorkflowExecutionInfoMapper.php">
662768
<ArgumentTypeCoercion>
769+
<code><![CDATA[$execution->getRunId()]]></code>
770+
<code><![CDATA[$execution->getWorkflowId()]]></code>
663771
<code><![CDATA[$message->getTaskQueue()]]></code>
664772
<code><![CDATA[(int) $message->getHistorySizeBytes()]]></code>
665773
<code><![CDATA[(int) $message->getStateTransitionCount()]]></code>
@@ -671,6 +779,9 @@
671779
<code><![CDATA[parse]]></code>
672780
<code><![CDATA[parse]]></code>
673781
</DocblockTypeContradiction>
782+
<RawObjectIteration>
783+
<code><![CDATA[$getAutoResetPoints->getPoints()]]></code>
784+
</RawObjectIteration>
674785
<RedundantConditionGivenDocblockType>
675786
<code><![CDATA[parse]]></code>
676787
</RedundantConditionGivenDocblockType>
@@ -740,6 +851,9 @@
740851
\sprintf('%d.%d', $input->getSeconds(), $input->getNanos() / 1000),
741852
)]]></code>
742853
</FalsableReturnStatement>
854+
<InvalidArgument>
855+
<code><![CDATA[$input->getPayloads()]]></code>
856+
</InvalidArgument>
743857
<InvalidFalsableReturnType>
744858
<code><![CDATA[\DateTimeImmutable]]></code>
745859
</InvalidFalsableReturnType>
@@ -752,6 +866,9 @@
752866
<NullableReturnStatement>
753867
<code><![CDATA[$mapper]]></code>
754868
</NullableReturnStatement>
869+
<PossibleRawObjectIteration>
870+
<code><![CDATA[$value]]></code>
871+
</PossibleRawObjectIteration>
755872
<PossiblyNullArgument>
756873
<code><![CDATA[$metadata->getDetails()]]></code>
757874
<code><![CDATA[$metadata->getSummary()]]></code>
@@ -1005,9 +1122,6 @@
10051122
<ArgumentTypeCoercion>
10061123
<code><![CDATA[$request->getID()]]></code>
10071124
</ArgumentTypeCoercion>
1008-
<PossiblyUndefinedStringArrayOffset>
1009-
<code><![CDATA[$request->getOptions()['name']]]></code>
1010-
</PossiblyUndefinedStringArrayOffset>
10111125
<UnusedVariable>
10121126
<code><![CDATA[$headers]]></code>
10131127
</UnusedVariable>
@@ -1301,6 +1415,9 @@
13011415
<code><![CDATA[$e->getCode()]]></code>
13021416
<code><![CDATA[$e->getCode()]]></code>
13031417
</PossiblyInvalidArgument>
1418+
<RawObjectIteration>
1419+
<code><![CDATA[$frame->getMessages()]]></code>
1420+
</RawObjectIteration>
13041421
<TooManyArguments>
13051422
<code><![CDATA[decode]]></code>
13061423
</TooManyArguments>

psalm.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@
2424
<issueHandlers>
2525
<MissingOverrideAttribute errorLevel="suppress" />
2626
<ClassMustBeFinal errorLevel="suppress" />
27+
<DeprecatedClass>
28+
<errorLevel type="suppress">
29+
<referencedClass name="Google\Protobuf\Internal\RepeatedField" />
30+
</errorLevel>
31+
</DeprecatedClass>
2732
</issueHandlers>
2833
</psalm>

src/Client/WorkflowClientInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ public function newWorkflowStub(
110110
*
111111
* IMPORTANT! Stub is per workflow instance. So new stub should be created
112112
* for each new one.
113+
*
114+
* @param non-empty-string $workflowType
113115
*/
114116
public function newUntypedWorkflowStub(
115117
string $workflowType,
@@ -121,6 +123,7 @@ public function newUntypedWorkflowStub(
121123
*
122124
* @psalm-template T of object
123125
* @param class-string<T> $class
126+
* @param non-empty-string $workflowID
124127
* @return T
125128
*/
126129
public function newRunningWorkflowStub(
@@ -131,6 +134,10 @@ public function newRunningWorkflowStub(
131134

132135
/**
133136
* Returns untyped workflow stub associated with running workflow.
137+
*
138+
* @param non-empty-string $workflowID
139+
* @param non-empty-string|null $runID
140+
* @param non-empty-string|null $workflowType
134141
*/
135142
public function newUntypedRunningWorkflowStub(
136143
string $workflowID,

src/Common/Priority.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,17 @@ final class Priority
4545
#[Marshal(name: 'PriorityKey')]
4646
public int $priorityKey = 0;
4747

48+
/**
49+
* @param int<0, max> $priorityKey
50+
*/
4851
private function __construct(int $priorityKey = 0)
4952
{
5053
$this->priorityKey = $priorityKey;
5154
}
5255

56+
/**
57+
* Create a new Priority instance.
58+
*/
5359
public static function new(int $priorityKey = 0): self
5460
{
5561
return new self($priorityKey);

src/Common/Uuid.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ final class Uuid
2525
*/
2626
public const NIL = '00000000-0000-0000-0000-000000000000';
2727

28+
/**
29+
* @return non-empty-string
30+
*/
2831
public static function nil(): string
2932
{
3033
return self::NIL;

src/Exception/Client/ServiceClientException.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
namespace Temporal\Exception\Client;
1313

14-
use Google\Protobuf\Any;
15-
use Google\Protobuf\Internal\RepeatedField;
14+
use Google\Protobuf\RepeatedField;
1615
use Google\Rpc\Status;
1716

1817
class ServiceClientException extends \RuntimeException
@@ -45,9 +44,9 @@ public function getStatus(): Status
4544
}
4645

4746
/**
48-
* @return \ArrayAccess<int, Any>&RepeatedField
47+
* @return RepeatedField
4948
*/
50-
public function getDetails(): RepeatedField
49+
public function getDetails(): \ArrayAccess&\Countable&\IteratorAggregate
5150
{
5251
return $this->status->getDetails();
5352
}

src/Internal/Declaration/Instantiator/WorkflowInstantiator.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace Temporal\Internal\Declaration\Instantiator;
1313

1414
use Temporal\Exception\InstantiationException;
15-
use Temporal\Interceptor\PipelineProvider;
16-
use Temporal\Interceptor\WorkflowInboundCallsInterceptor;
1715
use Temporal\Internal\Declaration\Prototype\PrototypeInterface;
1816
use Temporal\Internal\Declaration\Prototype\WorkflowPrototype;
1917
use Temporal\Internal\Declaration\WorkflowInstance;

src/Internal/Declaration/WorkflowInstance.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111

1212
namespace Temporal\Internal\Declaration;
1313

14-
use Temporal\Interceptor\WorkflowInboundCallsInterceptor;
1514
use Temporal\Internal\Declaration\Prototype\WorkflowPrototype;
1615
use Temporal\Internal\Declaration\WorkflowInstance\QueryDispatcher;
1716
use Temporal\Internal\Declaration\WorkflowInstance\SignalDispatcher;
1817
use Temporal\Internal\Declaration\WorkflowInstance\UpdateDispatcher;
19-
use Temporal\Internal\Interceptor;
2018

2119
/**
2220
* @internal

src/Internal/Transport/Router/InvokeQuery.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,23 @@ public function __construct(
4545

4646
public function handle(ServerRequestInterface $request, array $headers, Deferred $resolver): void
4747
{
48-
/** @var non-empty-string $name */
49-
$name = $request->getOptions()['name'];
48+
$name = $request->getOptions()['name'] ?? '';
5049
$process = $this->findProcessOrFail($request->getID());
5150
$context = $process->getContext();
5251

52+
\assert(\is_string($name) && $name !== '');
53+
5354
match ($name) {
5455
'__temporal_workflow_metadata' => $this->getWorkflowMetadata($resolver, $context),
5556
default => $this->handleQuery($name, $request, $resolver, $context, $headers),
5657
};
5758
}
5859

60+
/**
61+
* Handles the query request by finding the appropriate query handler and executing it.
62+
*
63+
* @param non-empty-string $name
64+
*/
5965
private function handleQuery(
6066
string $name,
6167
ServerRequestInterface $request,
@@ -120,7 +126,7 @@ static function () use ($resolver, $context): void {
120126
->setQueryDefinitions($context->getQueryDispatcher()->getQueryHandlers())
121127
->setSignalDefinitions($context->getSignalDispatcher()->getSignalHandlers())
122128
->setUpdateDefinitions($context->getUpdateDispatcher()->getUpdateHandlers()),
123-
)
129+
),
124130
]);
125131

126132
$resolver->resolve($result);

0 commit comments

Comments
 (0)