Skip to content
Open
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
139 changes: 21 additions & 118 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="6.14.3@d0b040a91f280f071c1abcb1b77ce3822058725a">
<file src="src/Activity.php">
<ImplicitToStringCast>
<code><![CDATA[$type]]></code>
</ImplicitToStringCast>
</file>
<file src="src/Activity/ActivityInterface.php">
<DeprecatedClass>
<code><![CDATA[NamedArgumentConstructor]]></code>
Expand All @@ -15,21 +10,11 @@
<code><![CDATA[NamedArgumentConstructor]]></code>
</DeprecatedClass>
</file>
<file src="src/Activity/ActivityOptions.php">
<PossiblyNullReference>
<code><![CDATA[mergeWith]]></code>
</PossiblyNullReference>
</file>
<file src="src/Activity/LocalActivityInterface.php">
<DeprecatedClass>
<code><![CDATA[NamedArgumentConstructor]]></code>
</DeprecatedClass>
</file>
<file src="src/Activity/LocalActivityOptions.php">
<PossiblyNullReference>
<code><![CDATA[mergeWith]]></code>
</PossiblyNullReference>
</file>
<file src="src/Client/ActivityCompletionClientInterface.php">
<MissingParamType>
<code><![CDATA[$details]]></code>
Expand All @@ -40,17 +25,6 @@
<code><![CDATA[recordHeartbeatByToken]]></code>
</MissingReturnType>
</file>
<file src="src/Client/Common/Paginator.php">
<PossiblyNullPropertyAssignmentValue>
<code><![CDATA[$loader->current()]]></code>
</PossiblyNullPropertyAssignmentValue>
</file>
<file src="src/Client/Common/RpcRetryOptions.php">
<TypeDoesNotContainType>
<code><![CDATA[withInitialInterval]]></code>
<code><![CDATA[withMaximumInterval]]></code>
</TypeDoesNotContainType>
</file>
<file src="src/Client/GRPC/Context.php">
<ArgumentTypeCoercion>
<code><![CDATA[$format]]></code>
Expand Down Expand Up @@ -274,62 +248,16 @@
<code><![CDATA[$parts[1]]]></code>
</PossiblyUndefinedArrayOffset>
</file>
<file src="src/DataConverter/DataConverter.php">
<MissingImmutableAnnotation>
<code><![CDATA[DataConverter]]></code>
</MissingImmutableAnnotation>
<PossiblyNullArgument>
<code><![CDATA[$type]]></code>
</PossiblyNullArgument>
</file>
<file src="src/DataConverter/EncodedCollection.php">
<InvalidArgument>
<code><![CDATA[$name]]></code>
<code><![CDATA[$value]]></code>
</InvalidArgument>
<MoreSpecificImplementedParamType>
<code><![CDATA[$type]]></code>
</MoreSpecificImplementedParamType>
</file>
<file src="src/DataConverter/EncodedValues.php">
<PossiblyNullIterator>
<code><![CDATA[$this->values]]></code>
</PossiblyNullIterator>
<UnsafeInstantiation>
<code><![CDATA[new static()]]></code>
<code><![CDATA[new static()]]></code>
<code><![CDATA[new static()]]></code>
</UnsafeInstantiation>
</file>
<file src="src/DataConverter/JsonConverter.php">
<ArgumentTypeCoercion>
<code><![CDATA[$type->getName()]]></code>
</ArgumentTypeCoercion>
<DeprecatedClass>
<code><![CDATA[new AnnotationReader()]]></code>
</DeprecatedClass>
<PossiblyInvalidArgument>
<code><![CDATA[$e->getCode()]]></code>
<code><![CDATA[$e->getCode()]]></code>
</PossiblyInvalidArgument>
<PossiblyInvalidPropertyFetch>
<code><![CDATA[$data->name]]></code>
</PossiblyInvalidPropertyFetch>
</file>
<file src="src/DataConverter/ProtoConverter.php">
<ArgumentTypeCoercion>
<code><![CDATA[$type->getName()]]></code>
</ArgumentTypeCoercion>
</file>
<file src="src/DataConverter/ProtoJsonConverter.php">
<ArgumentTypeCoercion>
<code><![CDATA[$type->getName()]]></code>
</ArgumentTypeCoercion>
</file>
<file src="src/DataConverter/ValuesInterface.php">
<MissingReturnType>
<code><![CDATA[setDataConverter]]></code>
</MissingReturnType>
</file>
<file src="src/Exception/Client/ActivityCompletionException.php">
<PossiblyNullReference>
Expand Down Expand Up @@ -638,25 +566,6 @@
<code><![CDATA[$updateValidator]]></code>
</PropertyNotSetInConstructor>
</file>
<file src="src/Internal/Events/EventEmitterInterface.php">
<InvalidTemplateParam>
<code><![CDATA[T]]></code>
</InvalidTemplateParam>
</file>
<file src="src/Internal/Events/EventEmitterTrait.php">
<LessSpecificImplementedReturnType>
<code><![CDATA[self]]></code>
<code><![CDATA[self]]></code>
</LessSpecificImplementedReturnType>
<PossiblyNullFunctionCall>
<code><![CDATA[$callback(...$arguments)]]></code>
</PossiblyNullFunctionCall>
</file>
<file src="src/Internal/Events/EventListenerInterface.php">
<InvalidTemplateParam>
<code><![CDATA[T]]></code>
</InvalidTemplateParam>
</file>
<file src="src/Internal/Interceptor/Pipeline.php">
<ImpureFunctionCall>
<code><![CDATA[$this->last]]></code>
Expand Down Expand Up @@ -1079,9 +988,6 @@
<MoreSpecificImplementedParamType>
<code><![CDATA[$method]]></code>
</MoreSpecificImplementedParamType>
<PossiblyNullArgument>
<code><![CDATA[$handler?->getReturnType()]]></code>
</PossiblyNullArgument>
</file>
<file src="src/Internal/Workflow/ChildWorkflowStub.php">
<ArgumentTypeCoercion>
Expand All @@ -1105,9 +1011,6 @@
<code><![CDATA[$this->start(...$args)->then(fn() => $this->getResult($returnType))]]></code>
<code><![CDATA[EncodedValues::decodePromise($started)]]></code>
</LessSpecificReturnStatement>
<MissingParamType>
<code><![CDATA[$returnType]]></code>
</MissingParamType>
<MoreSpecificReturnType>
<code><![CDATA[PromiseInterface]]></code>
<code><![CDATA[PromiseInterface]]></code>
Expand Down Expand Up @@ -1258,9 +1161,6 @@
<code><![CDATA[$cacheName]]></code>
<code><![CDATA[$host]]></code>
</ArgumentTypeCoercion>
<MissingParamType>
<code><![CDATA[$value]]></code>
</MissingParamType>
<PossiblyUndefinedStringArrayOffset>
<code><![CDATA[$request->getOptions()['name']]]></code>
</PossiblyUndefinedStringArrayOffset>
Expand Down Expand Up @@ -1462,9 +1362,6 @@
<PossiblyUndefinedStringArrayOffset>
<code><![CDATA[$headers[self::HEADER_TASK_QUEUE]]]></code>
</PossiblyUndefinedStringArrayOffset>
<PropertyNotSetInConstructor>
<code><![CDATA[$codec]]></code>
</PropertyNotSetInConstructor>
<UndefinedInterfaceMethod>
<code><![CDATA[dispatch]]></code>
<code><![CDATA[dispatch]]></code>
Expand All @@ -1483,16 +1380,6 @@
<code><![CDATA[getUpdateContext]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="src/Workflow/ChildWorkflowOptions.php">
<PossiblyNullReference>
<code><![CDATA[mergeWith]]></code>
</PossiblyNullReference>
</file>
<file src="src/Workflow/ChildWorkflowStubInterface.php">
<MissingParamType>
<code><![CDATA[$returnType]]></code>
</MissingParamType>
</file>
<file src="src/Workflow/QueryMethod.php">
<DeprecatedClass>
<code><![CDATA[NamedArgumentConstructor]]></code>
Expand All @@ -1503,11 +1390,6 @@
<code><![CDATA[NamedArgumentConstructor]]></code>
</DeprecatedClass>
</file>
<file src="src/Workflow/Saga.php">
<PossiblyInvalidArgument>
<code><![CDATA[$e->getCode()]]></code>
</PossiblyInvalidArgument>
</file>
<file src="src/Workflow/SignalMethod.php">
<DeprecatedClass>
<code><![CDATA[NamedArgumentConstructor]]></code>
Expand Down Expand Up @@ -1538,4 +1420,25 @@
<code><![CDATA[NamedArgumentConstructor]]></code>
</DeprecatedClass>
</file>
<file src="testing/src/Downloader.php">
<PossiblyUndefinedStringArrayOffset>
<code><![CDATA[$asset['browser_download_url']]]></code>
<code><![CDATA[$response->toArray()['assets']]]></code>
</PossiblyUndefinedStringArrayOffset>
</file>
<file src="testing/src/Replay/WorkflowReplayer.php">
<UndefinedMethod>
<code><![CDATA[getWorkflowType]]></code>
</UndefinedMethod>
</file>
<file src="testing/src/TestService.php">
<UndefinedClass>
<code><![CDATA[ChannelCredentials]]></code>
</UndefinedClass>
</file>
<file src="testing/src/WorkerMock.php">
<DeprecatedMethod>
<code><![CDATA[registerActivityImplementations]]></code>
</DeprecatedMethod>
</file>
</files>
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
>
<projectFiles>
<directory name="src" />
<directory name="testing/src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
Expand Down
6 changes: 5 additions & 1 deletion src/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
use Temporal\Exception\OutOfContextException;
use Temporal\Internal\Support\Facade;

/**
* @psalm-import-type TType from Type
*/
final class Activity extends Facade
{
/**
Expand Down Expand Up @@ -92,7 +95,8 @@ public static function hasHeartbeatDetails(): bool
*
* This method retrieves the payload that was passed into the last call of the {@see Activity::heartbeat()} method.
*
* @param Type|string|\ReflectionType|\ReflectionClass|null $type
* @param null|mixed $type
* @psalm-param TType $type
* @throws OutOfContextException in the absence of the activity execution context.
*/
public static function getHeartbeatDetails($type = null): mixed
Expand Down
6 changes: 5 additions & 1 deletion src/Activity/ActivityContextInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use Temporal\Exception\Client\ActivityCompletionException;
use Temporal\Exception\Client\ActivityPausedException;

/**
* @psalm-import-type TType from Type
*/
interface ActivityContextInterface
{
/**
Expand Down Expand Up @@ -46,7 +49,8 @@ public function hasHeartbeatDetails(): bool;
*
* @see Activity::getHeartbeatDetails()
*
* @param Type|string $type
* @param null|mixed $type
* @psalm-param TType $type
*/
public function getLastHeartbeatDetails($type = null): mixed;

Expand Down
2 changes: 1 addition & 1 deletion src/Activity/ActivityOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function mergeWith(?MethodRetry $retry = null): self
$self = clone $this;

if ($retry !== null && $this->diff->isPresent($self, 'retryOptions')) {
$self->retryOptions = $this->retryOptions->mergeWith($retry);
$self->retryOptions = $this->retryOptions?->mergeWith($retry);
}

return $self;
Expand Down
23 changes: 1 addition & 22 deletions src/Activity/LocalActivityInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Temporal\Activity;

use Doctrine\Common\Annotations\Annotation\Target;
use JetBrains\PhpStorm\Immutable;
use Spiral\Attributes\NamedArgumentConstructor;

/**
Expand All @@ -33,24 +32,4 @@
* @Target({ "CLASS" })
*/
#[\Attribute(\Attribute::TARGET_CLASS), NamedArgumentConstructor]
final class LocalActivityInterface extends ActivityInterface
{
/**
* Prefix to prepend to method names to generate activity types. Default is
* empty string which means that method names are used as activity types.
*
* Note that this value is ignored if a name of an activity is specified
* explicitly through {@see ActivityMethod::$name}.
*
* Be careful about names that contain special characters. These names can
* be used as metric tags. And systems like prometheus ignore metrics which
* have tags with unsupported characters.
*/
#[Immutable]
public string $prefix = '';

public function __construct(string $prefix = '')
{
$this->prefix = $prefix;
}
}
final class LocalActivityInterface extends ActivityInterface {}
2 changes: 1 addition & 1 deletion src/Activity/LocalActivityOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function mergeWith(?MethodRetry $retry = null): self
$self = clone $this;

if ($retry !== null && $this->diff->isPresent($self, 'retryOptions')) {
$self->retryOptions = $this->retryOptions->mergeWith($retry);
$self->retryOptions = $this->retryOptions?->mergeWith($retry);
}

return $self;
Expand Down
11 changes: 10 additions & 1 deletion src/Client/Common/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ private function __construct(
private readonly int $pageNumber,
private ?\Closure $counter,
) {
$this->collection = $loader->current();
$current = $loader->current();
if (!\is_array($current)) {
throw new \InvalidArgumentException(
\sprintf(
'Generator must return an array of items, %s returned.',
\get_debug_type($current),
),
);
}
$this->collection = $current;
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/Common/RetryOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public function mergeWith(?MethodRetry $retry = null): self
*
* @param mixed $interval parseable string, null, int|float in seconds, {@see \DateInterval}, or {@see Duration}
* @return static
* @psalm-assert DateIntervalValue|null $interval
*/
#[Pure]
public function withInitialInterval(mixed $interval): self
Expand Down Expand Up @@ -162,7 +161,6 @@ public function withBackoffCoefficient(float $coefficient): self
*
* @param mixed $interval parseable string, null, int|float in seconds, {@see \DateInterval}, or {@see Duration}
* @return static
* @psalm-assert DateIntervalValue|null $interval
*/
#[Pure]
public function withMaximumInterval(mixed $interval): self
Expand Down
5 changes: 4 additions & 1 deletion src/DataConverter/DataConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use Temporal\Api\Common\V1\Payload;
use Temporal\Exception\DataConverterException;

/**
* @psalm-import-type TType from Type
*/
final class DataConverter implements DataConverterInterface
{
/**
Expand All @@ -40,7 +43,7 @@ public static function createDefault(): DataConverterInterface
}

/**
* @param string|\ReflectionClass|\ReflectionType|Type|null $type
* @param TType $type
*/
public function fromPayload(Payload $payload, $type): mixed
{
Expand Down
Loading
Loading