diff --git a/.github/workflows/run-test-suite.yml b/.github/workflows/run-test-suite.yml index 0db6659a1..3263ea3ab 100644 --- a/.github/workflows/run-test-suite.yml +++ b/.github/workflows/run-test-suite.yml @@ -42,24 +42,21 @@ jobs: test: name: PHP${{ matrix.php }}${{ matrix.extensions-suffix }}, ${{ matrix.os }}, ${{ matrix.dependencies }} deps runs-on: ${{ matrix.os }} - timeout-minutes: ${{ matrix.timeout-minutes }} + timeout-minutes: ${{ inputs.test-timeout }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} strategy: fail-fast: ${{ inputs.fail-fast }} matrix: - php: [ 8.1, 8.2, 8.3 ] - os: [ ubuntu-latest, windows-latest ] + php: [ 8.1, 8.2, 8.3, 8.4 ] + os: [ ubuntu-latest ] extensions-suffix: [ '', ', protobuf' ] dependencies: [ lowest , highest ] - timeout-minutes: [ '${{ inputs.test-timeout }}' ] - exclude: - - os: windows-latest - php: 8.2 + include: - os: windows-latest extensions-suffix: ', protobuf' - - os: windows-latest - php: 8.3 + php: 8.1 + dependencies: highest steps: - name: Set Git To Use LF run: | @@ -82,6 +79,10 @@ jobs: - name: Validate composer.json and composer.lock run: composer validate --strict + - name: Download CPX (PHP 8.4) + if: inputs.download-binaries == true && matrix.php == '8.4' + run: composer global require cpx/cpx + - name: Get Composer Cache Directory id: composer-cache run: | @@ -96,23 +97,37 @@ jobs: php-${{ matrix.php }}-${{ matrix.os }}-composer- - name: Install lowest dependencies from composer.json - if: matrix.dependencies == 'lowest' + if: matrix.dependencies == 'lowest' && matrix.php != '8.4' run: composer update --no-interaction --no-progress --prefer-lowest + - name: Install lowest dependencies from composer.json ignoring ext-php constraint (PHP 8.4) + if: matrix.dependencies == 'lowest' && matrix.php == '8.4' + run: composer update --no-interaction --no-progress --prefer-lowest --ignore-platform-req php + + - name: Validate lowest dependencies - if: matrix.dependencies == 'lowest' + if: matrix.dependencies == 'lowest' && matrix.php == '8.1' env: COMPOSER_POOL_OPTIMIZER: 0 run: vendor/bin/validate-prefer-lowest + - name: Install highest dependencies from composer.json - if: matrix.dependencies == 'highest' + if: matrix.dependencies == 'highest' && matrix.php != '8.4' run: composer update --no-interaction --no-progress - - name: Download RoadRunner - if: inputs.download-binaries == true - run: | - vendor/bin/dload get --no-interaction -vv + - name: Install highest dependencies from composer.json ignoring ext-php constraint (PHP 8.4) + if: matrix.dependencies == 'highest' && matrix.php == '8.4' + run: composer update --no-interaction --no-progress --ignore-platform-req php + + + - name: Download binaries + if: inputs.download-binaries == true && matrix.php != '8.4' + run: composer get:binaries + + - name: Download binaries (PHP 8.4) + if: inputs.download-binaries == true && matrix.php == '8.4' + run: cpx internal/dload get --no-interaction - name: Run tests run: ${{ inputs.test-command }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 3c5ae10cc..37db3ee61 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -42,5 +42,43 @@ jobs: - name: Install Composer Dependencies run: composer install --prefer-dist --no-interaction - - name: Run Tests + - name: 🔍 Run Tests run: vendor/bin/psalm + + arch: + name: Architecture tests + runs-on: ${{ matrix.os }} + continue-on-error: true + strategy: + fail-fast: false + matrix: + php: [8.3] + os: [ubuntu-latest] + steps: + - name: Set up PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom + + - name: Check Out Code + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Get Composer Cache Directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache Dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: php-${{ matrix.php }}-${{ runner.os }}-composer- + + - name: Install Composer Dependencies + run: composer install --prefer-dist --no-interaction + + - name: 🔍 Run Tests + run: composer test:arch diff --git a/composer.json b/composer.json index b6c310b2a..a3e4f7d99 100644 --- a/composer.json +++ b/composer.json @@ -34,12 +34,12 @@ "roadrunner-php/roadrunner-api-dto": "^1.9.0", "roadrunner-php/version-checker": "^1.0", "spiral/attributes": "^3.1.6", - "spiral/roadrunner": "^2024.1", + "spiral/roadrunner": "^2024.3", "spiral/roadrunner-cli": "^2.5", "spiral/roadrunner-kv": "^4.2", "spiral/roadrunner-worker": "^3.5", "symfony/filesystem": "^5.4 || ^6.0 || ^7.0", - "symfony/http-client": "^5.4 || ^6.0 || ^7.0", + "symfony/http-client": "^5.4.3 || ^6.0.3 || ^7.0", "symfony/process": "^5.4 || ^6.0 || ^7.0" }, "autoload": { @@ -61,7 +61,7 @@ "phpunit/phpunit": "^10.5", "spiral/code-style": "~2.1.2", "spiral/core": "^3.13", - "symfony/var-dumper": "^6.0 || ^7.0", + "ta-tikoma/phpunit-architecture-test": "^0.8.4", "vimeo/psalm": "^4.30 || ^5.4" }, "autoload-dev": { @@ -81,12 +81,14 @@ }, "scripts": { "post-update-cmd": "Temporal\\Worker\\Transport\\RoadRunnerVersionChecker::postUpdate", + "get:binaries": "dload get --no-interaction -vv", "cs:diff": "php-cs-fixer fix --dry-run -v --diff --show-progress dots", "cs:fix": "php-cs-fixer fix -v", "psalm": "psalm", "psalm:baseline": "psalm --set-baseline=psalm-baseline.xml", "test:unit": "phpunit --testsuite=Unit --color=always --testdox", "test:func": "phpunit --testsuite=Functional --color=always --testdox", + "test:arch": "phpunit --testsuite=Arch --color=always --testdox", "test:accept": "phpunit --testsuite=Acceptance --color=always --testdox" }, "extra": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6d0db0da9..d9c16f1b2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -9,11 +9,20 @@ stopOnFailure="false" stopOnError="false" stderr="true" + displayDetailsOnIncompleteTests="true" + displayDetailsOnSkippedTests="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerErrors="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerWarnings="true" > tests/Acceptance/Harness + + tests/Arch + tests/Unit diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e0bfc18c0..bf156c41a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -109,6 +109,12 @@ + + + excludeCalendarList]]> + excludeCalendarList]]> + + getSuccess()]]> @@ -117,6 +123,7 @@ + @@ -142,6 +149,9 @@ + + + @@ -149,6 +159,14 @@ + + + + + + + + @@ -378,6 +396,14 @@ + + + + + + + + retryOptions ? $options->retryOptions->toWorkflowRetryPolicy() : null]]> toMemo($this->converter)]]> @@ -389,6 +415,9 @@ + + + @@ -399,6 +428,7 @@ getFailure()]]> getResult()]]> workflowType]]> + workflowType]]> getQueryResult()]]> execution]]> execution]]> @@ -508,7 +538,6 @@ - @@ -1218,10 +1247,6 @@ - - - - @@ -1367,11 +1392,6 @@ - - - - - getRelayAddress()]]> @@ -1457,6 +1477,7 @@ diff --git a/src/Activity.php b/src/Activity.php index d78993d05..1d7e84a50 100644 --- a/src/Activity.php +++ b/src/Activity.php @@ -26,7 +26,6 @@ final class Activity extends Facade /** * Returns information about current activity execution. * - * @return ActivityInfo * @throws OutOfContextException in the absence of the activity execution context. */ public static function getInfo(): ActivityInfo @@ -53,7 +52,6 @@ public static function getInfo(): ActivityInfo * } * ``` * - * @return ValuesInterface * @throws OutOfContextException in the absence of the activity execution context. */ public static function getInput(): ValuesInterface @@ -69,7 +67,6 @@ public static function getInput(): ValuesInterface * * This method returns **true** if the first argument has been passed to the {@see Activity::heartbeat()} method. * - * @return bool * @throws OutOfContextException in the absence of the activity execution context. */ public static function hasHeartbeatDetails(): bool diff --git a/src/Activity/ActivityContextInterface.php b/src/Activity/ActivityContextInterface.php index 457311a96..7128a6da1 100644 --- a/src/Activity/ActivityContextInterface.php +++ b/src/Activity/ActivityContextInterface.php @@ -22,7 +22,6 @@ interface ActivityContextInterface * * @see Activity::getInfo() * - * @return ActivityInfo */ public function getInfo(): ActivityInfo; @@ -31,7 +30,6 @@ public function getInfo(): ActivityInfo; * * @see Activity::getInput() * - * @return ValuesInterface */ public function getInput(): ValuesInterface; @@ -40,7 +38,6 @@ public function getInput(): ValuesInterface; * * @see Activity::hasHeartbeatDetails() * - * @return bool */ public function hasHeartbeatDetails(): bool; @@ -59,7 +56,6 @@ public function getHeartbeatDetails($type = null); * * @see Activity::doNotCompleteOnReturn() * - * @return void */ public function doNotCompleteOnReturn(): void; diff --git a/src/Activity/ActivityInfo.php b/src/Activity/ActivityInfo.php index 929774f82..a5866063a 100644 --- a/src/Activity/ActivityInfo.php +++ b/src/Activity/ActivityInfo.php @@ -38,26 +38,16 @@ final class ActivityInfo * * @see ActivityCompletionClientInterface::complete() * - * @var string */ #[Marshal(name: 'TaskToken')] public string $taskToken; - /** - * @var WorkflowType|null - */ #[Marshal(name: 'WorkflowType', type: NullableType::class, of: WorkflowType::class)] public ?WorkflowType $workflowType = null; - /** - * @var string - */ #[Marshal(name: 'WorkflowNamespace')] public string $workflowNamespace = 'default'; - /** - * @var WorkflowExecution|null - */ #[Marshal(name: 'WorkflowExecution', type: NullableType::class, of: WorkflowExecution::class)] public ?WorkflowExecution $workflowExecution = null; @@ -67,7 +57,6 @@ final class ActivityInfo * * @see ActivityCompletionClientInterface::complete() * - * @var string */ #[Marshal(name: 'ActivityID')] public string $id; @@ -75,21 +64,16 @@ final class ActivityInfo /** * Type (name) of the activity. * - * @var ActivityType */ #[Marshal(name: 'ActivityType', type: ObjectType::class, of: ActivityType::class)] public ActivityType $type; - /** - * @var string - */ #[Marshal(name: 'TaskQueue')] public string $taskQueue = WorkerFactoryInterface::DEFAULT_TASK_QUEUE; /** * Maximum time between heartbeats. 0 means no heartbeat needed. * - * @var \DateInterval */ #[Marshal(name: 'HeartbeatTimeout', type: DateIntervalType::class)] public \DateInterval $heartbeatTimeout; @@ -97,7 +81,6 @@ final class ActivityInfo /** * Time of activity scheduled by a workflow * - * @var \DateTimeInterface */ #[Marshal(name: 'ScheduledTime', type: DateTimeType::class)] public \DateTimeInterface $scheduledTime; @@ -105,7 +88,6 @@ final class ActivityInfo /** * Time of activity start * - * @var \DateTimeInterface */ #[Marshal(name: 'StartedTime', type: DateTimeType::class)] public \DateTimeInterface $startedTime; @@ -113,7 +95,6 @@ final class ActivityInfo /** * Time of activity timeout * - * @var \DateTimeInterface */ #[Marshal(name: 'Deadline', type: DateTimeType::class)] public \DateTimeInterface $deadline; @@ -122,7 +103,6 @@ final class ActivityInfo * Attempt starts from 1, and increased by 1 for every retry if * retry policy is specified. * - * @var int */ #[Marshal(name: 'Attempt')] public int $attempt = 1; diff --git a/src/Activity/ActivityInterface.php b/src/Activity/ActivityInterface.php index 3758811b5..fe2fbb6c9 100644 --- a/src/Activity/ActivityInterface.php +++ b/src/Activity/ActivityInterface.php @@ -49,9 +49,6 @@ class ActivityInterface #[Immutable] public string $prefix = ''; - /** - * @param string $prefix - */ public function __construct(string $prefix = '') { $this->prefix = $prefix; diff --git a/src/Activity/ActivityMethod.php b/src/Activity/ActivityMethod.php index 884ee38db..4942402b1 100644 --- a/src/Activity/ActivityMethod.php +++ b/src/Activity/ActivityMethod.php @@ -33,10 +33,7 @@ final class ActivityMethod #[Immutable] public ?string $name = null; - /** - * @param string|null $name - */ - public function __construct(string $name = null) + public function __construct(?string $name = null) { $this->name = $name; } diff --git a/src/Activity/ActivityOptions.php b/src/Activity/ActivityOptions.php index 94b5ff9e2..4c08cad42 100644 --- a/src/Activity/ActivityOptions.php +++ b/src/Activity/ActivityOptions.php @@ -123,10 +123,9 @@ public function __construct() } /** - * @param MethodRetry|null $retry * @return $this */ - public function mergeWith(MethodRetry $retry = null): self + public function mergeWith(?MethodRetry $retry = null): self { $self = clone $this; @@ -142,7 +141,6 @@ public function mergeWith(MethodRetry $retry = null): self * * By default, it is the same task list name the workflow was started with. * - * @param string|null $taskQueue * @return $this */ #[Pure] @@ -269,7 +267,6 @@ public function withCancellationType(ActivityCancellationType|int $type): self } /** - * @param string $activityId * @return $this */ #[Pure] @@ -283,7 +280,6 @@ public function withActivityId(string $activityId): self } /** - * @param RetryOptions|null $options * @return $this */ #[Pure] diff --git a/src/Activity/ActivityOptionsInterface.php b/src/Activity/ActivityOptionsInterface.php index 895c6eaf0..c3caf5f20 100644 --- a/src/Activity/ActivityOptionsInterface.php +++ b/src/Activity/ActivityOptionsInterface.php @@ -11,5 +11,5 @@ */ interface ActivityOptionsInterface { - public function mergeWith(MethodRetry $retry = null): self; + public function mergeWith(?MethodRetry $retry = null): self; } diff --git a/src/Activity/ActivityType.php b/src/Activity/ActivityType.php index faedf2555..6b9fab4ef 100644 --- a/src/Activity/ActivityType.php +++ b/src/Activity/ActivityType.php @@ -21,7 +21,6 @@ class ActivityType /** * @psalm-readonly * @psalm-allow-private-mutation - * @var string */ #[Marshal(name: 'Name')] public string $name = ''; diff --git a/src/Activity/LocalActivityInterface.php b/src/Activity/LocalActivityInterface.php index fad88041d..9ed095586 100644 --- a/src/Activity/LocalActivityInterface.php +++ b/src/Activity/LocalActivityInterface.php @@ -49,9 +49,6 @@ final class LocalActivityInterface extends ActivityInterface #[Immutable] public string $prefix = ''; - /** - * @param string $prefix - */ public function __construct(string $prefix = '') { $this->prefix = $prefix; diff --git a/src/Activity/LocalActivityOptions.php b/src/Activity/LocalActivityOptions.php index f533bd036..4099b1bd2 100644 --- a/src/Activity/LocalActivityOptions.php +++ b/src/Activity/LocalActivityOptions.php @@ -79,10 +79,9 @@ public function __construct() } /** - * @param MethodRetry|null $retry * @return $this */ - public function mergeWith(MethodRetry $retry = null): self + public function mergeWith(?MethodRetry $retry = null): self { $self = clone $this; @@ -142,7 +141,6 @@ public function withStartToCloseTimeout($timeout): self } /** - * @param RetryOptions|null $options * @return $this */ #[Pure] diff --git a/src/Client/ActivityCompletionClientInterface.php b/src/Client/ActivityCompletionClientInterface.php index d8252acd0..2e125db1f 100644 --- a/src/Client/ActivityCompletionClientInterface.php +++ b/src/Client/ActivityCompletionClientInterface.php @@ -20,25 +20,15 @@ interface ActivityCompletionClientInterface { /** - * @param string $workflowId - * @param string|null $runId - * @param string $activityId * @param mixed $result */ public function complete(string $workflowId, ?string $runId, string $activityId, $result = null): void; /** - * @param string $taskToken * @param mixed $result */ public function completeByToken(string $taskToken, $result = null): void; - /** - * @param string $workflowId - * @param string|null $runId - * @param string $activityId - * @param \Throwable $error - */ public function completeExceptionally( string $workflowId, ?string $runId, @@ -46,18 +36,8 @@ public function completeExceptionally( \Throwable $error, ): void; - /** - * @param string $taskToken - * @param \Throwable $error - */ public function completeExceptionallyByToken(string $taskToken, \Throwable $error): void; - /** - * @param string $workflowId - * @param string|null $runId - * @param string $activityId - * @param $details - */ public function reportCancellation( string $workflowId, ?string $runId, @@ -65,16 +45,9 @@ public function reportCancellation( $details = null, ): void; - /** - * @param string $taskToken - * @param $details - */ public function reportCancellationByToken(string $taskToken, $details = null): void; /** - * @param string $workflowId - * @param string|null $runId - * @param string $activityId * @param mixed $details * * @throw ActivityCanceledException @@ -87,7 +60,6 @@ public function recordHeartbeat( ); /** - * @param string $taskToken * @param mixed $details * * @throw ActivityCanceledException diff --git a/src/Client/ClientOptions.php b/src/Client/ClientOptions.php index 6958fbbda..7c7b8c1fd 100644 --- a/src/Client/ClientOptions.php +++ b/src/Client/ClientOptions.php @@ -31,14 +31,8 @@ class ClientOptions */ public string $namespace = self::DEFAULT_NAMESPACE; - /** - * @var string - */ public string $identity; - /** - * @var int - */ #[ExpectedValues(valuesFromClass: QueryRejectCondition::class)] public int $queryRejectionCondition = QueryRejectCondition::QUERY_REJECT_CONDITION_NONE; @@ -65,7 +59,6 @@ public function withNamespace(string $namespace): self } /** - * @param string $identity * @return $this */ #[Pure] diff --git a/src/Client/Common/Paginator.php b/src/Client/Common/Paginator.php index 22626130a..08044e8e3 100644 --- a/src/Client/Common/Paginator.php +++ b/src/Client/Common/Paginator.php @@ -111,7 +111,6 @@ public function getPageNumber(): int * Note: the method may call yet another RPC to get total number of items. * It means that the result may be different from the number of items at the moment of the pagination start. * - * @return int * @throws \LogicException If counter is not set. */ public function count(): int diff --git a/src/Client/Common/RpcRetryOptions.php b/src/Client/Common/RpcRetryOptions.php index 5261d764d..9b0c25c33 100644 --- a/src/Client/Common/RpcRetryOptions.php +++ b/src/Client/Common/RpcRetryOptions.php @@ -51,8 +51,6 @@ public static function fromRetryOptions(RetryOptions $options): self * @param DateIntervalValue|null $interval Interval to wait on first retry, on congestion failures. * Defaults to 1000ms, which is used if set to {@see null}. * - * @return self - * * @psalm-suppress ImpureMethodCall */ #[Pure] @@ -76,7 +74,6 @@ public function withCongestionInitialInterval($interval): self * @param null|float $coefficient Maximum amount of jitter. * Default will be used if set to {@see null}. * - * @return self */ #[Pure] public function withMaximumJitterCoefficient(?float $coefficient): self diff --git a/src/Client/Common/ServerCapabilities.php b/src/Client/Common/ServerCapabilities.php index a8d99dc4d..08ecd5334 100644 --- a/src/Client/Common/ServerCapabilities.php +++ b/src/Client/Common/ServerCapabilities.php @@ -43,7 +43,9 @@ final class ServerCapabilities * it in history * @param bool $countGroupByExecutionStatus * True if the server supports count group by execution status - * (-- api-linter: core::0140::prepositions=disabled --) + * @param bool $nexus + * True if the server supports Nexus operations. + * This flag is dependent both on server version and for Nexus to be enabled via server configuration. */ public function __construct( public readonly bool $signalAndQueryHeader = false, @@ -56,6 +58,7 @@ public function __construct( public readonly bool $eagerWorkflowStart = false, public readonly bool $sdkMetadata = false, public readonly bool $countGroupByExecutionStatus = false, + public readonly bool $nexus = false, ) {} /** diff --git a/src/Client/GRPC/BaseClient.php b/src/Client/GRPC/BaseClient.php index 201a6eac8..0bf0223ca 100644 --- a/src/Client/GRPC/BaseClient.php +++ b/src/Client/GRPC/BaseClient.php @@ -64,7 +64,6 @@ final public function __construct(WorkflowServiceClient|\Closure $workflowServic /** * @param non-empty-string $address Temporal service address in format `host:port` - * @return static * @psalm-suppress UndefinedClass */ public static function create(string $address): static @@ -86,17 +85,16 @@ public static function create(string $address): static * @param non-empty-string|null $clientKey Client private key string or file in PEM format. * @param non-empty-string|null $clientPem Client certificate chain string or file in PEM format. * @param non-empty-string|null $overrideServerName - * @return static * * @psalm-suppress UndefinedClass * @psalm-suppress UnusedVariable */ public static function createSSL( string $address, - string $crt = null, - string $clientKey = null, - string $clientPem = null, - string $overrideServerName = null, + ?string $crt = null, + ?string $clientKey = null, + ?string $clientPem = null, + ?string $overrideServerName = null, ): static { if (!\extension_loaded('grpc')) { throw new \RuntimeException('The gRPC extension is required to use Temporal Client.'); @@ -147,6 +145,8 @@ public function withContext(ContextInterface $context): static * This will overwrite any "Authorization" header that may be on the context before each request to the * Temporal service. * You may pass your own {@see \Stringable} implementation to be able to change the key dynamically. + * + * @link https://docs.temporal.io/cloud/api-keys */ public function withAuthKey(\Stringable|string $key): static { @@ -166,7 +166,6 @@ public function close(): void /** * @param null|Pipeline $pipeline * - * @return static */ final public function withInterceptorPipeline(?Pipeline $pipeline): static { @@ -202,6 +201,7 @@ public function getServerCapabilities(): ?ServerCapabilities eagerWorkflowStart: $capabilities->getEagerWorkflowStart(), sdkMetadata: $capabilities->getSdkMetadata(), countGroupByExecutionStatus: $capabilities->getCountGroupByExecutionStatus(), + nexus: $capabilities->getNexus(), ); } catch (ServiceClientException $e) { if ($e->getCode() === StatusCode::UNIMPLEMENTED) { @@ -233,10 +233,6 @@ public function getConnection(): ConnectionInterface /** * @param non-empty-string $method RPC method name - * @param object $arg - * @param ContextInterface|null $ctx - * - * @return mixed * * @throw ClientException */ @@ -262,10 +258,6 @@ protected function invoke(string $method, object $arg, ?ContextInterface $ctx = * Used in {@see withInterceptorPipeline()} * * @param non-empty-string $method - * @param object $arg - * @param ContextInterface $ctx - * - * @return object * * @throws \Exception */ @@ -339,7 +331,7 @@ private function call(string $method, object $arg, ContextInterface $ctx): objec ? $congestionInitialIntervalMs : $initialIntervalMs; - $wait = $throttler->calculateSleepTime(failureCount: $attempt, initialInterval: $baseInterval); + $wait = $throttler->calculateSleepTime(failureCount: $attempt, initialInterval: $baseInterval) * 1000; // wait till the next call $this->usleep($wait); diff --git a/src/Client/GRPC/ContextInterface.php b/src/Client/GRPC/ContextInterface.php index 0a6bc61ed..8f33b51ef 100644 --- a/src/Client/GRPC/ContextInterface.php +++ b/src/Client/GRPC/ContextInterface.php @@ -21,52 +21,26 @@ interface ContextInterface { /** * @param DateIntervalValue $timeout - * @param string $format * @return $this */ public function withTimeout($timeout, string $format = DateInterval::FORMAT_SECONDS): ContextInterface; /** - * @param \DateTimeInterface $deadline * @return $this */ public function withDeadline(\DateTimeInterface $deadline): ContextInterface; - /** - * @param array $options - * @return ContextInterface - */ public function withOptions(array $options): ContextInterface; - /** - * @param array $metadata - * @return ContextInterface - */ public function withMetadata(array $metadata): ContextInterface; - /** - * @param RetryOptions $options - * @return ContextInterface - */ public function withRetryOptions(RetryOptions $options): ContextInterface; - /** - * @return array - */ public function getOptions(): array; - /** - * @return array - */ public function getMetadata(): array; - /** - * @return \DateTimeInterface|null - */ public function getDeadline(): ?\DateTimeInterface; - /** - * @return RetryOptions - */ public function getRetryOptions(): RetryOptions; } diff --git a/src/Client/GRPC/ServiceClient.php b/src/Client/GRPC/ServiceClient.php index a1bb3b070..88ee5793a 100644 --- a/src/Client/GRPC/ServiceClient.php +++ b/src/Client/GRPC/ServiceClient.php @@ -27,12 +27,9 @@ class ServiceClient extends BaseClient * exactly one * namespace. * - * @param V1\RegisterNamespaceRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RegisterNamespaceResponse * @throws ServiceClientException */ - public function RegisterNamespace(V1\RegisterNamespaceRequest $arg, ContextInterface $ctx = null): V1\RegisterNamespaceResponse + public function RegisterNamespace(V1\RegisterNamespaceRequest $arg, ?ContextInterface $ctx = null): V1\RegisterNamespaceResponse { return $this->invoke("RegisterNamespace", $arg, $ctx); } @@ -41,12 +38,9 @@ public function RegisterNamespace(V1\RegisterNamespaceRequest $arg, ContextInter * DescribeNamespace returns the information and configuration for a registered * namespace. * - * @param V1\DescribeNamespaceRequest $arg - * @param ContextInterface|null $ctx - * @return V1\DescribeNamespaceResponse * @throws ServiceClientException */ - public function DescribeNamespace(V1\DescribeNamespaceRequest $arg, ContextInterface $ctx = null): V1\DescribeNamespaceResponse + public function DescribeNamespace(V1\DescribeNamespaceRequest $arg, ?ContextInterface $ctx = null): V1\DescribeNamespaceResponse { return $this->invoke("DescribeNamespace", $arg, $ctx); } @@ -54,12 +48,9 @@ public function DescribeNamespace(V1\DescribeNamespaceRequest $arg, ContextInter /** * ListNamespaces returns the information and configuration for all namespaces. * - * @param V1\ListNamespacesRequest $arg - * @param ContextInterface|null $ctx - * @return V1\ListNamespacesResponse * @throws ServiceClientException */ - public function ListNamespaces(V1\ListNamespacesRequest $arg, ContextInterface $ctx = null): V1\ListNamespacesResponse + public function ListNamespaces(V1\ListNamespacesRequest $arg, ?ContextInterface $ctx = null): V1\ListNamespacesResponse { return $this->invoke("ListNamespaces", $arg, $ctx); } @@ -69,12 +60,9 @@ public function ListNamespaces(V1\ListNamespacesRequest $arg, ContextInterface $ * registered * namespace. * - * @param V1\UpdateNamespaceRequest $arg - * @param ContextInterface|null $ctx - * @return V1\UpdateNamespaceResponse * @throws ServiceClientException */ - public function UpdateNamespace(V1\UpdateNamespaceRequest $arg, ContextInterface $ctx = null): V1\UpdateNamespaceResponse + public function UpdateNamespace(V1\UpdateNamespaceRequest $arg, ?ContextInterface $ctx = null): V1\UpdateNamespaceResponse { return $this->invoke("UpdateNamespace", $arg, $ctx); } @@ -91,12 +79,9 @@ public function UpdateNamespace(V1\UpdateNamespaceRequest $arg, ContextInterface * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: Deprecated --) * - * @param V1\DeprecateNamespaceRequest $arg - * @param ContextInterface|null $ctx - * @return V1\DeprecateNamespaceResponse * @throws ServiceClientException */ - public function DeprecateNamespace(V1\DeprecateNamespaceRequest $arg, ContextInterface $ctx = null): V1\DeprecateNamespaceResponse + public function DeprecateNamespace(V1\DeprecateNamespaceRequest $arg, ?ContextInterface $ctx = null): V1\DeprecateNamespaceResponse { return $this->invoke("DeprecateNamespace", $arg, $ctx); } @@ -110,27 +95,44 @@ public function DeprecateNamespace(V1\DeprecateNamespaceRequest $arg, ContextInt * `WorkflowExecutionAlreadyStarted`, if an * instance already exists with same workflow id. * - * @param V1\StartWorkflowExecutionRequest $arg - * @param ContextInterface|null $ctx - * @return V1\StartWorkflowExecutionResponse * @throws ServiceClientException */ - public function StartWorkflowExecution(V1\StartWorkflowExecutionRequest $arg, ContextInterface $ctx = null): V1\StartWorkflowExecutionResponse + public function StartWorkflowExecution(V1\StartWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\StartWorkflowExecutionResponse { return $this->invoke("StartWorkflowExecution", $arg, $ctx); } + /** + * ExecuteMultiOperation executes multiple operations within a single workflow. + * + * Operations are started atomically, meaning if *any* operation fails to be + * started, none are, + * and the request fails. Upon start, the API returns only when *all* operations + * have a response. + * + * Upon failure, it returns `MultiOperationExecutionFailure` where the status code + * equals the status code of the *first* operation that failed to be started. + * + * NOTE: Experimental API. + * + * @param V1\ExecuteMultiOperationRequest $arg + * @param ContextInterface|null $ctx + * @return V1\ExecuteMultiOperationResponse + * @throws ServiceClientException + */ + public function ExecuteMultiOperation(V1\ExecuteMultiOperationRequest $arg, ?ContextInterface $ctx = null): V1\ExecuteMultiOperationResponse + { + return $this->invoke("ExecuteMultiOperation", $arg, $ctx); + } + /** * GetWorkflowExecutionHistory returns the history of specified workflow execution. * Fails with * `NotFound` if the specified workflow execution is unknown to the service. * - * @param V1\GetWorkflowExecutionHistoryRequest $arg - * @param ContextInterface|null $ctx - * @return V1\GetWorkflowExecutionHistoryResponse * @throws ServiceClientException */ - public function GetWorkflowExecutionHistory(V1\GetWorkflowExecutionHistoryRequest $arg, ContextInterface $ctx = null): V1\GetWorkflowExecutionHistoryResponse + public function GetWorkflowExecutionHistory(V1\GetWorkflowExecutionHistoryRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkflowExecutionHistoryResponse { return $this->invoke("GetWorkflowExecutionHistory", $arg, $ctx); } @@ -142,12 +144,9 @@ public function GetWorkflowExecutionHistory(V1\GetWorkflowExecutionHistoryReques * execution is * unknown to the service. * - * @param V1\GetWorkflowExecutionHistoryReverseRequest $arg - * @param ContextInterface|null $ctx - * @return V1\GetWorkflowExecutionHistoryReverseResponse * @throws ServiceClientException */ - public function GetWorkflowExecutionHistoryReverse(V1\GetWorkflowExecutionHistoryReverseRequest $arg, ContextInterface $ctx = null): V1\GetWorkflowExecutionHistoryReverseResponse + public function GetWorkflowExecutionHistoryReverse(V1\GetWorkflowExecutionHistoryReverseRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkflowExecutionHistoryReverseResponse { return $this->invoke("GetWorkflowExecutionHistoryReverse", $arg, $ctx); } @@ -166,12 +165,9 @@ public function GetWorkflowExecutionHistoryReverse(V1\GetWorkflowExecutionHistor * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: We do not expose worker API to HTTP. --) * - * @param V1\PollWorkflowTaskQueueRequest $arg - * @param ContextInterface|null $ctx - * @return V1\PollWorkflowTaskQueueResponse * @throws ServiceClientException */ - public function PollWorkflowTaskQueue(V1\PollWorkflowTaskQueueRequest $arg, ContextInterface $ctx = null): V1\PollWorkflowTaskQueueResponse + public function PollWorkflowTaskQueue(V1\PollWorkflowTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\PollWorkflowTaskQueueResponse { return $this->invoke("PollWorkflowTaskQueue", $arg, $ctx); } @@ -190,12 +186,9 @@ public function PollWorkflowTaskQueue(V1\PollWorkflowTaskQueueRequest $arg, Cont * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: We do not expose worker API to HTTP. --) * - * @param V1\RespondWorkflowTaskCompletedRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RespondWorkflowTaskCompletedResponse * @throws ServiceClientException */ - public function RespondWorkflowTaskCompleted(V1\RespondWorkflowTaskCompletedRequest $arg, ContextInterface $ctx = null): V1\RespondWorkflowTaskCompletedResponse + public function RespondWorkflowTaskCompleted(V1\RespondWorkflowTaskCompletedRequest $arg, ?ContextInterface $ctx = null): V1\RespondWorkflowTaskCompletedResponse { return $this->invoke("RespondWorkflowTaskCompleted", $arg, $ctx); } @@ -218,12 +211,9 @@ public function RespondWorkflowTaskCompleted(V1\RespondWorkflowTaskCompletedRequ * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: We do not expose worker API to HTTP. --) * - * @param V1\RespondWorkflowTaskFailedRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RespondWorkflowTaskFailedResponse * @throws ServiceClientException */ - public function RespondWorkflowTaskFailed(V1\RespondWorkflowTaskFailedRequest $arg, ContextInterface $ctx = null): V1\RespondWorkflowTaskFailedResponse + public function RespondWorkflowTaskFailed(V1\RespondWorkflowTaskFailedRequest $arg, ?ContextInterface $ctx = null): V1\RespondWorkflowTaskFailedResponse { return $this->invoke("RespondWorkflowTaskFailed", $arg, $ctx); } @@ -252,12 +242,9 @@ public function RespondWorkflowTaskFailed(V1\RespondWorkflowTaskFailedRequest $a * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: We do not expose worker API to HTTP. --) * - * @param V1\PollActivityTaskQueueRequest $arg - * @param ContextInterface|null $ctx - * @return V1\PollActivityTaskQueueResponse * @throws ServiceClientException */ - public function PollActivityTaskQueue(V1\PollActivityTaskQueueRequest $arg, ContextInterface $ctx = null): V1\PollActivityTaskQueueResponse + public function PollActivityTaskQueue(V1\PollActivityTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\PollActivityTaskQueueResponse { return $this->invoke("PollActivityTaskQueue", $arg, $ctx); } @@ -275,12 +262,9 @@ public function PollActivityTaskQueue(V1\PollActivityTaskQueueRequest $arg, Cont * such situations, in that event, the SDK should request cancellation of the * activity. * - * @param V1\RecordActivityTaskHeartbeatRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RecordActivityTaskHeartbeatResponse * @throws ServiceClientException */ - public function RecordActivityTaskHeartbeat(V1\RecordActivityTaskHeartbeatRequest $arg, ContextInterface $ctx = null): V1\RecordActivityTaskHeartbeatResponse + public function RecordActivityTaskHeartbeat(V1\RecordActivityTaskHeartbeatRequest $arg, ?ContextInterface $ctx = null): V1\RecordActivityTaskHeartbeatResponse { return $this->invoke("RecordActivityTaskHeartbeat", $arg, $ctx); } @@ -293,12 +277,9 @@ public function RecordActivityTaskHeartbeat(V1\RecordActivityTaskHeartbeatReques * (-- api-linter: core::0136::prepositions=disabled * aip.dev/not-precedent: "By" is used to indicate request type. --) * - * @param V1\RecordActivityTaskHeartbeatByIdRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RecordActivityTaskHeartbeatByIdResponse * @throws ServiceClientException */ - public function RecordActivityTaskHeartbeatById(V1\RecordActivityTaskHeartbeatByIdRequest $arg, ContextInterface $ctx = null): V1\RecordActivityTaskHeartbeatByIdResponse + public function RecordActivityTaskHeartbeatById(V1\RecordActivityTaskHeartbeatByIdRequest $arg, ?ContextInterface $ctx = null): V1\RecordActivityTaskHeartbeatByIdResponse { return $this->invoke("RecordActivityTaskHeartbeatById", $arg, $ctx); } @@ -315,12 +296,9 @@ public function RecordActivityTaskHeartbeatById(V1\RecordActivityTaskHeartbeatBy * no longer valid due to activity timeout, already being completed, or never * having existed. * - * @param V1\RespondActivityTaskCompletedRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RespondActivityTaskCompletedResponse * @throws ServiceClientException */ - public function RespondActivityTaskCompleted(V1\RespondActivityTaskCompletedRequest $arg, ContextInterface $ctx = null): V1\RespondActivityTaskCompletedResponse + public function RespondActivityTaskCompleted(V1\RespondActivityTaskCompletedRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskCompletedResponse { return $this->invoke("RespondActivityTaskCompleted", $arg, $ctx); } @@ -333,12 +311,9 @@ public function RespondActivityTaskCompleted(V1\RespondActivityTaskCompletedRequ * (-- api-linter: core::0136::prepositions=disabled * aip.dev/not-precedent: "By" is used to indicate request type. --) * - * @param V1\RespondActivityTaskCompletedByIdRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RespondActivityTaskCompletedByIdResponse * @throws ServiceClientException */ - public function RespondActivityTaskCompletedById(V1\RespondActivityTaskCompletedByIdRequest $arg, ContextInterface $ctx = null): V1\RespondActivityTaskCompletedByIdResponse + public function RespondActivityTaskCompletedById(V1\RespondActivityTaskCompletedByIdRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskCompletedByIdResponse { return $this->invoke("RespondActivityTaskCompletedById", $arg, $ctx); } @@ -354,12 +329,9 @@ public function RespondActivityTaskCompletedById(V1\RespondActivityTaskCompleted * longer valid due to activity timeout, already being completed, or never having * existed. * - * @param V1\RespondActivityTaskFailedRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RespondActivityTaskFailedResponse * @throws ServiceClientException */ - public function RespondActivityTaskFailed(V1\RespondActivityTaskFailedRequest $arg, ContextInterface $ctx = null): V1\RespondActivityTaskFailedResponse + public function RespondActivityTaskFailed(V1\RespondActivityTaskFailedRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskFailedResponse { return $this->invoke("RespondActivityTaskFailed", $arg, $ctx); } @@ -372,12 +344,9 @@ public function RespondActivityTaskFailed(V1\RespondActivityTaskFailedRequest $a * (-- api-linter: core::0136::prepositions=disabled * aip.dev/not-precedent: "By" is used to indicate request type. --) * - * @param V1\RespondActivityTaskFailedByIdRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RespondActivityTaskFailedByIdResponse * @throws ServiceClientException */ - public function RespondActivityTaskFailedById(V1\RespondActivityTaskFailedByIdRequest $arg, ContextInterface $ctx = null): V1\RespondActivityTaskFailedByIdResponse + public function RespondActivityTaskFailedById(V1\RespondActivityTaskFailedByIdRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskFailedByIdResponse { return $this->invoke("RespondActivityTaskFailedById", $arg, $ctx); } @@ -393,12 +362,9 @@ public function RespondActivityTaskFailedById(V1\RespondActivityTaskFailedByIdRe * no longer valid due to activity timeout, already being completed, or never * having existed. * - * @param V1\RespondActivityTaskCanceledRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RespondActivityTaskCanceledResponse * @throws ServiceClientException */ - public function RespondActivityTaskCanceled(V1\RespondActivityTaskCanceledRequest $arg, ContextInterface $ctx = null): V1\RespondActivityTaskCanceledResponse + public function RespondActivityTaskCanceled(V1\RespondActivityTaskCanceledRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskCanceledResponse { return $this->invoke("RespondActivityTaskCanceled", $arg, $ctx); } @@ -411,12 +377,9 @@ public function RespondActivityTaskCanceled(V1\RespondActivityTaskCanceledReques * (-- api-linter: core::0136::prepositions=disabled * aip.dev/not-precedent: "By" is used to indicate request type. --) * - * @param V1\RespondActivityTaskCanceledByIdRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RespondActivityTaskCanceledByIdResponse * @throws ServiceClientException */ - public function RespondActivityTaskCanceledById(V1\RespondActivityTaskCanceledByIdRequest $arg, ContextInterface $ctx = null): V1\RespondActivityTaskCanceledByIdResponse + public function RespondActivityTaskCanceledById(V1\RespondActivityTaskCanceledByIdRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskCanceledByIdResponse { return $this->invoke("RespondActivityTaskCanceledById", $arg, $ctx); } @@ -433,12 +396,9 @@ public function RespondActivityTaskCanceledById(V1\RespondActivityTaskCanceledBy * workflow is already closed. It fails with 'NotFound' if the requested workflow * doesn't exist. * - * @param V1\RequestCancelWorkflowExecutionRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RequestCancelWorkflowExecutionResponse * @throws ServiceClientException */ - public function RequestCancelWorkflowExecution(V1\RequestCancelWorkflowExecutionRequest $arg, ContextInterface $ctx = null): V1\RequestCancelWorkflowExecutionResponse + public function RequestCancelWorkflowExecution(V1\RequestCancelWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\RequestCancelWorkflowExecutionResponse { return $this->invoke("RequestCancelWorkflowExecution", $arg, $ctx); } @@ -451,12 +411,9 @@ public function RequestCancelWorkflowExecution(V1\RequestCancelWorkflowExecution * and a workflow * task being created for the execution. * - * @param V1\SignalWorkflowExecutionRequest $arg - * @param ContextInterface|null $ctx - * @return V1\SignalWorkflowExecutionResponse * @throws ServiceClientException */ - public function SignalWorkflowExecution(V1\SignalWorkflowExecutionRequest $arg, ContextInterface $ctx = null): V1\SignalWorkflowExecutionResponse + public function SignalWorkflowExecution(V1\SignalWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\SignalWorkflowExecutionResponse { return $this->invoke("SignalWorkflowExecution", $arg, $ctx); } @@ -478,12 +435,9 @@ public function SignalWorkflowExecution(V1\SignalWorkflowExecutionRequest $arg, * (-- api-linter: core::0136::prepositions=disabled * aip.dev/not-precedent: "With" is used to indicate combined operation. --) * - * @param V1\SignalWithStartWorkflowExecutionRequest $arg - * @param ContextInterface|null $ctx - * @return V1\SignalWithStartWorkflowExecutionResponse * @throws ServiceClientException */ - public function SignalWithStartWorkflowExecution(V1\SignalWithStartWorkflowExecutionRequest $arg, ContextInterface $ctx = null): V1\SignalWithStartWorkflowExecutionResponse + public function SignalWithStartWorkflowExecution(V1\SignalWithStartWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\SignalWithStartWorkflowExecutionResponse { return $this->invoke("SignalWithStartWorkflowExecution", $arg, $ctx); } @@ -496,12 +450,9 @@ public function SignalWithStartWorkflowExecution(V1\SignalWithStartWorkflowExecu * TODO: Does exclusive here mean *just* the completed event, or also WFT started? * Otherwise the task is doomed to time out? * - * @param V1\ResetWorkflowExecutionRequest $arg - * @param ContextInterface|null $ctx - * @return V1\ResetWorkflowExecutionResponse * @throws ServiceClientException */ - public function ResetWorkflowExecution(V1\ResetWorkflowExecutionRequest $arg, ContextInterface $ctx = null): V1\ResetWorkflowExecutionResponse + public function ResetWorkflowExecution(V1\ResetWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\ResetWorkflowExecutionResponse { return $this->invoke("ResetWorkflowExecution", $arg, $ctx); } @@ -513,12 +464,9 @@ public function ResetWorkflowExecution(V1\ResetWorkflowExecutionRequest $arg, Co * the * execution instance. * - * @param V1\TerminateWorkflowExecutionRequest $arg - * @param ContextInterface|null $ctx - * @return V1\TerminateWorkflowExecutionResponse * @throws ServiceClientException */ - public function TerminateWorkflowExecution(V1\TerminateWorkflowExecutionRequest $arg, ContextInterface $ctx = null): V1\TerminateWorkflowExecutionResponse + public function TerminateWorkflowExecution(V1\TerminateWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\TerminateWorkflowExecutionResponse { return $this->invoke("TerminateWorkflowExecution", $arg, $ctx); } @@ -535,12 +483,9 @@ public function TerminateWorkflowExecution(V1\TerminateWorkflowExecutionRequest * aip.dev/not-precedent: Workflow deletion not exposed to HTTP, users should use * cancel or terminate. --) * - * @param V1\DeleteWorkflowExecutionRequest $arg - * @param ContextInterface|null $ctx - * @return V1\DeleteWorkflowExecutionResponse * @throws ServiceClientException */ - public function DeleteWorkflowExecution(V1\DeleteWorkflowExecutionRequest $arg, ContextInterface $ctx = null): V1\DeleteWorkflowExecutionResponse + public function DeleteWorkflowExecution(V1\DeleteWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\DeleteWorkflowExecutionResponse { return $this->invoke("DeleteWorkflowExecution", $arg, $ctx); } @@ -552,12 +497,9 @@ public function DeleteWorkflowExecution(V1\DeleteWorkflowExecutionRequest $arg, * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: HTTP users should use ListWorkflowExecutions instead. --) * - * @param V1\ListOpenWorkflowExecutionsRequest $arg - * @param ContextInterface|null $ctx - * @return V1\ListOpenWorkflowExecutionsResponse * @throws ServiceClientException */ - public function ListOpenWorkflowExecutions(V1\ListOpenWorkflowExecutionsRequest $arg, ContextInterface $ctx = null): V1\ListOpenWorkflowExecutionsResponse + public function ListOpenWorkflowExecutions(V1\ListOpenWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ListOpenWorkflowExecutionsResponse { return $this->invoke("ListOpenWorkflowExecutions", $arg, $ctx); } @@ -569,12 +511,9 @@ public function ListOpenWorkflowExecutions(V1\ListOpenWorkflowExecutionsRequest * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: HTTP users should use ListWorkflowExecutions instead. --) * - * @param V1\ListClosedWorkflowExecutionsRequest $arg - * @param ContextInterface|null $ctx - * @return V1\ListClosedWorkflowExecutionsResponse * @throws ServiceClientException */ - public function ListClosedWorkflowExecutions(V1\ListClosedWorkflowExecutionsRequest $arg, ContextInterface $ctx = null): V1\ListClosedWorkflowExecutionsResponse + public function ListClosedWorkflowExecutions(V1\ListClosedWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ListClosedWorkflowExecutionsResponse { return $this->invoke("ListClosedWorkflowExecutions", $arg, $ctx); } @@ -583,12 +522,9 @@ public function ListClosedWorkflowExecutions(V1\ListClosedWorkflowExecutionsRequ * ListWorkflowExecutions is a visibility API to list workflow executions in a * specific namespace. * - * @param V1\ListWorkflowExecutionsRequest $arg - * @param ContextInterface|null $ctx - * @return V1\ListWorkflowExecutionsResponse * @throws ServiceClientException */ - public function ListWorkflowExecutions(V1\ListWorkflowExecutionsRequest $arg, ContextInterface $ctx = null): V1\ListWorkflowExecutionsResponse + public function ListWorkflowExecutions(V1\ListWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ListWorkflowExecutionsResponse { return $this->invoke("ListWorkflowExecutions", $arg, $ctx); } @@ -597,12 +533,9 @@ public function ListWorkflowExecutions(V1\ListWorkflowExecutionsRequest $arg, Co * ListArchivedWorkflowExecutions is a visibility API to list archived workflow * executions in a specific namespace. * - * @param V1\ListArchivedWorkflowExecutionsRequest $arg - * @param ContextInterface|null $ctx - * @return V1\ListArchivedWorkflowExecutionsResponse * @throws ServiceClientException */ - public function ListArchivedWorkflowExecutions(V1\ListArchivedWorkflowExecutionsRequest $arg, ContextInterface $ctx = null): V1\ListArchivedWorkflowExecutionsResponse + public function ListArchivedWorkflowExecutions(V1\ListArchivedWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ListArchivedWorkflowExecutionsResponse { return $this->invoke("ListArchivedWorkflowExecutions", $arg, $ctx); } @@ -614,12 +547,9 @@ public function ListArchivedWorkflowExecutions(V1\ListArchivedWorkflowExecutions * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: HTTP users should use ListWorkflowExecutions instead. --) * - * @param V1\ScanWorkflowExecutionsRequest $arg - * @param ContextInterface|null $ctx - * @return V1\ScanWorkflowExecutionsResponse * @throws ServiceClientException */ - public function ScanWorkflowExecutions(V1\ScanWorkflowExecutionsRequest $arg, ContextInterface $ctx = null): V1\ScanWorkflowExecutionsResponse + public function ScanWorkflowExecutions(V1\ScanWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ScanWorkflowExecutionsResponse { return $this->invoke("ScanWorkflowExecutions", $arg, $ctx); } @@ -628,12 +558,9 @@ public function ScanWorkflowExecutions(V1\ScanWorkflowExecutionsRequest $arg, Co * CountWorkflowExecutions is a visibility API to count of workflow executions in a * specific namespace. * - * @param V1\CountWorkflowExecutionsRequest $arg - * @param ContextInterface|null $ctx - * @return V1\CountWorkflowExecutionsResponse * @throws ServiceClientException */ - public function CountWorkflowExecutions(V1\CountWorkflowExecutionsRequest $arg, ContextInterface $ctx = null): V1\CountWorkflowExecutionsResponse + public function CountWorkflowExecutions(V1\CountWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\CountWorkflowExecutionsResponse { return $this->invoke("CountWorkflowExecutions", $arg, $ctx); } @@ -646,12 +573,9 @@ public function CountWorkflowExecutions(V1\CountWorkflowExecutionsRequest $arg, * aip.dev/not-precedent: We do not expose this search attribute API to HTTP (but * may expose on OperatorService). --) * - * @param V1\GetSearchAttributesRequest $arg - * @param ContextInterface|null $ctx - * @return V1\GetSearchAttributesResponse * @throws ServiceClientException */ - public function GetSearchAttributes(V1\GetSearchAttributesRequest $arg, ContextInterface $ctx = null): V1\GetSearchAttributesResponse + public function GetSearchAttributes(V1\GetSearchAttributesRequest $arg, ?ContextInterface $ctx = null): V1\GetSearchAttributesResponse { return $this->invoke("GetSearchAttributes", $arg, $ctx); } @@ -668,12 +592,9 @@ public function GetSearchAttributes(V1\GetSearchAttributesRequest $arg, ContextI * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: We do not expose worker API to HTTP. --) * - * @param V1\RespondQueryTaskCompletedRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RespondQueryTaskCompletedResponse * @throws ServiceClientException */ - public function RespondQueryTaskCompleted(V1\RespondQueryTaskCompletedRequest $arg, ContextInterface $ctx = null): V1\RespondQueryTaskCompletedResponse + public function RespondQueryTaskCompleted(V1\RespondQueryTaskCompletedRequest $arg, ?ContextInterface $ctx = null): V1\RespondQueryTaskCompletedResponse { return $this->invoke("RespondQueryTaskCompleted", $arg, $ctx); } @@ -692,12 +613,9 @@ public function RespondQueryTaskCompleted(V1\RespondQueryTaskCompletedRequest $a * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: We do not expose worker API to HTTP. --) * - * @param V1\ResetStickyTaskQueueRequest $arg - * @param ContextInterface|null $ctx - * @return V1\ResetStickyTaskQueueResponse * @throws ServiceClientException */ - public function ResetStickyTaskQueue(V1\ResetStickyTaskQueueRequest $arg, ContextInterface $ctx = null): V1\ResetStickyTaskQueueResponse + public function ResetStickyTaskQueue(V1\ResetStickyTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\ResetStickyTaskQueueResponse { return $this->invoke("ResetStickyTaskQueue", $arg, $ctx); } @@ -705,12 +623,9 @@ public function ResetStickyTaskQueue(V1\ResetStickyTaskQueueRequest $arg, Contex /** * QueryWorkflow requests a query be executed for a specified workflow execution. * - * @param V1\QueryWorkflowRequest $arg - * @param ContextInterface|null $ctx - * @return V1\QueryWorkflowResponse * @throws ServiceClientException */ - public function QueryWorkflow(V1\QueryWorkflowRequest $arg, ContextInterface $ctx = null): V1\QueryWorkflowResponse + public function QueryWorkflow(V1\QueryWorkflowRequest $arg, ?ContextInterface $ctx = null): V1\QueryWorkflowResponse { return $this->invoke("QueryWorkflow", $arg, $ctx); } @@ -719,12 +634,9 @@ public function QueryWorkflow(V1\QueryWorkflowRequest $arg, ContextInterface $ct * DescribeWorkflowExecution returns information about the specified workflow * execution. * - * @param V1\DescribeWorkflowExecutionRequest $arg - * @param ContextInterface|null $ctx - * @return V1\DescribeWorkflowExecutionResponse * @throws ServiceClientException */ - public function DescribeWorkflowExecution(V1\DescribeWorkflowExecutionRequest $arg, ContextInterface $ctx = null): V1\DescribeWorkflowExecutionResponse + public function DescribeWorkflowExecution(V1\DescribeWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\DescribeWorkflowExecutionResponse { return $this->invoke("DescribeWorkflowExecution", $arg, $ctx); } @@ -736,12 +648,9 @@ public function DescribeWorkflowExecution(V1\DescribeWorkflowExecutionRequest $a * - Workflow Reachability status * - Backlog info for Workflow and/or Activity tasks * - * @param V1\DescribeTaskQueueRequest $arg - * @param ContextInterface|null $ctx - * @return V1\DescribeTaskQueueResponse * @throws ServiceClientException */ - public function DescribeTaskQueue(V1\DescribeTaskQueueRequest $arg, ContextInterface $ctx = null): V1\DescribeTaskQueueResponse + public function DescribeTaskQueue(V1\DescribeTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\DescribeTaskQueueResponse { return $this->invoke("DescribeTaskQueue", $arg, $ctx); } @@ -749,12 +658,9 @@ public function DescribeTaskQueue(V1\DescribeTaskQueueRequest $arg, ContextInter /** * GetClusterInfo returns information about temporal cluster * - * @param V1\GetClusterInfoRequest $arg - * @param ContextInterface|null $ctx - * @return V1\GetClusterInfoResponse * @throws ServiceClientException */ - public function GetClusterInfo(V1\GetClusterInfoRequest $arg, ContextInterface $ctx = null): V1\GetClusterInfoResponse + public function GetClusterInfo(V1\GetClusterInfoRequest $arg, ?ContextInterface $ctx = null): V1\GetClusterInfoResponse { return $this->invoke("GetClusterInfo", $arg, $ctx); } @@ -762,12 +668,9 @@ public function GetClusterInfo(V1\GetClusterInfoRequest $arg, ContextInterface $ /** * GetSystemInfo returns information about the system. * - * @param V1\GetSystemInfoRequest $arg - * @param ContextInterface|null $ctx - * @return V1\GetSystemInfoResponse * @throws ServiceClientException */ - public function GetSystemInfo(V1\GetSystemInfoRequest $arg, ContextInterface $ctx = null): V1\GetSystemInfoResponse + public function GetSystemInfo(V1\GetSystemInfoRequest $arg, ?ContextInterface $ctx = null): V1\GetSystemInfoResponse { return $this->invoke("GetSystemInfo", $arg, $ctx); } @@ -776,12 +679,9 @@ public function GetSystemInfo(V1\GetSystemInfoRequest $arg, ContextInterface $ct * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: We do not expose this low-level API to HTTP. --) * - * @param V1\ListTaskQueuePartitionsRequest $arg - * @param ContextInterface|null $ctx - * @return V1\ListTaskQueuePartitionsResponse * @throws ServiceClientException */ - public function ListTaskQueuePartitions(V1\ListTaskQueuePartitionsRequest $arg, ContextInterface $ctx = null): V1\ListTaskQueuePartitionsResponse + public function ListTaskQueuePartitions(V1\ListTaskQueuePartitionsRequest $arg, ?ContextInterface $ctx = null): V1\ListTaskQueuePartitionsResponse { return $this->invoke("ListTaskQueuePartitions", $arg, $ctx); } @@ -789,12 +689,9 @@ public function ListTaskQueuePartitions(V1\ListTaskQueuePartitionsRequest $arg, /** * Creates a new schedule. * - * @param V1\CreateScheduleRequest $arg - * @param ContextInterface|null $ctx - * @return V1\CreateScheduleResponse * @throws ServiceClientException */ - public function CreateSchedule(V1\CreateScheduleRequest $arg, ContextInterface $ctx = null): V1\CreateScheduleResponse + public function CreateSchedule(V1\CreateScheduleRequest $arg, ?ContextInterface $ctx = null): V1\CreateScheduleResponse { return $this->invoke("CreateSchedule", $arg, $ctx); } @@ -802,12 +699,9 @@ public function CreateSchedule(V1\CreateScheduleRequest $arg, ContextInterface $ /** * Returns the schedule description and current state of an existing schedule. * - * @param V1\DescribeScheduleRequest $arg - * @param ContextInterface|null $ctx - * @return V1\DescribeScheduleResponse * @throws ServiceClientException */ - public function DescribeSchedule(V1\DescribeScheduleRequest $arg, ContextInterface $ctx = null): V1\DescribeScheduleResponse + public function DescribeSchedule(V1\DescribeScheduleRequest $arg, ?ContextInterface $ctx = null): V1\DescribeScheduleResponse { return $this->invoke("DescribeSchedule", $arg, $ctx); } @@ -815,12 +709,9 @@ public function DescribeSchedule(V1\DescribeScheduleRequest $arg, ContextInterfa /** * Changes the configuration or state of an existing schedule. * - * @param V1\UpdateScheduleRequest $arg - * @param ContextInterface|null $ctx - * @return V1\UpdateScheduleResponse * @throws ServiceClientException */ - public function UpdateSchedule(V1\UpdateScheduleRequest $arg, ContextInterface $ctx = null): V1\UpdateScheduleResponse + public function UpdateSchedule(V1\UpdateScheduleRequest $arg, ?ContextInterface $ctx = null): V1\UpdateScheduleResponse { return $this->invoke("UpdateSchedule", $arg, $ctx); } @@ -828,12 +719,9 @@ public function UpdateSchedule(V1\UpdateScheduleRequest $arg, ContextInterface $ /** * Makes a specific change to a schedule or triggers an immediate action. * - * @param V1\PatchScheduleRequest $arg - * @param ContextInterface|null $ctx - * @return V1\PatchScheduleResponse * @throws ServiceClientException */ - public function PatchSchedule(V1\PatchScheduleRequest $arg, ContextInterface $ctx = null): V1\PatchScheduleResponse + public function PatchSchedule(V1\PatchScheduleRequest $arg, ?ContextInterface $ctx = null): V1\PatchScheduleResponse { return $this->invoke("PatchSchedule", $arg, $ctx); } @@ -841,12 +729,9 @@ public function PatchSchedule(V1\PatchScheduleRequest $arg, ContextInterface $ct /** * Lists matching times within a range. * - * @param V1\ListScheduleMatchingTimesRequest $arg - * @param ContextInterface|null $ctx - * @return V1\ListScheduleMatchingTimesResponse * @throws ServiceClientException */ - public function ListScheduleMatchingTimes(V1\ListScheduleMatchingTimesRequest $arg, ContextInterface $ctx = null): V1\ListScheduleMatchingTimesResponse + public function ListScheduleMatchingTimes(V1\ListScheduleMatchingTimesRequest $arg, ?ContextInterface $ctx = null): V1\ListScheduleMatchingTimesResponse { return $this->invoke("ListScheduleMatchingTimes", $arg, $ctx); } @@ -854,12 +739,9 @@ public function ListScheduleMatchingTimes(V1\ListScheduleMatchingTimesRequest $a /** * Deletes a schedule, removing it from the system. * - * @param V1\DeleteScheduleRequest $arg - * @param ContextInterface|null $ctx - * @return V1\DeleteScheduleResponse * @throws ServiceClientException */ - public function DeleteSchedule(V1\DeleteScheduleRequest $arg, ContextInterface $ctx = null): V1\DeleteScheduleResponse + public function DeleteSchedule(V1\DeleteScheduleRequest $arg, ?ContextInterface $ctx = null): V1\DeleteScheduleResponse { return $this->invoke("DeleteSchedule", $arg, $ctx); } @@ -867,12 +749,9 @@ public function DeleteSchedule(V1\DeleteScheduleRequest $arg, ContextInterface $ /** * List all schedules in a namespace. * - * @param V1\ListSchedulesRequest $arg - * @param ContextInterface|null $ctx - * @return V1\ListSchedulesResponse * @throws ServiceClientException */ - public function ListSchedules(V1\ListSchedulesRequest $arg, ContextInterface $ctx = null): V1\ListSchedulesResponse + public function ListSchedules(V1\ListSchedulesRequest $arg, ?ContextInterface $ctx = null): V1\ListSchedulesResponse { return $this->invoke("ListSchedules", $arg, $ctx); } @@ -902,12 +781,9 @@ public function ListSchedules(V1\ListSchedulesRequest $arg, ContextInterface $ct * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: We do yet expose versioning API to HTTP. --) * - * @param V1\UpdateWorkerBuildIdCompatibilityRequest $arg - * @param ContextInterface|null $ctx - * @return V1\UpdateWorkerBuildIdCompatibilityResponse * @throws ServiceClientException */ - public function UpdateWorkerBuildIdCompatibility(V1\UpdateWorkerBuildIdCompatibilityRequest $arg, ContextInterface $ctx = null): V1\UpdateWorkerBuildIdCompatibilityResponse + public function UpdateWorkerBuildIdCompatibility(V1\UpdateWorkerBuildIdCompatibilityRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkerBuildIdCompatibilityResponse { return $this->invoke("UpdateWorkerBuildIdCompatibility", $arg, $ctx); } @@ -916,30 +792,56 @@ public function UpdateWorkerBuildIdCompatibility(V1\UpdateWorkerBuildIdCompatibi * Deprecated. Use `GetWorkerVersioningRules`. * Fetches the worker build id versioning sets for a task queue. * - * @param V1\GetWorkerBuildIdCompatibilityRequest $arg - * @param ContextInterface|null $ctx - * @return V1\GetWorkerBuildIdCompatibilityResponse * @throws ServiceClientException */ - public function GetWorkerBuildIdCompatibility(V1\GetWorkerBuildIdCompatibilityRequest $arg, ContextInterface $ctx = null): V1\GetWorkerBuildIdCompatibilityResponse + public function GetWorkerBuildIdCompatibility(V1\GetWorkerBuildIdCompatibilityRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkerBuildIdCompatibilityResponse { return $this->invoke("GetWorkerBuildIdCompatibility", $arg, $ctx); } /** - * Allows updating the Build ID assignment and redirect rules for a given Task - * Queue. + * Use this API to manage Worker Versioning Rules for a given Task Queue. There are + * two types of + * rules: Build ID Assignment rules and Compatible Build ID Redirect rules. + * + * Assignment rules determine how to assign new executions to a Build IDs. Their + * primary + * use case is to specify the latest Build ID but they have powerful features for + * gradual rollout + * of a new Build ID. + * + * Once a workflow execution is assigned to a Build ID and it completes its first + * Workflow Task, + * the workflow stays on the assigned Build ID regardless of changes in assignment + * rules. This + * eliminates the need for compatibility between versions when you only care about + * using the new + * version for new workflows and let existing workflows finish in their own + * version. + * + * Activities, Child Workflows and Continue-as-New executions have the option to + * inherit the + * Build ID of their parent/previous workflow or use the latest assignment rules to + * independently + * select a Build ID. + * + * Redirect rules should only be used when you want to move workflows and + * activities assigned to + * one Build ID (source) to another compatible Build ID (target). You are + * responsible to make sure + * the target Build ID of a redirect rule is able to process event histories made + * by the source + * Build ID by using [Patching](https://docs.temporal.io/workflows#patching) or + * other means. + * * WARNING: Worker Versioning is not yet stable and the API and behavior may change * incompatibly. * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: We do yet expose versioning API to HTTP. --) * - * @param V1\UpdateWorkerVersioningRulesRequest $arg - * @param ContextInterface|null $ctx - * @return V1\UpdateWorkerVersioningRulesResponse * @throws ServiceClientException */ - public function UpdateWorkerVersioningRules(V1\UpdateWorkerVersioningRulesRequest $arg, ContextInterface $ctx = null): V1\UpdateWorkerVersioningRulesResponse + public function UpdateWorkerVersioningRules(V1\UpdateWorkerVersioningRulesRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkerVersioningRulesResponse { return $this->invoke("UpdateWorkerVersioningRules", $arg, $ctx); } @@ -949,12 +851,9 @@ public function UpdateWorkerVersioningRules(V1\UpdateWorkerVersioningRulesReques * WARNING: Worker Versioning is not yet stable and the API and behavior may change * incompatibly. * - * @param V1\GetWorkerVersioningRulesRequest $arg - * @param ContextInterface|null $ctx - * @return V1\GetWorkerVersioningRulesResponse * @throws ServiceClientException */ - public function GetWorkerVersioningRules(V1\GetWorkerVersioningRulesRequest $arg, ContextInterface $ctx = null): V1\GetWorkerVersioningRulesResponse + public function GetWorkerVersioningRules(V1\GetWorkerVersioningRulesRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkerVersioningRulesResponse { return $this->invoke("GetWorkerVersioningRules", $arg, $ctx); } @@ -982,12 +881,9 @@ public function GetWorkerVersioningRules(V1\GetWorkerVersioningRulesRequest $arg * `limit.reachabilityTaskQueueScan` with the caveat that this call can strain the * visibility store. * - * @param V1\GetWorkerTaskReachabilityRequest $arg - * @param ContextInterface|null $ctx - * @return V1\GetWorkerTaskReachabilityResponse * @throws ServiceClientException */ - public function GetWorkerTaskReachability(V1\GetWorkerTaskReachabilityRequest $arg, ContextInterface $ctx = null): V1\GetWorkerTaskReachabilityResponse + public function GetWorkerTaskReachability(V1\GetWorkerTaskReachabilityRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkerTaskReachabilityResponse { return $this->invoke("GetWorkerTaskReachability", $arg, $ctx); } @@ -995,12 +891,9 @@ public function GetWorkerTaskReachability(V1\GetWorkerTaskReachabilityRequest $a /** * Invokes the specified update function on user workflow code. * - * @param V1\UpdateWorkflowExecutionRequest $arg - * @param ContextInterface|null $ctx - * @return V1\UpdateWorkflowExecutionResponse * @throws ServiceClientException */ - public function UpdateWorkflowExecution(V1\UpdateWorkflowExecutionRequest $arg, ContextInterface $ctx = null): V1\UpdateWorkflowExecutionResponse + public function UpdateWorkflowExecution(V1\UpdateWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkflowExecutionResponse { return $this->invoke("UpdateWorkflowExecution", $arg, $ctx); } @@ -1015,12 +908,9 @@ public function UpdateWorkflowExecution(V1\UpdateWorkflowExecutionRequest $arg, * aip.dev/not-precedent: We don't expose update polling API to HTTP in favor of a * potential future non-blocking form. --) * - * @param V1\PollWorkflowExecutionUpdateRequest $arg - * @param ContextInterface|null $ctx - * @return V1\PollWorkflowExecutionUpdateResponse * @throws ServiceClientException */ - public function PollWorkflowExecutionUpdate(V1\PollWorkflowExecutionUpdateRequest $arg, ContextInterface $ctx = null): V1\PollWorkflowExecutionUpdateResponse + public function PollWorkflowExecutionUpdate(V1\PollWorkflowExecutionUpdateRequest $arg, ?ContextInterface $ctx = null): V1\PollWorkflowExecutionUpdateResponse { return $this->invoke("PollWorkflowExecutionUpdate", $arg, $ctx); } @@ -1028,12 +918,9 @@ public function PollWorkflowExecutionUpdate(V1\PollWorkflowExecutionUpdateReques /** * StartBatchOperation starts a new batch operation * - * @param V1\StartBatchOperationRequest $arg - * @param ContextInterface|null $ctx - * @return V1\StartBatchOperationResponse * @throws ServiceClientException */ - public function StartBatchOperation(V1\StartBatchOperationRequest $arg, ContextInterface $ctx = null): V1\StartBatchOperationResponse + public function StartBatchOperation(V1\StartBatchOperationRequest $arg, ?ContextInterface $ctx = null): V1\StartBatchOperationResponse { return $this->invoke("StartBatchOperation", $arg, $ctx); } @@ -1041,12 +928,9 @@ public function StartBatchOperation(V1\StartBatchOperationRequest $arg, ContextI /** * StopBatchOperation stops a batch operation * - * @param V1\StopBatchOperationRequest $arg - * @param ContextInterface|null $ctx - * @return V1\StopBatchOperationResponse * @throws ServiceClientException */ - public function StopBatchOperation(V1\StopBatchOperationRequest $arg, ContextInterface $ctx = null): V1\StopBatchOperationResponse + public function StopBatchOperation(V1\StopBatchOperationRequest $arg, ?ContextInterface $ctx = null): V1\StopBatchOperationResponse { return $this->invoke("StopBatchOperation", $arg, $ctx); } @@ -1054,12 +938,9 @@ public function StopBatchOperation(V1\StopBatchOperationRequest $arg, ContextInt /** * DescribeBatchOperation returns the information about a batch operation * - * @param V1\DescribeBatchOperationRequest $arg - * @param ContextInterface|null $ctx - * @return V1\DescribeBatchOperationResponse * @throws ServiceClientException */ - public function DescribeBatchOperation(V1\DescribeBatchOperationRequest $arg, ContextInterface $ctx = null): V1\DescribeBatchOperationResponse + public function DescribeBatchOperation(V1\DescribeBatchOperationRequest $arg, ?ContextInterface $ctx = null): V1\DescribeBatchOperationResponse { return $this->invoke("DescribeBatchOperation", $arg, $ctx); } @@ -1067,12 +948,9 @@ public function DescribeBatchOperation(V1\DescribeBatchOperationRequest $arg, Co /** * ListBatchOperations returns a list of batch operations * - * @param V1\ListBatchOperationsRequest $arg - * @param ContextInterface|null $ctx - * @return V1\ListBatchOperationsResponse * @throws ServiceClientException */ - public function ListBatchOperations(V1\ListBatchOperationsRequest $arg, ContextInterface $ctx = null): V1\ListBatchOperationsResponse + public function ListBatchOperations(V1\ListBatchOperationsRequest $arg, ?ContextInterface $ctx = null): V1\ListBatchOperationsResponse { return $this->invoke("ListBatchOperations", $arg, $ctx); } @@ -1082,12 +960,9 @@ public function ListBatchOperations(V1\ListBatchOperationsRequest $arg, ContextI * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: We do not expose worker API to HTTP. --) * - * @param V1\PollNexusTaskQueueRequest $arg - * @param ContextInterface|null $ctx - * @return V1\PollNexusTaskQueueResponse * @throws ServiceClientException */ - public function PollNexusTaskQueue(V1\PollNexusTaskQueueRequest $arg, ContextInterface $ctx = null): V1\PollNexusTaskQueueResponse + public function PollNexusTaskQueue(V1\PollNexusTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\PollNexusTaskQueueResponse { return $this->invoke("PollNexusTaskQueue", $arg, $ctx); } @@ -1098,12 +973,9 @@ public function PollNexusTaskQueue(V1\PollNexusTaskQueueRequest $arg, ContextInt * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: We do not expose worker API to HTTP. --) * - * @param V1\RespondNexusTaskCompletedRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RespondNexusTaskCompletedResponse * @throws ServiceClientException */ - public function RespondNexusTaskCompleted(V1\RespondNexusTaskCompletedRequest $arg, ContextInterface $ctx = null): V1\RespondNexusTaskCompletedResponse + public function RespondNexusTaskCompleted(V1\RespondNexusTaskCompletedRequest $arg, ?ContextInterface $ctx = null): V1\RespondNexusTaskCompletedResponse { return $this->invoke("RespondNexusTaskCompleted", $arg, $ctx); } @@ -1114,12 +986,9 @@ public function RespondNexusTaskCompleted(V1\RespondNexusTaskCompletedRequest $a * (-- api-linter: core::0127::http-annotation=disabled * aip.dev/not-precedent: We do not expose worker API to HTTP. --) * - * @param V1\RespondNexusTaskFailedRequest $arg - * @param ContextInterface|null $ctx - * @return V1\RespondNexusTaskFailedResponse * @throws ServiceClientException */ - public function RespondNexusTaskFailed(V1\RespondNexusTaskFailedRequest $arg, ContextInterface $ctx = null): V1\RespondNexusTaskFailedResponse + public function RespondNexusTaskFailed(V1\RespondNexusTaskFailedRequest $arg, ?ContextInterface $ctx = null): V1\RespondNexusTaskFailedResponse { return $this->invoke("RespondNexusTaskFailed", $arg, $ctx); } diff --git a/src/Client/GRPC/ServiceClientInterface.php b/src/Client/GRPC/ServiceClientInterface.php index 2e1956e78..f614931b9 100644 --- a/src/Client/GRPC/ServiceClientInterface.php +++ b/src/Client/GRPC/ServiceClientInterface.php @@ -100,6 +100,25 @@ public function DeprecateNamespace(V1\DeprecateNamespaceRequest $arg, ContextInt * @throws ServiceClientException */ public function StartWorkflowExecution(V1\StartWorkflowExecutionRequest $arg, ContextInterface $ctx = null) : V1\StartWorkflowExecutionResponse; + /** + * ExecuteMultiOperation executes multiple operations within a single workflow. + * + * Operations are started atomically, meaning if *any* operation fails to be + * started, none are, + * and the request fails. Upon start, the API returns only when *all* operations + * have a response. + * + * Upon failure, it returns `MultiOperationExecutionFailure` where the status code + * equals the status code of the *first* operation that failed to be started. + * + * NOTE: Experimental API. + * + * @param V1\ExecuteMultiOperationRequest $arg + * @param ContextInterface|null $ctx + * @return V1\ExecuteMultiOperationResponse + * @throws ServiceClientException + */ + public function ExecuteMultiOperation(V1\ExecuteMultiOperationRequest $arg, ContextInterface $ctx = null) : V1\ExecuteMultiOperationResponse; /** * GetWorkflowExecutionHistory returns the history of specified workflow execution. * Fails with @@ -731,8 +750,40 @@ public function UpdateWorkerBuildIdCompatibility(V1\UpdateWorkerBuildIdCompatibi */ public function GetWorkerBuildIdCompatibility(V1\GetWorkerBuildIdCompatibilityRequest $arg, ContextInterface $ctx = null) : V1\GetWorkerBuildIdCompatibilityResponse; /** - * Allows updating the Build ID assignment and redirect rules for a given Task - * Queue. + * Use this API to manage Worker Versioning Rules for a given Task Queue. There are + * two types of + * rules: Build ID Assignment rules and Compatible Build ID Redirect rules. + * + * Assignment rules determine how to assign new executions to a Build IDs. Their + * primary + * use case is to specify the latest Build ID but they have powerful features for + * gradual rollout + * of a new Build ID. + * + * Once a workflow execution is assigned to a Build ID and it completes its first + * Workflow Task, + * the workflow stays on the assigned Build ID regardless of changes in assignment + * rules. This + * eliminates the need for compatibility between versions when you only care about + * using the new + * version for new workflows and let existing workflows finish in their own + * version. + * + * Activities, Child Workflows and Continue-as-New executions have the option to + * inherit the + * Build ID of their parent/previous workflow or use the latest assignment rules to + * independently + * select a Build ID. + * + * Redirect rules should only be used when you want to move workflows and + * activities assigned to + * one Build ID (source) to another compatible Build ID (target). You are + * responsible to make sure + * the target Build ID of a redirect rule is able to process event histories made + * by the source + * Build ID by using [Patching](https://docs.temporal.io/workflows#patching) or + * other means. + * * WARNING: Worker Versioning is not yet stable and the API and behavior may change * incompatibly. * (-- api-linter: core::0127::http-annotation=disabled diff --git a/src/Client/Schedule/Spec/ScheduleSpec.php b/src/Client/Schedule/Spec/ScheduleSpec.php index d1a688836..5e6c74047 100644 --- a/src/Client/Schedule/Spec/ScheduleSpec.php +++ b/src/Client/Schedule/Spec/ScheduleSpec.php @@ -76,6 +76,8 @@ final class ScheduleSpec * Any timestamps matching any of exclude* will be skipped. * * @var list + * + * @deprecated */ #[MarshalArray(name: 'exclude_calendar', of: CalendarSpec::class)] public readonly array $excludeCalendarList; @@ -245,18 +247,25 @@ public function withAddedInterval(mixed $interval): self /** * Returns a new instance with the replaced exclude calendar list. + * + * @deprecated This method is deprecated and will be removed in the next major release. */ public function withExcludeCalendarList(CalendarSpec ...$calendar): self { + @\trigger_error('ScheduleSpec::withExcludeCalendarList() is deprecated', E_USER_DEPRECATED); + /** @see self::$excludeCalendarList */ return $this->with('excludeCalendarList', $calendar); } /** * Any timestamps matching any of exclude* will be skipped. + * + * @deprecated This method is deprecated and will be removed in the next major release. */ public function withAddedExcludeCalendar(CalendarSpec $calendar): self { + @\trigger_error('ScheduleSpec::withAddedExcludeCalendar() is deprecated', E_USER_DEPRECATED); $value = $this->excludeCalendarList; $value[] = $calendar; diff --git a/src/Client/ScheduleClient.php b/src/Client/ScheduleClient.php index 5348cdab6..aebeb5a31 100644 --- a/src/Client/ScheduleClient.php +++ b/src/Client/ScheduleClient.php @@ -46,15 +46,10 @@ final class ScheduleClient implements ScheduleClientInterface private MarshallerInterface $marshaller; private ProtoToArrayConverter $protoConverter; - /** - * @param ServiceClientInterface $serviceClient - * @param ClientOptions|null $options - * @param DataConverterInterface|null $converter - */ public function __construct( ServiceClientInterface $serviceClient, - ClientOptions $options = null, - DataConverterInterface $converter = null, + ?ClientOptions $options = null, + ?DataConverterInterface $converter = null, ) { $this->client = $serviceClient; $this->clientOptions = $options ?? new ClientOptions(); @@ -67,8 +62,8 @@ public function __construct( public static function create( ServiceClientInterface $serviceClient, - ClientOptions $options = null, - DataConverterInterface $converter = null, + ?ClientOptions $options = null, + ?DataConverterInterface $converter = null, ): ScheduleClientInterface { return new self($serviceClient, $options, $converter); } @@ -149,11 +144,13 @@ public function getHandle(string $scheduleID, ?string $namespace = null): Schedu public function listSchedules( ?string $namespace = null, int $pageSize = 0, + string $query = '', ): Paginator { // Build request $request = (new ListSchedulesRequest()) ->setNamespace($namespace ?? $this->clientOptions->namespace) - ->setMaximumPageSize($pageSize); + ->setMaximumPageSize($pageSize) + ->setQuery($query); $loader = function (ListSchedulesRequest $request): \Generator { do { diff --git a/src/Client/ScheduleClientInterface.php b/src/Client/ScheduleClientInterface.php index 00a999bdc..db7241dff 100644 --- a/src/Client/ScheduleClientInterface.php +++ b/src/Client/ScheduleClientInterface.php @@ -46,8 +46,9 @@ public function getHandle(string $scheduleID, ?string $namespace = null): Schedu * * @param non-empty-string|null $namespace If null, the preconfigured namespace will be used. * @param int<0, max> $pageSize Maximum number of Schedule info per page. + * @param string $query Temporal Visibility Query. {@link https://docs.temporal.io/visibility#list-filter} * * @return Paginator */ - public function listSchedules(?string $namespace = null, int $pageSize = 0): Paginator; + public function listSchedules(?string $namespace = null, int $pageSize = 0, string $query = ''): Paginator; } diff --git a/src/Client/Update/UpdateHandle.php b/src/Client/Update/UpdateHandle.php index 4183e5314..ccf913667 100644 --- a/src/Client/Update/UpdateHandle.php +++ b/src/Client/Update/UpdateHandle.php @@ -57,7 +57,6 @@ public function getId(): string /** * Check there is a cached accepted result or failure for this update request. * - * @return bool */ public function hasResult(): bool { @@ -139,7 +138,6 @@ private function fetchResult(int|float|null $timeout = null): void $failure = $result->getFailure(); \assert($failure !== null); $e = FailureConverter::mapFailureToException($failure, $this->converter); - tr($e); $this->result = new WorkflowUpdateException( $e->getMessage(), diff --git a/src/Client/WorkflowClient.php b/src/Client/WorkflowClient.php index 0065915f6..22097b5e6 100644 --- a/src/Client/WorkflowClient.php +++ b/src/Client/WorkflowClient.php @@ -12,6 +12,7 @@ namespace Temporal\Client; use Doctrine\Common\Annotations\Reader; +use JetBrains\PhpStorm\Deprecated; use Spiral\Attributes\AnnotationReader; use Spiral\Attributes\AttributeReader; use Spiral\Attributes\Composite\SelectiveReader; @@ -24,6 +25,9 @@ use Temporal\Client\Common\ClientContextTrait; use Temporal\Client\Common\Paginator; use Temporal\Client\GRPC\ServiceClientInterface; +use Temporal\Client\Update\LifecycleStage; +use Temporal\Client\Update\UpdateHandle; +use Temporal\Client\Update\UpdateOptions; use Temporal\Client\Workflow\CountWorkflowExecutions; use Temporal\Client\Workflow\WorkflowExecutionHistory; use Temporal\DataConverter\DataConverter; @@ -64,17 +68,11 @@ class WorkflowClient implements WorkflowClientInterface /** @var Pipeline */ private Pipeline $interceptorPipeline; - /** - * @param ServiceClientInterface $serviceClient - * @param ClientOptions|null $options - * @param DataConverterInterface|null $converter - * @param PipelineProvider|null $interceptorProvider - */ public function __construct( ServiceClientInterface $serviceClient, - ClientOptions $options = null, - DataConverterInterface $converter = null, - PipelineProvider $interceptorProvider = null, + ?ClientOptions $options = null, + ?DataConverterInterface $converter = null, + ?PipelineProvider $interceptorProvider = null, ) { $this->client = $serviceClient; $this->interceptorPipeline = ($interceptorProvider ?? new SimplePipelineProvider()) @@ -85,23 +83,17 @@ public function __construct( } /** - * @param ServiceClientInterface $serviceClient - * @param ClientOptions|null $options - * @param DataConverterInterface|null $converter * @return static */ public static function create( ServiceClientInterface $serviceClient, - ClientOptions $options = null, - DataConverterInterface $converter = null, - PipelineProvider $interceptorProvider = null, + ?ClientOptions $options = null, + ?DataConverterInterface $converter = null, + ?PipelineProvider $interceptorProvider = null, ): self { return new self($serviceClient, $options, $converter, $interceptorProvider); } - /** - * @return ServiceClientInterface - */ public function getServiceClient(): ServiceClientInterface { return $this->client; @@ -113,7 +105,6 @@ public function getServiceClient(): ServiceClientInterface * * @param object|WorkflowStubInterface $workflow * @param mixed ...$args - * @return WorkflowRunInterface */ public function start($workflow, ...$args): WorkflowRunInterface { @@ -157,14 +148,7 @@ public function start($workflow, ...$args): WorkflowRunInterface ); } - /** - * @param object|WorkflowStubInterface $workflow - * @param string $signal - * @param array $signalArgs - * @param array $startArgs - * @return WorkflowRunInterface - */ - public function startWithSignal( + public function signalWithStart( $workflow, string $signal, array $signalArgs = [], @@ -222,12 +206,53 @@ public function startWithSignal( ); } - /** - * {@inheritDoc} - */ + #[Deprecated(replacement: '%class%->signalWithStart(%parametersList%)')] + public function startWithSignal( + $workflow, + string $signal, + array $signalArgs = [], + array $startArgs = [], + ): WorkflowRunInterface { + return $this->signalWithStart($workflow, $signal, $signalArgs, $startArgs); + } + + public function updateWithStart( + $workflow, + string|UpdateOptions $update, + array $updateArgs = [], + array $startArgs = [], + ): UpdateHandle { + $workflow instanceof WorkflowProxy && !$workflow->hasHandler() && throw new InvalidArgumentException( + 'Unable to start workflow without workflow handler', + ); + + $update = \is_string($update) ? UpdateOptions::new($update, LifecycleStage::StageAccepted) : $update; + + $workflowStub = WorkflowStubConverter::fromWorkflow($workflow); + + $workflowType = $workflowStub->getWorkflowType() ?? throw new InvalidArgumentException( + 'Unable to start untyped workflow without given workflowType', + ); + $workflowStub->hasExecution() and throw new InvalidArgumentException(self::ERROR_WORKFLOW_START_DUPLICATION); + + [$execution, $handle] = $this->getStarter()->updateWithStart( + $workflowType, + $workflowStub->getOptions() ?? WorkflowOptions::new(), + $update, + $updateArgs, + $startArgs, + ); + + $workflowStub->setExecution($execution); + + return $handle instanceof \Throwable + ? throw $handle + : $handle; + } + public function newWorkflowStub( string $class, - WorkflowOptions $options = null, + ?WorkflowOptions $options = null, ): object { $workflow = $this->reader->fromClass($class); @@ -238,12 +263,9 @@ public function newWorkflowStub( ); } - /** - * {@inheritDoc} - */ public function newUntypedWorkflowStub( string $workflowType, - WorkflowOptions $options = null, + ?WorkflowOptions $options = null, ): WorkflowStubInterface { $options ??= new WorkflowOptions(); @@ -257,9 +279,6 @@ public function newUntypedWorkflowStub( ); } - /** - * {@inheritDoc} - */ public function newRunningWorkflowStub(string $class, string $workflowID, ?string $runID = null): object { $workflow = $this->reader->fromClass($class); @@ -271,9 +290,6 @@ public function newRunningWorkflowStub(string $class, string $workflowID, ?strin ); } - /** - * {@inheritDoc} - */ public function newUntypedRunningWorkflowStub( string $workflowID, ?string $runID = null, @@ -291,17 +307,11 @@ public function newUntypedRunningWorkflowStub( return $untyped; } - /** - * {@inheritDoc} - */ public function newActivityCompletionClient(): ActivityCompletionClientInterface { return new ActivityCompletionClient($this->client, $this->clientOptions, $this->converter); } - /** - * @inheritDoc - */ public function listWorkflowExecutions( string $query, ?string $namespace = null, @@ -338,9 +348,6 @@ public function listWorkflowExecutions( return Paginator::createFromGenerator($loader($request), $counter); } - /** - * @inheritDoc - */ public function countWorkflowExecutions( string $query, ?string $namespace = null, @@ -356,9 +363,6 @@ public function countWorkflowExecutions( ); } - /** - * @inheritDoc - */ public function getWorkflowHistory( WorkflowExecution $execution, ?string $namespace = null, @@ -404,9 +408,6 @@ public function __clone() $this->starter = null; } - /** - * @return ReaderInterface - */ private function createReader(): ReaderInterface { if (\interface_exists(Reader::class)) { diff --git a/src/Client/WorkflowClientInterface.php b/src/Client/WorkflowClientInterface.php index 2a95eae8c..c84665557 100644 --- a/src/Client/WorkflowClientInterface.php +++ b/src/Client/WorkflowClientInterface.php @@ -11,10 +11,13 @@ namespace Temporal\Client; +use JetBrains\PhpStorm\Deprecated; use Temporal\Api\Enums\V1\HistoryEventFilterType; use Temporal\Client\Common\ClientContextInterface; use Temporal\Client\Common\Paginator; use Temporal\Client\GRPC\ServiceClientInterface; +use Temporal\Client\Update\UpdateHandle; +use Temporal\Client\Update\UpdateOptions; use Temporal\Client\Workflow\CountWorkflowExecutions; use Temporal\Client\Workflow\WorkflowExecutionHistory; use Temporal\Workflow\WorkflowExecution; @@ -23,9 +26,6 @@ interface WorkflowClientInterface extends ClientContextInterface { - /** - * @return ServiceClientInterface - */ public function getServiceClient(): ServiceClientInterface; /** @@ -33,7 +33,6 @@ public function getServiceClient(): ServiceClientInterface; * * @param WorkflowStubInterface|object $workflow * @param mixed $args - * @return WorkflowRunInterface */ public function start($workflow, ...$args): WorkflowRunInterface; @@ -41,11 +40,21 @@ public function start($workflow, ...$args): WorkflowRunInterface; * Starts untyped and typed workflow stubs in async mode. Sends signal on start. * * @param object|WorkflowStubInterface $workflow - * @param string $signal - * @param array $signalArgs - * @param array $startArgs - * @return WorkflowRunInterface + * @param non-empty-string $signal + * + * @since 2.12.0 + */ + public function signalWithStart( + $workflow, + string $signal, + array $signalArgs = [], + array $startArgs = [], + ): WorkflowRunInterface; + + /** + * @deprecated Use {@see self::signalWithStart()} instead. */ + #[Deprecated(replacement: '%class%->signalWithStart(%parametersList%)')] public function startWithSignal( $workflow, string $signal, @@ -53,6 +62,26 @@ public function startWithSignal( array $startArgs = [], ): WorkflowRunInterface; + /** + * Starts untyped and typed workflow stubs in async mode. Sends Update on start. + * + * @param object|WorkflowStubInterface $workflow + * @param non-empty-string|UpdateOptions $update Name of the update handler or update options. + * @param array $updateArgs + * @param array $startArgs + * + * @return UpdateHandle + * + * @note Experimental feature. + * @since 2.12.0 + */ + public function updateWithStart( + $workflow, + string|UpdateOptions $update, + array $updateArgs = [], + array $startArgs = [], + ): UpdateHandle; + /** * Creates workflow client stub that can be used to start a single workflow execution. * @@ -66,12 +95,11 @@ public function startWithSignal( * * @psalm-template T of object * @param class-string $class - * @param WorkflowOptions|null $options * @return T */ public function newWorkflowStub( string $class, - WorkflowOptions $options = null, + ?WorkflowOptions $options = null, ): object; /** @@ -84,13 +112,10 @@ public function newWorkflowStub( * IMPORTANT! Stub is per workflow instance. So new stub should be created * for each new one. * - * @param string $workflowType - * @param WorkflowOptions|null $options - * @return WorkflowStubInterface */ public function newUntypedWorkflowStub( string $workflowType, - WorkflowOptions $options = null, + ?WorkflowOptions $options = null, ): WorkflowStubInterface; /** @@ -98,8 +123,6 @@ public function newUntypedWorkflowStub( * * @psalm-template T of object * @param class-string $class - * @param string $workflowID - * @param string|null $runID * @return T */ public function newRunningWorkflowStub( @@ -111,10 +134,6 @@ public function newRunningWorkflowStub( /** * Returns untyped workflow stub associated with running workflow. * - * @param string $workflowID - * @param string|null $runID - * @param string|null $workflowType - * @return WorkflowStubInterface */ public function newUntypedRunningWorkflowStub( string $workflowID, @@ -130,7 +149,6 @@ public function newUntypedRunningWorkflowStub( * * @see ActivityCompletionClient * - * @return ActivityCompletionClientInterface */ public function newActivityCompletionClient(): ActivityCompletionClientInterface; @@ -177,18 +195,15 @@ public function countWorkflowExecutions( ): CountWorkflowExecutions; /** - * @param WorkflowExecution $execution * @param non-empty-string|null $namespace If null, the preconfigured namespace will be used. * @param bool $waitNewEvent If set to true, the RPC call will not resolve until there is a new event which matches, * the $historyEventFilterType, or a timeout is hit. The RPC call will be resolved immediately if the * workflow was already finished. * @param int<0, 2>| $historyEventFilterType Filter returned events such that they match the specified filter type. * Available values are {@see HistoryEventFilterType} constants. - * @param bool $skipArchival * @param int<0, max> $pageSize Size of the pages to be requested. It affects internal queries only. Use it if you * want to load limited number of events from the history. * - * @return WorkflowExecutionHistory */ public function getWorkflowHistory( WorkflowExecution $execution, diff --git a/src/Client/WorkflowOptions.php b/src/Client/WorkflowOptions.php index 9716c1f07..dc576d770 100644 --- a/src/Client/WorkflowOptions.php +++ b/src/Client/WorkflowOptions.php @@ -163,12 +163,9 @@ public function __construct() } /** - * @param MethodRetry|null $retry - * @param CronSchedule|null $cron - * * @return self return a new {@see self} instance with merged options */ - public function mergeWith(MethodRetry $retry = null, CronSchedule $cron = null): self + public function mergeWith(?MethodRetry $retry = null, ?CronSchedule $cron = null): self { $self = clone $this; @@ -189,7 +186,6 @@ public function mergeWith(MethodRetry $retry = null, CronSchedule $cron = null): * deduplication will happen based on the generated id. So prefer assigning * business meaningful ids if possible. * - * @param string $workflowId * @return $this */ #[Pure] @@ -207,7 +203,6 @@ public function withWorkflowId(string $workflowId): self * specified when creating a {@see Worker} that hosts the * workflow code. * - * @param string $taskQueue * @return $this */ #[Pure] @@ -227,7 +222,6 @@ public function withTaskQueue(string $taskQueue): self * Eager Workflow Dispatch can be enabled if the server supports it and a local worker * is available the task is fed directly to the worker. * - * @param bool $value * @return $this */ #[Pure] @@ -375,7 +369,6 @@ public function withWorkflowIdConflictPolicy(WorkflowIdConflictPolicy $policy): * RetryOptions that define how child workflow is retried in case of * failure. Default is null which is no reties. * - * @param RetryOptions|null $options * @return $this */ #[Pure] @@ -389,7 +382,6 @@ public function withRetryOptions(?RetryOptions $options): self } /** - * @param string|null $expression * @return $this */ #[Pure] @@ -405,7 +397,6 @@ public function withCronSchedule(?string $expression): self /** * Specifies additional non-indexed information in result of list workflow. * - * @param array|null $memo * @return $this */ #[Pure] @@ -421,7 +412,6 @@ public function withMemo(?array $memo): self /** * Specifies additional indexed information in result of list workflow. * - * @param array|null $searchAttributes * @return $this */ #[Pure] @@ -435,8 +425,6 @@ public function withSearchAttributes(?array $searchAttributes): self } /** - * @param DataConverterInterface $converter - * @return Memo|null * @internal */ public function toMemo(DataConverterInterface $converter): ?Memo @@ -458,8 +446,6 @@ public function toMemo(DataConverterInterface $converter): ?Memo } /** - * @param DataConverterInterface $converter - * @return SearchAttributes|null * @internal */ public function toSearchAttributes(DataConverterInterface $converter): ?SearchAttributes diff --git a/src/Client/WorkflowStubInterface.php b/src/Client/WorkflowStubInterface.php index b939b1eda..618f4feef 100644 --- a/src/Client/WorkflowStubInterface.php +++ b/src/Client/WorkflowStubInterface.php @@ -33,7 +33,7 @@ interface WorkflowStubInterface extends WorkflowRunInterface { /** - * @return string|null + * @return non-empty-string|null */ public function getWorkflowType(): ?string; @@ -41,7 +41,6 @@ public function getWorkflowType(): ?string; * Returns associated workflow options. Empty for running workflows. Workflow options are immutable and can * not be changed after the workflow was created. * - * @return WorkflowOptions|null */ public function getOptions(): ?WorkflowOptions; @@ -55,21 +54,18 @@ public function getExecution(): WorkflowExecution; /** * Check if workflow was started and has associated execution. * - * @return bool */ public function hasExecution(): bool; /** * Attaches running workflow context to the workflow stub. * - * @param WorkflowExecution $execution */ public function setExecution(WorkflowExecution $execution): void; /** * Sends named signal to the workflow execution. * - * @param string $name * @param mixed ...$args */ public function signal(string $name, ...$args): void; @@ -79,9 +75,7 @@ public function signal(string $name, ...$args): void; * * Usually a query handler is a method annotated with {@see QueryMethod}. * - * @param string $name * @param mixed ...$args - * @return ValuesInterface|null */ public function query(string $name, ...$args): ?ValuesInterface; @@ -92,7 +86,6 @@ public function query(string $name, ...$args): ?ValuesInterface; * * @param non-empty-string $name Name of the update handler. * @param mixed ...$args Arguments to pass to the update handler. - * @return ValuesInterface|null * @throws WorkflowUpdateException * @throws WorkflowUpdateRPCTimeoutOrCanceledException */ @@ -130,7 +123,6 @@ public function getUpdateHandle(string $updateId, mixed $resultType = null): Upd * main workflow method. Note that workflow can take long time to get * canceled or even completely ignore the cancellation request. * - * @return void */ public function cancel(): void; @@ -140,9 +132,6 @@ public function cancel(): void; * Termination is a hard stop of a workflow execution which doesn't give * workflow code any chance to perform cleanup. * - * @param string $reason - * @param array $details - * @return void */ public function terminate(string $reason, array $details = []): void; } diff --git a/src/Common/CronSchedule.php b/src/Common/CronSchedule.php index 956930a59..abc9141ef 100644 --- a/src/Common/CronSchedule.php +++ b/src/Common/CronSchedule.php @@ -50,22 +50,15 @@ final class CronSchedule implements \Stringable * * * * * * * ``` * - * @var string */ #[Immutable] public string $interval; - /** - * @param string $interval - */ public function __construct(string $interval) { $this->interval = $interval; } - /** - * {@inheritDoc} - */ public function __toString(): string { return (string) $this->interval; diff --git a/src/Common/MethodRetry.php b/src/Common/MethodRetry.php index 658b454dd..d488b1234 100644 --- a/src/Common/MethodRetry.php +++ b/src/Common/MethodRetry.php @@ -37,7 +37,6 @@ final class MethodRetry extends RetryOptions * @param DateIntervalValue|null $initialInterval * @param DateIntervalValue|null $maximumInterval * @param int<0, max> $maximumAttempts - * @param float $backoffCoefficient * @param ExceptionsList $nonRetryableExceptions */ public function __construct( diff --git a/src/Common/RetryOptions.php b/src/Common/RetryOptions.php index 1a4b65269..9a9c5baed 100644 --- a/src/Common/RetryOptions.php +++ b/src/Common/RetryOptions.php @@ -106,11 +106,7 @@ class RetryOptions extends Options #[Marshal(name: 'non_retryable_error_types')] public array $nonRetryableExceptions = self::DEFAULT_NON_RETRYABLE_EXCEPTIONS; - /** - * @param MethodRetry|null $retry - * @return self - */ - public function mergeWith(MethodRetry $retry = null): self + public function mergeWith(?MethodRetry $retry = null): self { $self = clone $this; @@ -142,7 +138,6 @@ public function withInitialInterval($interval): self /** * @psalm-suppress ImpureMethodCall * - * @param float $coefficient * @return static */ #[Pure] @@ -207,7 +202,6 @@ public function withNonRetryableExceptions(array $exceptions): self /** * Converts DTO to protobuf object * - * @return RetryPolicy * @psalm-suppress ImpureMethodCall */ public function toWorkflowRetryPolicy(): RetryPolicy diff --git a/src/Common/Uuid.php b/src/Common/Uuid.php index 17f7612da..d8230f91f 100644 --- a/src/Common/Uuid.php +++ b/src/Common/Uuid.php @@ -25,9 +25,6 @@ final class Uuid */ public const NIL = '00000000-0000-0000-0000-000000000000'; - /** - * @return string - */ public static function nil(): string { return self::NIL; @@ -56,7 +53,6 @@ public static function v4(): string } /** - * @return string * @throws \Exception */ private static function bytes(): string @@ -81,9 +77,6 @@ private static function bytes(): string * @see http://tools.ietf.org/html/rfc4122#section-4.1.3 * * @psalm-pure - * @param int $timeHi - * @param int $version - * @return int */ private static function version(int $timeHi, int $version): int { @@ -96,8 +89,6 @@ private static function version(int $timeHi, int $version): int * @see http://tools.ietf.org/html/rfc4122#section-4.1.1 * * @psalm-pure - * @param int $clockSeq - * @return int */ private static function variant(int $clockSeq): int { diff --git a/src/DataConverter/BinaryConverter.php b/src/DataConverter/BinaryConverter.php index 03c8658b9..dd708d040 100644 --- a/src/DataConverter/BinaryConverter.php +++ b/src/DataConverter/BinaryConverter.php @@ -16,9 +16,6 @@ class BinaryConverter extends Converter { - /** - * @return string - */ public function getEncodingType(): string { return EncodingKeys::METADATA_ENCODING_RAW; @@ -26,7 +23,6 @@ public function getEncodingType(): string /** * @param mixed $value - * @return Payload|null */ public function toPayload($value): ?Payload { @@ -38,8 +34,6 @@ public function toPayload($value): ?Payload } /** - * @param Payload $payload - * @param Type $type * @return Bytes */ public function fromPayload(Payload $payload, Type $type) diff --git a/src/DataConverter/Bytes.php b/src/DataConverter/Bytes.php index fa8b86006..462225851 100644 --- a/src/DataConverter/Bytes.php +++ b/src/DataConverter/Bytes.php @@ -13,30 +13,18 @@ final class Bytes implements \Stringable { - /** - * @var string - */ private string $data; - /** - * @param string $data - */ public function __construct(string $data) { $this->data = $data; } - /** - * @return int - */ public function getSize(): int { return \strlen($this->data); } - /** - * @return string - */ public function getData(): string { return $this->data; diff --git a/src/DataConverter/Converter.php b/src/DataConverter/Converter.php index f6aa05d44..abb6dd2fd 100644 --- a/src/DataConverter/Converter.php +++ b/src/DataConverter/Converter.php @@ -15,10 +15,6 @@ abstract class Converter implements PayloadConverterInterface { - /** - * @param string $data - * @return Payload - */ protected function create(string $data): Payload { $payload = new Payload(); diff --git a/src/DataConverter/DataConverter.php b/src/DataConverter/DataConverter.php index 6ba436aaa..d3ea48b55 100644 --- a/src/DataConverter/DataConverter.php +++ b/src/DataConverter/DataConverter.php @@ -21,9 +21,6 @@ final class DataConverter implements DataConverterInterface */ private array $converters = []; - /** - * @param PayloadConverterInterface ...$converter - */ public function __construct(PayloadConverterInterface ...$converter) { foreach ($converter as $c) { @@ -31,9 +28,6 @@ public function __construct(PayloadConverterInterface ...$converter) } } - /** - * @return DataConverterInterface - */ public static function createDefault(): DataConverterInterface { return new DataConverter( @@ -45,9 +39,6 @@ public static function createDefault(): DataConverterInterface ); } - /** - * {@inheritDoc} - */ public function fromPayload(Payload $payload, $type) { /** @var \ArrayAccess $meta */ @@ -73,7 +64,6 @@ public function fromPayload(Payload $payload, $type) /** * @param mixed $value - * @return Payload * * @throws DataConverterException */ diff --git a/src/DataConverter/DataConverterInterface.php b/src/DataConverter/DataConverterInterface.php index b20806481..0033d0f98 100644 --- a/src/DataConverter/DataConverterInterface.php +++ b/src/DataConverter/DataConverterInterface.php @@ -17,7 +17,6 @@ interface DataConverterInterface { /** - * @param Payload $payload * @param string|\ReflectionClass|\ReflectionType|Type|null $type * @return mixed * @@ -28,7 +27,6 @@ public function fromPayload(Payload $payload, $type); /** * @param mixed $value - * @return Payload * * @throws DataConverterException */ diff --git a/src/DataConverter/EncodedCollection.php b/src/DataConverter/EncodedCollection.php index b245ffd4f..75ef277dd 100644 --- a/src/DataConverter/EncodedCollection.php +++ b/src/DataConverter/EncodedCollection.php @@ -24,9 +24,6 @@ */ class EncodedCollection implements \IteratorAggregate, \Countable { - /** - * @var DataConverterInterface|null - */ private ?DataConverterInterface $converter = null; /** diff --git a/src/DataConverter/EncodedValues.php b/src/DataConverter/EncodedValues.php index f11662189..bb0ed99f9 100644 --- a/src/DataConverter/EncodedValues.php +++ b/src/DataConverter/EncodedValues.php @@ -38,9 +38,6 @@ class EncodedValues implements ValuesInterface */ protected ?array $values = null; - /** - * @var DataConverterInterface|null - */ private ?DataConverterInterface $converter = null; /** @@ -48,9 +45,6 @@ class EncodedValues implements ValuesInterface */ private function __construct() {} - /** - * @return static - */ public static function empty(): static { $ev = new static(); @@ -59,30 +53,16 @@ public static function empty(): static return $ev; } - /** - * @param Payloads $payloads - * @param DataConverterInterface $dataConverter - * - * @return EncodedValues - */ public static function fromPayloads(Payloads $payloads, DataConverterInterface $dataConverter): EncodedValues { return static::fromPayloadCollection($payloads->getPayloads(), $dataConverter); } - /** - * @param DataConverterInterface $converter - * @param ValuesInterface $values - * @param int $offset - * @param int|null $length - * - * @return ValuesInterface - */ public static function sliceValues( DataConverterInterface $converter, ValuesInterface $values, int $offset, - int $length = null, + ?int $length = null, ): ValuesInterface { $payloads = $values->toPayloads(); $newPayloads = new Payloads(); @@ -94,10 +74,8 @@ public static function sliceValues( /** * Decode promise response upon returning it to the domain layer. * - * @param PromiseInterface $promise * @param string|\ReflectionClass|\ReflectionType|Type|null $type * - * @return PromiseInterface */ public static function decodePromise(PromiseInterface $promise, $type = null): PromiseInterface { @@ -112,13 +90,7 @@ static function (mixed $value) use ($type) { ); } - /** - * @param array $values - * @param DataConverterInterface|null $dataConverter - * - * @return static - */ - public static function fromValues(array $values, DataConverterInterface $dataConverter = null): static + public static function fromValues(array $values, ?DataConverterInterface $dataConverter = null): static { $ev = new static(); $ev->values = \array_values($values); @@ -129,9 +101,7 @@ public static function fromValues(array $values, DataConverterInterface $dataCon /** * @param TPayloadsCollection $payloads - * @param ?DataConverterInterface $dataConverter * - * @return static */ public static function fromPayloadCollection( \Traversable $payloads, @@ -189,9 +159,6 @@ public function getValues(): array return $result; } - /** - * @param DataConverterInterface $converter - */ public function setDataConverter(DataConverterInterface $converter): void { $this->converter = $converter; diff --git a/src/DataConverter/JsonConverter.php b/src/DataConverter/JsonConverter.php index dbff0ca30..8f422e4de 100644 --- a/src/DataConverter/JsonConverter.php +++ b/src/DataConverter/JsonConverter.php @@ -34,22 +34,13 @@ class JsonConverter extends Converter */ public const JSON_FLAGS = \JSON_THROW_ON_ERROR | \JSON_PRESERVE_ZERO_FRACTION; - /** - * @var MarshallerInterface - */ private MarshallerInterface $marshaller; - /** - * @param MarshallerInterface|null $marshaller - */ - public function __construct(MarshallerInterface $marshaller = null) + public function __construct(?MarshallerInterface $marshaller = null) { $this->marshaller = $marshaller ?? self::createDefaultMarshaller(); } - /** - * @return string - */ public function getEncodingType(): string { return EncodingKeys::METADATA_ENCODING_JSON; @@ -57,7 +48,6 @@ public function getEncodingType(): string /** * @param mixed $value - * @return Payload|null * @throws DataConverterException */ public function toPayload($value): ?Payload @@ -78,8 +68,6 @@ public function toPayload($value): ?Payload } /** - * @param Payload $payload - * @param Type $type * @return mixed|void * @throws DataConverterException */ @@ -178,17 +166,11 @@ public function fromPayload(Payload $payload, Type $type) throw $this->errorInvalidTypeName($type); } - /** - * @return MarshallerInterface - */ private static function createDefaultMarshaller(): MarshallerInterface { return new Marshaller(new AttributeMapperFactory(self::createDefaultReader())); } - /** - * @return ReaderInterface - */ private static function createDefaultReader(): ReaderInterface { if (\interface_exists(Reader::class)) { @@ -200,7 +182,6 @@ private static function createDefaultReader(): ReaderInterface /** * @param object|array $context - * @return array */ private function toHashMap($context): array { @@ -217,10 +198,6 @@ private function toHashMap($context): array return $context; } - /** - * @param Type $type - * @return DataConverterException - */ private function errorInvalidTypeName(Type $type): DataConverterException { $message = \vsprintf('Type named "%s" is not a valid type name', [ @@ -231,9 +208,7 @@ private function errorInvalidTypeName(Type $type): DataConverterException } /** - * @param Type $type * @param mixed $data - * @return DataConverterException */ private function errorInvalidType(Type $type, $data): DataConverterException { @@ -248,7 +223,6 @@ private function errorInvalidType(Type $type, $data): DataConverterException /** * @template T of object * - * @param object|array $data * @param \ReflectionClass $reflection * * @return T diff --git a/src/DataConverter/NullConverter.php b/src/DataConverter/NullConverter.php index de2afb435..588a5fe89 100644 --- a/src/DataConverter/NullConverter.php +++ b/src/DataConverter/NullConverter.php @@ -16,9 +16,6 @@ class NullConverter extends Converter { - /** - * @return string - */ public function getEncodingType(): string { return EncodingKeys::METADATA_ENCODING_NULL; @@ -26,7 +23,6 @@ public function getEncodingType(): string /** * @param mixed $value - * @return Payload|null */ public function toPayload($value): ?Payload { @@ -38,8 +34,6 @@ public function toPayload($value): ?Payload } /** - * @param Payload $payload - * @param Type $type * @return null */ public function fromPayload(Payload $payload, Type $type) diff --git a/src/DataConverter/PayloadConverterInterface.php b/src/DataConverter/PayloadConverterInterface.php index e28629737..464683f52 100644 --- a/src/DataConverter/PayloadConverterInterface.php +++ b/src/DataConverter/PayloadConverterInterface.php @@ -19,7 +19,6 @@ interface PayloadConverterInterface /** * Returns associated encoding type. * - * @return string */ public function getEncodingType(): string; @@ -27,15 +26,12 @@ public function getEncodingType(): string; * Implements conversion of a single value to Payload. Must return null if value can't be encoded. * * @param mixed $value - * @return Payload|null * * @throws DataConverterException */ public function toPayload($value): ?Payload; /** - * @param Payload $payload - * @param Type $type * @return mixed * * @throws DataConverterException diff --git a/src/DataConverter/ProtoConverter.php b/src/DataConverter/ProtoConverter.php index 27720d73e..a29276505 100644 --- a/src/DataConverter/ProtoConverter.php +++ b/src/DataConverter/ProtoConverter.php @@ -17,9 +17,6 @@ class ProtoConverter extends Converter { - /** - * @return string - */ public function getEncodingType(): string { return EncodingKeys::METADATA_ENCODING_PROTOBUF; @@ -27,7 +24,6 @@ public function getEncodingType(): string /** * @param mixed $value - * @return Payload|null */ public function toPayload($value): ?Payload { @@ -48,8 +44,6 @@ public function toPayload($value): ?Payload } /** - * @param Payload $payload - * @param Type $type * @return Message * @throws DataConverterException */ diff --git a/src/DataConverter/ProtoJsonConverter.php b/src/DataConverter/ProtoJsonConverter.php index 4474a0f8d..34daf6599 100644 --- a/src/DataConverter/ProtoJsonConverter.php +++ b/src/DataConverter/ProtoJsonConverter.php @@ -17,9 +17,6 @@ class ProtoJsonConverter extends Converter { - /** - * @return string - */ public function getEncodingType(): string { return EncodingKeys::METADATA_ENCODING_PROTOBUF_JSON; @@ -27,7 +24,6 @@ public function getEncodingType(): string /** * @param mixed $value - * @return Payload|null */ public function toPayload($value): ?Payload { @@ -48,8 +44,6 @@ public function toPayload($value): ?Payload } /** - * @param Payload $payload - * @param Type $type * @return Message * @throws DataConverterException */ diff --git a/src/DataConverter/Type.php b/src/DataConverter/Type.php index fa20e3e0e..70af788ee 100644 --- a/src/DataConverter/Type.php +++ b/src/DataConverter/Type.php @@ -30,19 +30,14 @@ final class Type public const TYPE_TRUE = 'true'; public const TYPE_FALSE = 'false'; - /** - * @var bool - */ private readonly bool $allowsNull; /** * @param TypeEnum|string $name - * @param bool|null $allowsNull - * @param bool $isArrayOf */ public function __construct( private readonly string $name = Type::TYPE_ANY, - bool $allowsNull = null, + ?bool $allowsNull = null, private readonly bool $isArrayOf = false, ) { $this->allowsNull = $allowsNull ?? ( @@ -55,20 +50,11 @@ public static function arrayOf(string $class): self return new self($class, null, true); } - /** - * @param \ReflectionClass $class - * @param bool $nullable - * @return Type - */ public static function fromReflectionClass(\ReflectionClass $class, bool $nullable = false): self { return new self($class->getName(), $nullable); } - /** - * @param \ReflectionType $type - * @return Type - */ public static function fromReflectionType(\ReflectionType $type): self { if ($type instanceof \ReflectionNamedType) { @@ -90,7 +76,6 @@ public static function fromReflectionType(\ReflectionType $type): self /** * @param string|\ReflectionClass|\ReflectionType|Type|ReturnType $type - * @return Type */ public static function create($type): Type { @@ -115,33 +100,21 @@ public static function create($type): Type } } - /** - * @return string - */ public function getName(): string { return $this->name; } - /** - * @return bool - */ public function allowsNull(): bool { return $this->allowsNull; } - /** - * @return bool - */ public function isUntyped(): bool { return $this->name === self::TYPE_ANY; } - /** - * @return bool - */ public function isClass(): bool { return \class_exists($this->name); diff --git a/src/DataConverter/ValuesInterface.php b/src/DataConverter/ValuesInterface.php index e08f9e1cc..27ddea517 100644 --- a/src/DataConverter/ValuesInterface.php +++ b/src/DataConverter/ValuesInterface.php @@ -23,13 +23,9 @@ interface ValuesInterface extends \Countable /** * Checks if any value present. * - * @return bool */ public function isEmpty(): bool; - /** - * @param DataConverterInterface $converter - */ public function setDataConverter(DataConverterInterface $converter); /** @@ -38,7 +34,6 @@ public function setDataConverter(DataConverterInterface $converter); * Returns {@see null} if there are no values and $type has null value * like {@see null}, {@see Type::TYPE_VOID} or {@see Type::TYPE_NULL}. * - * @param int $index * @param string|\ReflectionClass|\ReflectionType|Type|null $type * @return mixed */ @@ -47,7 +42,6 @@ public function getValue(int $index, $type); /** * Returns associated payloads. * - * @return Payloads */ public function toPayloads(): Payloads; } diff --git a/src/Exception/Client/ActivityCompletionException.php b/src/Exception/Client/ActivityCompletionException.php index 83858559e..daeed894c 100644 --- a/src/Exception/Client/ActivityCompletionException.php +++ b/src/Exception/Client/ActivityCompletionException.php @@ -22,7 +22,6 @@ class ActivityCompletionException extends TemporalException private ?string $activityId = null; /** - * @param \Throwable $e * @return static */ public static function fromPrevious(\Throwable $e): self @@ -35,8 +34,6 @@ public static function fromPrevious(\Throwable $e): self } /** - * @param string $activityId - * @param \Throwable $e * @return static */ public static function fromPreviousWithActivityId(string $activityId, \Throwable $e): self @@ -48,11 +45,9 @@ public static function fromPreviousWithActivityId(string $activityId, \Throwable } /** - * @param ActivityInfo $info - * @param \Throwable|null $e * @return static */ - public static function fromActivityInfo(ActivityInfo $info, \Throwable $e = null): self + public static function fromActivityInfo(ActivityInfo $info, ?\Throwable $e = null): self { $e = new static( self::buildMessage( @@ -75,33 +70,21 @@ public static function fromActivityInfo(ActivityInfo $info, \Throwable $e = null return $e; } - /** - * @return string|null - */ public function getWorkflowId(): ?string { return $this->workflowId; } - /** - * @return string|null - */ public function getRunId(): ?string { return $this->runId; } - /** - * @return string|null - */ public function getActivityType(): ?string { return $this->activityType; } - /** - * @return string|null - */ public function getActivityId(): ?string { return $this->activityId; diff --git a/src/Exception/Client/MultyOperation/OperationStatus.php b/src/Exception/Client/MultyOperation/OperationStatus.php new file mode 100644 index 000000000..a87533a15 --- /dev/null +++ b/src/Exception/Client/MultyOperation/OperationStatus.php @@ -0,0 +1,44 @@ +&RepeatedField $details + */ + private function __construct( + private readonly \Traversable $details, + private readonly string $message, + ) {} + + public static function fromMessage(OperationStatusMessage $message): self + { + return new self($message->getDetails(), $message->getMessage()); + } + + public function getMessage(): string + { + return $this->message; + } + + /** + * @return \ArrayAccess&RepeatedField + */ + private function getDetails(): \Traversable + { + return $this->details; + } +} diff --git a/src/Exception/Client/ServiceClientException.php b/src/Exception/Client/ServiceClientException.php index cca9679ab..fbd2df4f3 100644 --- a/src/Exception/Client/ServiceClientException.php +++ b/src/Exception/Client/ServiceClientException.php @@ -14,21 +14,17 @@ use Google\Protobuf\Any; use Google\Protobuf\Internal\RepeatedField; use Google\Rpc\Status; -use GPBMetadata\Temporal\Api\Errordetails\V1\Message; class ServiceClientException extends \RuntimeException { - /** - * @var Status - */ + use UnpackDetailsTrait; + private Status $status; /** - * @param \stdClass $status - * @param \Throwable|null $previous * @throws \Exception */ - public function __construct(\stdClass $status, \Throwable $previous = null) + public function __construct(\stdClass $status, ?\Throwable $previous = null) { $this->status = new Status(); @@ -36,49 +32,23 @@ public function __construct(\stdClass $status, \Throwable $previous = null) $this->status->mergeFromString($status->metadata['grpc-status-details-bin'][0]); } - parent::__construct($status->details . " (code: $status->code)", $status->code, $previous); + parent::__construct(\sprintf( + "%s (code: %d)", + isset($status->details) ? (string) $status->details : '', + $status->code, + ), $status->code, $previous); } - /** - * @return Status - */ public function getStatus(): Status { return $this->status; } /** - * @return RepeatedField + * @return \ArrayAccess&RepeatedField */ public function getDetails(): RepeatedField { return $this->status->getDetails(); } - - /** - * @link https://dev.to/khepin/grpc-advanced-error-handling-from-go-to-php-1omc - * - * @param string $class - * @return object|null - * @throws \Exception - */ - public function getFailure(string $class): ?object - { - $details = $this->getDetails(); - if ($details->count() === 0) { - return null; - } - - // ensures that message descriptor was added to the pool - Message::initOnce(); - - /** @var Any $detail */ - foreach ($details as $detail) { - if ($detail->is($class)) { - return $detail->unpack(); - } - } - - return null; - } } diff --git a/src/Exception/Client/UnpackDetailsTrait.php b/src/Exception/Client/UnpackDetailsTrait.php new file mode 100644 index 000000000..783400f79 --- /dev/null +++ b/src/Exception/Client/UnpackDetailsTrait.php @@ -0,0 +1,48 @@ + $class + * @return T|null + * @throws \Exception + */ + public function getFailure(string $class): ?object + { + $details = $this->getDetails(); + if ($details->count() === 0) { + return null; + } + + // ensures that message descriptor was added to the pool + Message::initOnce(); + + /** @var Any $detail */ + foreach ($details as $detail) { + if ($detail->is($class)) { + return $detail->unpack(); + } + } + + return null; + } + + /** + * @return \ArrayAccess&RepeatedField + */ + abstract private function getDetails(): iterable; +} diff --git a/src/Exception/Client/WorkflowException.php b/src/Exception/Client/WorkflowException.php index dfb72d8b9..9b6bb869c 100644 --- a/src/Exception/Client/WorkflowException.php +++ b/src/Exception/Client/WorkflowException.php @@ -16,27 +16,14 @@ class WorkflowException extends TemporalException { - /** - * @var WorkflowExecution - */ private WorkflowExecution $execution; - - /** - * @var string|null - */ private ?string $type; - /** - * @param string|null $message - * @param WorkflowExecution $execution - * @param string|null $workflowType - * @param \Throwable|null $previous - */ public function __construct( ?string $message, WorkflowExecution $execution, - string $workflowType = null, - \Throwable $previous = null, + ?string $workflowType = null, + ?\Throwable $previous = null, ) { parent::__construct( self::buildMessage( @@ -53,31 +40,19 @@ public function __construct( $this->type = $workflowType; } - /** - * @param WorkflowExecution $execution - * @param string|null $workflowType - * @param \Throwable|null $previous - * @return WorkflowException - */ public static function withoutMessage( WorkflowExecution $execution, - string $workflowType = null, - \Throwable $previous = null, + ?string $workflowType = null, + ?\Throwable $previous = null, ): WorkflowException { return new static(null, $execution, $workflowType, $previous); } - /** - * @return WorkflowExecution - */ public function getExecution(): WorkflowExecution { return $this->execution; } - /** - * @return string|null - */ public function getWorkflowType(): ?string { return $this->type; diff --git a/src/Exception/Client/WorkflowExecutionAlreadyStartedException.php b/src/Exception/Client/WorkflowExecutionAlreadyStartedException.php index f6d6b976b..28c31e801 100644 --- a/src/Exception/Client/WorkflowExecutionAlreadyStartedException.php +++ b/src/Exception/Client/WorkflowExecutionAlreadyStartedException.php @@ -15,15 +15,10 @@ class WorkflowExecutionAlreadyStartedException extends WorkflowException { - /** - * @param WorkflowExecution $execution - * @param string|null $type - * @param \Throwable|null $previous - */ public function __construct( WorkflowExecution $execution, - string $type = null, - \Throwable $previous = null, + ?string $type = null, + ?\Throwable $previous = null, ) { parent::__construct(null, $execution, $type, $previous); } diff --git a/src/Exception/Client/WorkflowFailedException.php b/src/Exception/Client/WorkflowFailedException.php index 99595b1e5..1307131d5 100644 --- a/src/Exception/Client/WorkflowFailedException.php +++ b/src/Exception/Client/WorkflowFailedException.php @@ -18,18 +18,14 @@ class WorkflowFailedException extends WorkflowException private int $lastWorkflowTaskCompletedEventId; /** - * @param WorkflowExecution $execution * @param non-empty-string|null $type - * @param int $lastWorkflowTaskCompletedEventId - * @param int $retryState - * @param \Throwable|null $previous */ public function __construct( WorkflowExecution $execution, ?string $type, int $lastWorkflowTaskCompletedEventId, int $retryState, - \Throwable $previous = null, + ?\Throwable $previous = null, ) { parent::__construct(null, $execution, $type, $previous); @@ -46,9 +42,6 @@ public function __construct( $this->lastWorkflowTaskCompletedEventId = $lastWorkflowTaskCompletedEventId; } - /** - * @return int - */ public function getWorkflowTaskCompletedEventId(): int { return $this->lastWorkflowTaskCompletedEventId; diff --git a/src/Exception/Client/WorkflowQueryRejectedException.php b/src/Exception/Client/WorkflowQueryRejectedException.php index 0adc6474e..538644e13 100644 --- a/src/Exception/Client/WorkflowQueryRejectedException.php +++ b/src/Exception/Client/WorkflowQueryRejectedException.php @@ -15,43 +15,26 @@ class WorkflowQueryRejectedException extends WorkflowQueryException { - /** - * @var int - */ private int $queryRejectCondition; - private int $workflowExecutionStatus; - /** - * @param WorkflowExecution $execution - * @param string $type - * @param int $queryRejectCondition - * @param int $workflowExecutionStatus - * @param \Throwable|null $previous - */ public function __construct( WorkflowExecution $execution, string $type, int $queryRejectCondition, int $workflowExecutionStatus, - \Throwable $previous = null, + ?\Throwable $previous = null, ) { parent::__construct(null, $execution, $type, $previous); $this->queryRejectCondition = $queryRejectCondition; $this->workflowExecutionStatus = $workflowExecutionStatus; } - /** - * @return int - */ public function getQueryRejectCondition(): int { return $this->queryRejectCondition; } - /** - * @return int - */ public function getWorkflowExecutionStatus(): int { return $this->workflowExecutionStatus; diff --git a/src/Exception/CompensationException.php b/src/Exception/CompensationException.php index 8f5c7bfe3..2793aef77 100644 --- a/src/Exception/CompensationException.php +++ b/src/Exception/CompensationException.php @@ -18,9 +18,6 @@ class CompensationException extends TemporalException */ private array $suppressed = []; - /** - * @param \Throwable $e - */ public function addSuppressed(\Throwable $e): void { $this->suppressed[] = $e; diff --git a/src/Exception/ExceptionInterceptor.php b/src/Exception/ExceptionInterceptor.php index 771730c64..b55c857f6 100644 --- a/src/Exception/ExceptionInterceptor.php +++ b/src/Exception/ExceptionInterceptor.php @@ -17,14 +17,8 @@ */ class ExceptionInterceptor implements ExceptionInterceptorInterface { - /** - * @var array - */ private array $retryableErrors; - /** - * @param array $retryableErrors - */ public function __construct(array $retryableErrors) { $this->retryableErrors = $retryableErrors; @@ -38,10 +32,6 @@ public static function createDefault(): self return new self([\Error::class]); } - /** - * @param \Throwable $e - * @return bool - */ public function isRetryable(\Throwable $e): bool { foreach ($this->retryableErrors as $retryableError) { diff --git a/src/Exception/ExceptionInterceptorInterface.php b/src/Exception/ExceptionInterceptorInterface.php index 2b7ffd9db..0fefdce5c 100644 --- a/src/Exception/ExceptionInterceptorInterface.php +++ b/src/Exception/ExceptionInterceptorInterface.php @@ -17,9 +17,5 @@ */ interface ExceptionInterceptorInterface { - /** - * @param \Throwable $e - * @return bool - */ public function isRetryable(\Throwable $e): bool; } diff --git a/src/Exception/Failure/ActivityFailure.php b/src/Exception/Failure/ActivityFailure.php index 9037c8cb4..04adac67d 100644 --- a/src/Exception/Failure/ActivityFailure.php +++ b/src/Exception/Failure/ActivityFailure.php @@ -20,15 +20,6 @@ class ActivityFailure extends TemporalFailure private string $identity; private int $retryState; - /** - * @param int $scheduledEventId - * @param int $startedEventId - * @param string $activityType - * @param string $activityId - * @param int $retryState - * @param string $identity - * @param \Throwable|null $previous - */ public function __construct( int $scheduledEventId, int $startedEventId, @@ -36,7 +27,7 @@ public function __construct( string $activityId, int $retryState, string $identity, - \Throwable $previous = null, + ?\Throwable $previous = null, ) { parent::__construct( self::buildMessage( @@ -61,49 +52,31 @@ public function __construct( $this->retryState = $retryState; } - /** - * @return int - */ public function getScheduledEventId(): int { return $this->scheduledEventId; } - /** - * @return int - */ public function getStartedEventId(): int { return $this->startedEventId; } - /** - * @return string - */ public function getActivityType(): string { return $this->activityType; } - /** - * @return string - */ public function getActivityId(): string { return $this->activityId; } - /** - * @return string - */ public function getIdentity(): string { return $this->identity; } - /** - * @return int - */ public function getRetryState(): int { return $this->retryState; diff --git a/src/Exception/Failure/ApplicationFailure.php b/src/Exception/Failure/ApplicationFailure.php index 7e82c9d22..3aceb7cd9 100644 --- a/src/Exception/Failure/ApplicationFailure.php +++ b/src/Exception/Failure/ApplicationFailure.php @@ -47,19 +47,15 @@ class ApplicationFailure extends TemporalFailure private bool $nonRetryable; /** - * @param string $message - * @param string $type - * @param bool $nonRetryable * @param ValuesInterface|null $details Optional details about the failure. - * @param \Throwable|null $previous * @param \DateInterval|null $nextRetryDelay Delay before the next retry attempt. */ public function __construct( string $message, string $type, bool $nonRetryable, - ValuesInterface $details = null, - \Throwable $previous = null, + ?ValuesInterface $details = null, + ?\Throwable $previous = null, private ?\DateInterval $nextRetryDelay = null, ) { parent::__construct( @@ -73,17 +69,11 @@ public function __construct( $this->details = $details ?? EncodedValues::empty(); } - /** - * @return string - */ public function getType(): string { return $this->type; } - /** - * @return ValuesInterface - */ public function getDetails(): ValuesInterface { return $this->details; @@ -94,25 +84,16 @@ public function getNextRetryDelay(): ?\DateInterval return $this->nextRetryDelay; } - /** - * @return bool - */ public function isNonRetryable(): bool { return $this->nonRetryable; } - /** - * @param bool $nonRetryable - */ public function setNonRetryable(bool $nonRetryable): void { $this->nonRetryable = $nonRetryable; } - /** - * @param DataConverterInterface $converter - */ public function setDataConverter(DataConverterInterface $converter): void { $this->details->setDataConverter($converter); diff --git a/src/Exception/Failure/CanceledFailure.php b/src/Exception/Failure/CanceledFailure.php index 640f85213..6a983d940 100644 --- a/src/Exception/Failure/CanceledFailure.php +++ b/src/Exception/Failure/CanceledFailure.php @@ -19,28 +19,17 @@ class CanceledFailure extends TemporalFailure { private ValuesInterface $details; - /** - * @param string $message - * @param ValuesInterface|null $details - * @param \Throwable|null $previous - */ - public function __construct(string $message, ValuesInterface $details = null, \Throwable $previous = null) + public function __construct(string $message, ?ValuesInterface $details = null, ?\Throwable $previous = null) { parent::__construct($message, '', $previous); $this->details = $details ?? EncodedValues::empty(); } - /** - * @return ValuesInterface - */ public function getDetails(): ValuesInterface { return $this->details; } - /** - * @param DataConverterInterface $converter - */ public function setDataConverter(DataConverterInterface $converter): void { $this->details->setDataConverter($converter); diff --git a/src/Exception/Failure/ChildWorkflowFailure.php b/src/Exception/Failure/ChildWorkflowFailure.php index 70e1630fe..f01ebd5e0 100644 --- a/src/Exception/Failure/ChildWorkflowFailure.php +++ b/src/Exception/Failure/ChildWorkflowFailure.php @@ -22,15 +22,6 @@ class ChildWorkflowFailure extends TemporalFailure private WorkflowExecution $execution; private string $workflowType; - /** - * @param int $initiatedEventId - * @param int $startedEventId - * @param string $workflowType - * @param WorkflowExecution $execution - * @param string $namespace - * @param int $retryState - * @param \Throwable|null $previous - */ public function __construct( int $initiatedEventId, int $startedEventId, @@ -38,7 +29,7 @@ public function __construct( WorkflowExecution $execution, string $namespace, int $retryState, - \Throwable $previous = null, + ?\Throwable $previous = null, ) { parent::__construct( self::buildMessage( @@ -64,49 +55,31 @@ public function __construct( $this->retryState = $retryState; } - /** - * @return int - */ public function getInitiatedEventId(): int { return $this->initiatedEventId; } - /** - * @return int - */ public function getStartedEventId(): int { return $this->startedEventId; } - /** - * @return string - */ public function getNamespace(): string { return $this->namespace; } - /** - * @return int - */ public function getRetryState(): int { return $this->retryState; } - /** - * @return WorkflowExecution - */ public function getExecution(): WorkflowExecution { return $this->execution; } - /** - * @return string - */ public function getWorkflowType(): string { return $this->workflowType; diff --git a/src/Exception/Failure/FailureConverter.php b/src/Exception/Failure/FailureConverter.php index faf941b5c..1d1d4262e 100644 --- a/src/Exception/Failure/FailureConverter.php +++ b/src/Exception/Failure/FailureConverter.php @@ -30,16 +30,8 @@ final class FailureConverter { - /** - * @var LoggerInterface|null - */ private static ?LoggerInterface $logger; - /** - * @param Failure $failure - * @param DataConverterInterface $converter - * @return TemporalFailure - */ public static function mapFailureToException(Failure $failure, DataConverterInterface $converter): TemporalFailure { $e = self::createFailureException($failure, $converter); @@ -52,11 +44,6 @@ public static function mapFailureToException(Failure $failure, DataConverterInte return $e; } - /** - * @param \Throwable $e - * @param DataConverterInterface $converter - * @return Failure - */ public static function mapExceptionToFailure(\Throwable $e, DataConverterInterface $converter): Failure { $failure = new Failure(); @@ -173,19 +160,11 @@ public static function mapExceptionToFailure(\Throwable $e, DataConverterInterfa return $failure; } - /** - * @param LoggerInterface $logger - */ public function setLogger(LoggerInterface $logger): void { self::$logger = $logger; } - /** - * @param Failure $failure - * @param DataConverterInterface $converter - * @return TemporalFailure - */ private static function createFailureException(Failure $failure, DataConverterInterface $converter): TemporalFailure { $previous = null; diff --git a/src/Exception/Failure/ServerFailure.php b/src/Exception/Failure/ServerFailure.php index c7a297177..b61a66ae6 100644 --- a/src/Exception/Failure/ServerFailure.php +++ b/src/Exception/Failure/ServerFailure.php @@ -15,12 +15,7 @@ class ServerFailure extends TemporalFailure { private bool $nonRetryable; - /** - * @param string $message - * @param bool $nonRetryable - * @param \Throwable|null $previous - */ - public function __construct(string $message, bool $nonRetryable, \Throwable $previous = null) + public function __construct(string $message, bool $nonRetryable, ?\Throwable $previous = null) { parent::__construct( $message, @@ -30,9 +25,6 @@ public function __construct(string $message, bool $nonRetryable, \Throwable $pre $this->nonRetryable = $nonRetryable; } - /** - * @return bool - */ public function isNonRetryable(): bool { return $this->nonRetryable; diff --git a/src/Exception/Failure/TemporalFailure.php b/src/Exception/Failure/TemporalFailure.php index 97d20bd8f..f10c87f63 100644 --- a/src/Exception/Failure/TemporalFailure.php +++ b/src/Exception/Failure/TemporalFailure.php @@ -35,45 +35,28 @@ class TemporalFailure extends TemporalException implements \Stringable private string $originalMessage; private ?string $originalStackTrace = null; - /** - * @param string $message - * @param string|null $originalMessage - * @param \Throwable|null $previous - */ - public function __construct(string $message, string $originalMessage = null, \Throwable $previous = null) + public function __construct(string $message, ?string $originalMessage = null, ?\Throwable $previous = null) { parent::__construct($message, 0, $previous); $this->originalMessage = $originalMessage ?? ''; } - /** - * @return Failure|null - */ public function getFailure(): ?Failure { return $this->failure; } - /** - * @param Failure|null $failure - */ public function setFailure(?Failure $failure): void { $this->failure = $failure; } - /** - * @return string - */ public function getOriginalMessage(): string { return $this->originalMessage; } - /** - * @param string $stackTrace - */ public function setOriginalStackTrace(string $stackTrace): void { $this->originalStackTrace = $stackTrace; @@ -89,25 +72,16 @@ public function hasOriginalStackTrace(): bool return $this->originalStackTrace !== null; } - /** - * @return string|null - */ public function getOriginalStackTrace(): ?string { return $this->originalStackTrace; } - /** - * @param DataConverterInterface $converter - */ public function setDataConverter(DataConverterInterface $converter): void { // typically handled by children } - /** - * @return string - */ public function __toString(): string { if ($this->hasOriginalStackTrace()) { @@ -120,8 +94,6 @@ public function __toString(): string /** * Explain known types of key=>value pairs. * - * @param array $values - * @return string */ protected static function buildMessage(array $values): string { diff --git a/src/Exception/Failure/TerminatedFailure.php b/src/Exception/Failure/TerminatedFailure.php index badfb7e82..396f65ea3 100644 --- a/src/Exception/Failure/TerminatedFailure.php +++ b/src/Exception/Failure/TerminatedFailure.php @@ -13,11 +13,7 @@ class TerminatedFailure extends TemporalFailure { - /** - * @param string $message - * @param \Throwable|null $previous - */ - public function __construct(string $message, \Throwable $previous = null) + public function __construct(string $message, ?\Throwable $previous = null) { parent::__construct($message, $message, $previous); } diff --git a/src/Exception/Failure/TimeoutFailure.php b/src/Exception/Failure/TimeoutFailure.php index a0080dde5..13d24fddc 100644 --- a/src/Exception/Failure/TimeoutFailure.php +++ b/src/Exception/Failure/TimeoutFailure.php @@ -19,17 +19,11 @@ class TimeoutFailure extends TemporalFailure private ValuesInterface $lastHeartbeatDetails; private int $timeoutType; - /** - * @param string $message - * @param ValuesInterface $lastHeartbeatDetails - * @param int $timeoutWorkflowType - * @param \Throwable|null $previous - */ public function __construct( string $message, ValuesInterface $lastHeartbeatDetails, int $timeoutWorkflowType, - \Throwable $previous = null, + ?\Throwable $previous = null, ) { parent::__construct( self::buildMessage(\compact('message', 'timeoutWorkflowType') + ['type' => 'TimeoutFailure']), @@ -41,25 +35,16 @@ public function __construct( $this->timeoutType = $timeoutWorkflowType; } - /** - * @return int - */ public function getTimeoutType(): int { return $this->timeoutType; } - /** - * @return ValuesInterface - */ public function getLastHeartbeatDetails(): ValuesInterface { return $this->lastHeartbeatDetails; } - /** - * @param DataConverterInterface $converter - */ public function setDataConverter(DataConverterInterface $converter): void { $this->lastHeartbeatDetails->setDataConverter($converter); diff --git a/src/Exception/TemporalException.php b/src/Exception/TemporalException.php index 1b58cf19a..39ced09b8 100644 --- a/src/Exception/TemporalException.php +++ b/src/Exception/TemporalException.php @@ -17,7 +17,6 @@ class TemporalException extends \RuntimeException * Build key-value list to explain exception. Skips empty values. * * @param array $values - * @return string */ protected static function buildMessage(array $values): string { diff --git a/src/Exception/WorkflowExecutionFailedException.php b/src/Exception/WorkflowExecutionFailedException.php index e9f9db736..73675d32c 100644 --- a/src/Exception/WorkflowExecutionFailedException.php +++ b/src/Exception/WorkflowExecutionFailedException.php @@ -15,26 +15,12 @@ class WorkflowExecutionFailedException extends TemporalException { - /** - * @var Failure - */ private Failure $failure; - - /** - * @var int - */ private int $lastWorkflowTaskCompletedEventId; - - /** - * @var int - */ private int $retryState; /** * WorkflowExecutionFailedException constructor. - * @param Failure $failure - * @param int $lastWorkflowTaskCompletedEventId - * @param int $retryState */ public function __construct(Failure $failure, int $lastWorkflowTaskCompletedEventId, int $retryState) { @@ -44,25 +30,16 @@ public function __construct(Failure $failure, int $lastWorkflowTaskCompletedEven $this->retryState = $retryState; } - /** - * @return Failure - */ public function getFailure(): Failure { return $this->failure; } - /** - * @return int - */ public function getWorkflowTaskCompletedEventId(): int { return $this->lastWorkflowTaskCompletedEventId; } - /** - * @return int - */ public function getRetryState(): int { return $this->retryState; diff --git a/src/Interceptor/ActivityInbound/ActivityInput.php b/src/Interceptor/ActivityInbound/ActivityInput.php index 0ce1a2b49..2289bdeb1 100644 --- a/src/Interceptor/ActivityInbound/ActivityInput.php +++ b/src/Interceptor/ActivityInbound/ActivityInput.php @@ -29,8 +29,8 @@ public function __construct( ) {} public function with( - ValuesInterface $arguments = null, - HeaderInterface $header = null, + ?ValuesInterface $arguments = null, + ?HeaderInterface $header = null, ): self { return new self( $arguments ?? $this->arguments, diff --git a/src/Interceptor/ActivityInboundInterceptor.php b/src/Interceptor/ActivityInboundInterceptor.php index 9ac3738cb..16fd81227 100644 --- a/src/Interceptor/ActivityInboundInterceptor.php +++ b/src/Interceptor/ActivityInboundInterceptor.php @@ -26,10 +26,8 @@ interface ActivityInboundInterceptor extends Interceptor /** * Intercepts a call to the main activity entry method. * - * @param ActivityInput $input * @param callable(ActivityInput): mixed $next * - * @return mixed */ public function handleActivityInbound(ActivityInput $input, callable $next): mixed; } diff --git a/src/Interceptor/GrpcClientInterceptor.php b/src/Interceptor/GrpcClientInterceptor.php index f7a98f060..2d36e14bf 100644 --- a/src/Interceptor/GrpcClientInterceptor.php +++ b/src/Interceptor/GrpcClientInterceptor.php @@ -23,11 +23,8 @@ interface GrpcClientInterceptor extends Interceptor * Intercepts a gRPC call. * * @param non-empty-string $method - * @param object $arg - * @param ContextInterface $ctx * @param callable(non-empty-string, object, ContextInterface): object $next * - * @return object */ public function interceptCall(string $method, object $arg, ContextInterface $ctx, callable $next): object; } diff --git a/src/Interceptor/SimplePipelineProvider.php b/src/Interceptor/SimplePipelineProvider.php index 216316941..56360f6a1 100644 --- a/src/Interceptor/SimplePipelineProvider.php +++ b/src/Interceptor/SimplePipelineProvider.php @@ -25,9 +25,6 @@ public function __construct( private iterable $interceptors = [], ) {} - /** - * @inheritDoc - */ public function getPipeline(string $interceptorClass): Pipeline { return $this->cache[$interceptorClass] ??= Pipeline::prepare( diff --git a/src/Interceptor/Trait/WorkflowClientCallsInterceptorTrait.php b/src/Interceptor/Trait/WorkflowClientCallsInterceptorTrait.php index 3ca36a267..5c07fb26a 100644 --- a/src/Interceptor/Trait/WorkflowClientCallsInterceptorTrait.php +++ b/src/Interceptor/Trait/WorkflowClientCallsInterceptorTrait.php @@ -11,6 +11,7 @@ namespace Temporal\Interceptor\Trait; +use Temporal\Client\Update\UpdateHandle; use Temporal\Client\Workflow\WorkflowExecutionDescription; use Temporal\DataConverter\EncodedValues; use Temporal\Interceptor\WorkflowClient\CancelInput; @@ -23,6 +24,7 @@ use Temporal\Interceptor\WorkflowClient\StartUpdateOutput; use Temporal\Interceptor\WorkflowClient\TerminateInput; use Temporal\Interceptor\WorkflowClient\UpdateInput; +use Temporal\Interceptor\WorkflowClient\UpdateWithStartInput; use Temporal\Interceptor\WorkflowClientCallsInterceptor; use Temporal\Workflow\WorkflowExecution; @@ -73,6 +75,16 @@ public function signalWithStart(SignalWithStartInput $input, callable $next): Wo return $next($input); } + /** + * Default implementation of the `updateWithStart` method. + * + * @see WorkflowClientCallsInterceptor::updateWithStart() + */ + public function updateWithStart(UpdateWithStartInput $input, callable $next): UpdateHandle + { + return $next($input); + } + /** * Default implementation of the `getResult` method. * diff --git a/src/Interceptor/Trait/WorkflowOutboundRequestInterceptorTrait.php b/src/Interceptor/Trait/WorkflowOutboundRequestInterceptorTrait.php index 33125b380..992ff7a7c 100644 --- a/src/Interceptor/Trait/WorkflowOutboundRequestInterceptorTrait.php +++ b/src/Interceptor/Trait/WorkflowOutboundRequestInterceptorTrait.php @@ -60,10 +60,8 @@ final public function handleOutboundRequest(RequestInterface $request, callable } /** - * @param ExecuteActivity $request * @param callable(ExecuteActivity): PromiseInterface $next * - * @return PromiseInterface */ private function executeActivityRequest(ExecuteActivity $request, callable $next): PromiseInterface { @@ -71,10 +69,8 @@ private function executeActivityRequest(ExecuteActivity $request, callable $next } /** - * @param ExecuteLocalActivity $request * @param callable(ExecuteLocalActivity): PromiseInterface $next * - * @return PromiseInterface */ private function executeLocalActivityRequest(ExecuteLocalActivity $request, callable $next): PromiseInterface { @@ -82,10 +78,8 @@ private function executeLocalActivityRequest(ExecuteLocalActivity $request, call } /** - * @param ExecuteChildWorkflow $request * @param callable(ExecuteChildWorkflow): PromiseInterface $next * - * @return PromiseInterface */ private function executeChildWorkflowRequest(ExecuteChildWorkflow $request, callable $next): PromiseInterface { @@ -93,10 +87,8 @@ private function executeChildWorkflowRequest(ExecuteChildWorkflow $request, call } /** - * @param NewTimer $request * @param callable(NewTimer): PromiseInterface $next * - * @return PromiseInterface */ private function newTimerRequest(NewTimer $request, callable $next): PromiseInterface { @@ -104,10 +96,8 @@ private function newTimerRequest(NewTimer $request, callable $next): PromiseInte } /** - * @param ContinueAsNew $request * @param callable(ContinueAsNew): PromiseInterface $next * - * @return PromiseInterface */ private function continueAsNewRequest(ContinueAsNew $request, callable $next): PromiseInterface { @@ -115,10 +105,8 @@ private function continueAsNewRequest(ContinueAsNew $request, callable $next): P } /** - * @param SignalExternalWorkflow $request * @param callable(SignalExternalWorkflow): PromiseInterface $next * - * @return PromiseInterface */ private function signalExternalWorkflowRequest(SignalExternalWorkflow $request, callable $next): PromiseInterface { @@ -126,10 +114,8 @@ private function signalExternalWorkflowRequest(SignalExternalWorkflow $request, } /** - * @param CompleteWorkflow $request * @param callable(CompleteWorkflow): PromiseInterface $next * - * @return PromiseInterface */ private function completeWorkflowRequest(CompleteWorkflow $request, callable $next): PromiseInterface { @@ -137,10 +123,8 @@ private function completeWorkflowRequest(CompleteWorkflow $request, callable $ne } /** - * @param CancelExternalWorkflow $request * @param callable(CancelExternalWorkflow): PromiseInterface $next * - * @return PromiseInterface */ private function cancelExternalWorkflowRequest(CancelExternalWorkflow $request, callable $next): PromiseInterface { @@ -148,10 +132,8 @@ private function cancelExternalWorkflowRequest(CancelExternalWorkflow $request, } /** - * @param GetVersion $request * @param callable(GetVersion): PromiseInterface $next * - * @return PromiseInterface */ private function getVersionRequest(GetVersion $request, callable $next): PromiseInterface { @@ -159,10 +141,8 @@ private function getVersionRequest(GetVersion $request, callable $next): Promise } /** - * @param Panic $request * @param callable(Panic): PromiseInterface $next * - * @return PromiseInterface */ private function panicRequest(Panic $request, callable $next): PromiseInterface { @@ -170,10 +150,8 @@ private function panicRequest(Panic $request, callable $next): PromiseInterface } /** - * @param SideEffect $request * @param callable(SideEffect): PromiseInterface $next * - * @return PromiseInterface */ private function sideEffectRequest(SideEffect $request, callable $next): PromiseInterface { @@ -181,10 +159,8 @@ private function sideEffectRequest(SideEffect $request, callable $next): Promise } /** - * @param UpsertSearchAttributes $request * @param callable(UpsertSearchAttributes): PromiseInterface $next * - * @return PromiseInterface */ private function upsertSearchAttributesRequest(UpsertSearchAttributes $request, callable $next): PromiseInterface { @@ -192,10 +168,8 @@ private function upsertSearchAttributesRequest(UpsertSearchAttributes $request, } /** - * @param Cancel $request * @param callable(Cancel): PromiseInterface $next * - * @return PromiseInterface */ private function cancelRequest(Cancel $request, callable $next): PromiseInterface { diff --git a/src/Interceptor/WorkflowClient/CancelInput.php b/src/Interceptor/WorkflowClient/CancelInput.php index 1146b74bd..4e37ea0d4 100644 --- a/src/Interceptor/WorkflowClient/CancelInput.php +++ b/src/Interceptor/WorkflowClient/CancelInput.php @@ -27,7 +27,7 @@ public function __construct( ) {} public function with( - WorkflowExecution $workflowExecution = null, + ?WorkflowExecution $workflowExecution = null, ): self { return new self( $workflowExecution ?? $this->workflowExecution, diff --git a/src/Interceptor/WorkflowClient/DescribeInput.php b/src/Interceptor/WorkflowClient/DescribeInput.php index da23ec188..e616d6c84 100644 --- a/src/Interceptor/WorkflowClient/DescribeInput.php +++ b/src/Interceptor/WorkflowClient/DescribeInput.php @@ -28,8 +28,8 @@ public function __construct( ) {} public function with( - WorkflowExecution $workflowExecution = null, - string $namespace = null, + ?WorkflowExecution $workflowExecution = null, + ?string $namespace = null, ): self { return new self( $workflowExecution ?? $this->workflowExecution, diff --git a/src/Interceptor/WorkflowClient/GetResultInput.php b/src/Interceptor/WorkflowClient/GetResultInput.php index d89851f2b..03febaf63 100644 --- a/src/Interceptor/WorkflowClient/GetResultInput.php +++ b/src/Interceptor/WorkflowClient/GetResultInput.php @@ -30,9 +30,9 @@ public function __construct( ) {} public function with( - WorkflowExecution $workflowExecution = null, - string $workflowType = null, - int $timeout = null, + ?WorkflowExecution $workflowExecution = null, + ?string $workflowType = null, + ?int $timeout = null, ): self { return new self( $workflowExecution ?? $this->workflowExecution, diff --git a/src/Interceptor/WorkflowClient/QueryInput.php b/src/Interceptor/WorkflowClient/QueryInput.php index 279556212..6a28df073 100644 --- a/src/Interceptor/WorkflowClient/QueryInput.php +++ b/src/Interceptor/WorkflowClient/QueryInput.php @@ -31,9 +31,9 @@ public function __construct( ) {} public function with( - WorkflowExecution $workflowExecution = null, - string $queryType = null, - ValuesInterface $arguments = null, + ?WorkflowExecution $workflowExecution = null, + ?string $queryType = null, + ?ValuesInterface $arguments = null, ): self { return new self( $workflowExecution ?? $this->workflowExecution, diff --git a/src/Interceptor/WorkflowClient/SignalInput.php b/src/Interceptor/WorkflowClient/SignalInput.php index 8b74d1c4a..97b1533e1 100644 --- a/src/Interceptor/WorkflowClient/SignalInput.php +++ b/src/Interceptor/WorkflowClient/SignalInput.php @@ -31,8 +31,8 @@ public function __construct( ) {} public function with( - string $signalName = null, - ValuesInterface $arguments = null, + ?string $signalName = null, + ?ValuesInterface $arguments = null, ): self { return new self( $this->workflowExecution, diff --git a/src/Interceptor/WorkflowClient/SignalWithStartInput.php b/src/Interceptor/WorkflowClient/SignalWithStartInput.php index f6a58792f..52c22b2c6 100644 --- a/src/Interceptor/WorkflowClient/SignalWithStartInput.php +++ b/src/Interceptor/WorkflowClient/SignalWithStartInput.php @@ -19,6 +19,8 @@ class SignalWithStartInput { /** + * @param non-empty-string $signalName + * * @no-named-arguments * @internal Don't use the constructor. Use {@see self::with()} instead. */ @@ -28,10 +30,13 @@ public function __construct( public readonly ValuesInterface $signalArguments, ) {} + /** + * @param non-empty-string|null $signalName + */ public function with( - StartInput $workflowStartInput = null, - string $signalName = null, - ValuesInterface $signalArguments = null, + ?StartInput $workflowStartInput = null, + ?string $signalName = null, + ?ValuesInterface $signalArguments = null, ): self { return new self( $workflowStartInput ?? $this->workflowStartInput, diff --git a/src/Interceptor/WorkflowClient/StartInput.php b/src/Interceptor/WorkflowClient/StartInput.php index 070386c35..5c7cc03d0 100644 --- a/src/Interceptor/WorkflowClient/StartInput.php +++ b/src/Interceptor/WorkflowClient/StartInput.php @@ -33,9 +33,9 @@ public function __construct( ) {} public function with( - HeaderInterface $header = null, - ValuesInterface $arguments = null, - WorkflowOptions $options = null, + ?HeaderInterface $header = null, + ?ValuesInterface $arguments = null, + ?WorkflowOptions $options = null, ): self { return new self( $this->workflowId, diff --git a/src/Interceptor/WorkflowClient/TerminateInput.php b/src/Interceptor/WorkflowClient/TerminateInput.php index 1491d02ff..85f284f7d 100644 --- a/src/Interceptor/WorkflowClient/TerminateInput.php +++ b/src/Interceptor/WorkflowClient/TerminateInput.php @@ -28,8 +28,8 @@ public function __construct( ) {} public function with( - WorkflowExecution $workflowExecution = null, - string $reason = null, + ?WorkflowExecution $workflowExecution = null, + ?string $reason = null, ): self { return new self( $workflowExecution ?? $this->workflowExecution, diff --git a/src/Interceptor/WorkflowClient/UpdateWithStartInput.php b/src/Interceptor/WorkflowClient/UpdateWithStartInput.php new file mode 100644 index 000000000..b069d44eb --- /dev/null +++ b/src/Interceptor/WorkflowClient/UpdateWithStartInput.php @@ -0,0 +1,37 @@ +workflowStartInput, + $updateInput ?? $this->updateInput, + ); + } +} diff --git a/src/Interceptor/WorkflowClientCallsInterceptor.php b/src/Interceptor/WorkflowClientCallsInterceptor.php index e09059a91..c69424dc5 100644 --- a/src/Interceptor/WorkflowClientCallsInterceptor.php +++ b/src/Interceptor/WorkflowClientCallsInterceptor.php @@ -11,6 +11,7 @@ namespace Temporal\Interceptor; +use Temporal\Client\Update\UpdateHandle; use Temporal\Client\Workflow\WorkflowExecutionDescription; use Temporal\DataConverter\ValuesInterface; use Temporal\Interceptor\Trait\WorkflowClientCallsInterceptorTrait; @@ -24,6 +25,7 @@ use Temporal\Interceptor\WorkflowClient\StartUpdateOutput; use Temporal\Interceptor\WorkflowClient\TerminateInput; use Temporal\Interceptor\WorkflowClient\UpdateInput; +use Temporal\Interceptor\WorkflowClient\UpdateWithStartInput; use Temporal\Internal\Interceptor\Interceptor; use Temporal\Workflow\WorkflowExecution; @@ -50,74 +52,55 @@ interface WorkflowClientCallsInterceptor extends Interceptor { /** - * @param StartInput $input * @param callable(StartInput): WorkflowExecution $next - * - * @return WorkflowExecution */ public function start(StartInput $input, callable $next): WorkflowExecution; /** - * @param SignalInput $input * @param callable(SignalInput): void $next - * - * @return void */ public function signal(SignalInput $input, callable $next): void; /** - * @param UpdateInput $input * @param callable(UpdateInput): StartUpdateOutput $next - * - * @return StartUpdateOutput */ public function update(UpdateInput $input, callable $next): StartUpdateOutput; /** - * @param SignalWithStartInput $input * @param callable(SignalWithStartInput): WorkflowExecution $next - * - * @return WorkflowExecution */ public function signalWithStart(SignalWithStartInput $input, callable $next): WorkflowExecution; /** - * @param GetResultInput $input - * @param callable(GetResultInput): ?ValuesInterface $next + * @param UpdateWithStartInput $input + * @param callable(UpdateWithStartInput): WorkflowExecution $next * - * @return ValuesInterface|null + * @return UpdateHandle + */ + public function updateWithStart(UpdateWithStartInput $input, callable $next): UpdateHandle; + + /** + * @param callable(GetResultInput): ?ValuesInterface $next */ public function getResult(GetResultInput $input, callable $next): ?ValuesInterface; /** - * @param QueryInput $input * @param callable(QueryInput): ?ValuesInterface $next - * - * @return ValuesInterface|null */ public function query(QueryInput $input, callable $next): ?ValuesInterface; /** - * @param CancelInput $input * @param callable(CancelInput): void $next - * - * @return void */ public function cancel(CancelInput $input, callable $next): void; /** - * @param TerminateInput $input * @param callable(TerminateInput): void $next - * - * @return void */ public function terminate(TerminateInput $input, callable $next): void; /** - * @param DescribeInput $input * @param callable(DescribeInput): void $next - * - * @return WorkflowExecutionDescription */ public function describe(DescribeInput $input, callable $next): WorkflowExecutionDescription; } diff --git a/src/Interceptor/WorkflowInbound/QueryInput.php b/src/Interceptor/WorkflowInbound/QueryInput.php index adb882a91..bd04a0655 100644 --- a/src/Interceptor/WorkflowInbound/QueryInput.php +++ b/src/Interceptor/WorkflowInbound/QueryInput.php @@ -12,6 +12,7 @@ namespace Temporal\Interceptor\WorkflowInbound; use Temporal\DataConverter\ValuesInterface; +use Temporal\Workflow\WorkflowInfo; /** * @psalm-immutable @@ -25,14 +26,17 @@ class QueryInput public function __construct( public readonly string $queryName, public readonly ValuesInterface $arguments, + public readonly WorkflowInfo $info, ) {} public function with( - ValuesInterface $arguments = null, + ?ValuesInterface $arguments = null, + ?WorkflowInfo $info = null, ): self { return new self( $this->queryName, $arguments ?? $this->arguments, + $info ?? $this->info, ); } } diff --git a/src/Interceptor/WorkflowInbound/SignalInput.php b/src/Interceptor/WorkflowInbound/SignalInput.php index 5dc9b4da4..22986dd2d 100644 --- a/src/Interceptor/WorkflowInbound/SignalInput.php +++ b/src/Interceptor/WorkflowInbound/SignalInput.php @@ -31,18 +31,20 @@ public function __construct( public readonly WorkflowInfo $info, public readonly ValuesInterface $arguments, public readonly HeaderInterface $header, + public readonly bool $isReplaying, ) {} public function with( - WorkflowInfo $info = null, - ValuesInterface $arguments = null, - HeaderInterface $header = null, + ?WorkflowInfo $info = null, + ?ValuesInterface $arguments = null, + ?HeaderInterface $header = null, ): self { return new self( $this->signalName, $info ?? $this->info, $arguments ?? $this->arguments, $header ?? $this->header, + $this->isReplaying, ); } } diff --git a/src/Interceptor/WorkflowInbound/UpdateInput.php b/src/Interceptor/WorkflowInbound/UpdateInput.php index c033d1923..c7aca57a1 100644 --- a/src/Interceptor/WorkflowInbound/UpdateInput.php +++ b/src/Interceptor/WorkflowInbound/UpdateInput.php @@ -32,12 +32,13 @@ public function __construct( public readonly WorkflowInfo $info, public readonly ValuesInterface $arguments, public readonly HeaderInterface $header, + public readonly bool $isReplaying, ) {} public function with( - WorkflowInfo $info = null, - ValuesInterface $arguments = null, - HeaderInterface $header = null, + ?WorkflowInfo $info = null, + ?ValuesInterface $arguments = null, + ?HeaderInterface $header = null, ): self { return new self( $this->updateName, @@ -45,6 +46,7 @@ public function with( $info ?? $this->info, $arguments ?? $this->arguments, $header ?? $this->header, + $this->isReplaying, ); } } diff --git a/src/Interceptor/WorkflowInbound/WorkflowInput.php b/src/Interceptor/WorkflowInbound/WorkflowInput.php index 0485c5c1f..c07a5dca5 100644 --- a/src/Interceptor/WorkflowInbound/WorkflowInput.php +++ b/src/Interceptor/WorkflowInbound/WorkflowInput.php @@ -28,17 +28,19 @@ public function __construct( public readonly WorkflowInfo $info, public readonly ValuesInterface $arguments, public readonly HeaderInterface $header, + public readonly bool $isReplaying, ) {} public function with( - WorkflowInfo $info = null, - ValuesInterface $arguments = null, - HeaderInterface $header = null, + ?WorkflowInfo $info = null, + ?ValuesInterface $arguments = null, + ?HeaderInterface $header = null, ): self { return new self( $info ?? $this->info, $arguments ?? $this->arguments, $header ?? $this->header, + $this->isReplaying, ); } } diff --git a/src/Interceptor/WorkflowInboundCallsInterceptor.php b/src/Interceptor/WorkflowInboundCallsInterceptor.php index 27b1bf401..f528eca76 100644 --- a/src/Interceptor/WorkflowInboundCallsInterceptor.php +++ b/src/Interceptor/WorkflowInboundCallsInterceptor.php @@ -41,31 +41,26 @@ interface WorkflowInboundCallsInterceptor extends Interceptor { /** - * @param WorkflowInput $input * @param callable(WorkflowInput): void $next */ public function execute(WorkflowInput $input, callable $next): void; /** - * @param SignalInput $input * @param callable(SignalInput): void $next */ public function handleSignal(SignalInput $input, callable $next): void; /** - * @param QueryInput $input * @param callable(QueryInput): mixed $next */ public function handleQuery(QueryInput $input, callable $next): mixed; /** - * @param UpdateInput $input * @param callable(UpdateInput): mixed $next */ public function handleUpdate(UpdateInput $input, callable $next): mixed; /** - * @param UpdateInput $input * @param callable(UpdateInput): void $next */ public function validateUpdate(UpdateInput $input, callable $next): void; diff --git a/src/Interceptor/WorkflowOutboundCallsInterceptor.php b/src/Interceptor/WorkflowOutboundCallsInterceptor.php index dd2c3b0c4..7b078a2c2 100644 --- a/src/Interceptor/WorkflowOutboundCallsInterceptor.php +++ b/src/Interceptor/WorkflowOutboundCallsInterceptor.php @@ -54,10 +54,8 @@ interface WorkflowOutboundCallsInterceptor extends Interceptor { /** - * @param ExecuteActivityInput $input * @param callable(ExecuteActivityInput): PromiseInterface $next * - * @return PromiseInterface */ public function executeActivity( ExecuteActivityInput $input, @@ -65,41 +63,32 @@ public function executeActivity( ): PromiseInterface; /** - * @param ExecuteLocalActivityInput $input * @param callable(ExecuteLocalActivityInput): PromiseInterface $next * - * @return PromiseInterface */ public function executeLocalActivity(ExecuteLocalActivityInput $input, callable $next): PromiseInterface; /** - * @param ExecuteChildWorkflowInput $input * @param callable(ExecuteChildWorkflowInput): PromiseInterface $next * - * @return PromiseInterface */ public function executeChildWorkflow(ExecuteChildWorkflowInput $input, callable $next): PromiseInterface; /** - * @param SignalExternalWorkflowInput $input * @param callable(SignalExternalWorkflowInput): PromiseInterface $next * - * @return PromiseInterface */ public function signalExternalWorkflow(SignalExternalWorkflowInput $input, callable $next): PromiseInterface; /** - * @param CancelExternalWorkflowInput $input * @param callable(CancelExternalWorkflowInput): PromiseInterface $next * - * @return PromiseInterface */ public function cancelExternalWorkflow(CancelExternalWorkflowInput $input, callable $next): PromiseInterface; /** * Intercept {@see SideEffectInput::$callable} execution. * - * @param SideEffectInput $input * @param callable(SideEffectInput): mixed $next * * @return mixed The result of the callable execution. @@ -107,66 +96,50 @@ public function cancelExternalWorkflow(CancelExternalWorkflowInput $input, calla public function sideEffect(SideEffectInput $input, callable $next): mixed; /** - * @param TimerInput $input * @param callable(TimerInput): PromiseInterface $next * - * @return PromiseInterface */ public function timer(TimerInput $input, callable $next): PromiseInterface; /** - * @param PanicInput $input * @param callable(PanicInput): PromiseInterface $next * - * @return PromiseInterface */ public function panic(PanicInput $input, callable $next): PromiseInterface; /** - * @param CompleteInput $input * @param callable(CompleteInput): PromiseInterface $next * - * @return PromiseInterface */ public function complete(CompleteInput $input, callable $next): PromiseInterface; /** - * @param ContinueAsNewInput $input * @param callable(ContinueAsNewInput): PromiseInterface $next * - * @return PromiseInterface */ public function continueAsNew(ContinueAsNewInput $input, callable $next): PromiseInterface; /** - * @param GetVersionInput $input * @param callable(GetVersionInput): PromiseInterface $next * - * @return PromiseInterface */ public function getVersion(GetVersionInput $input, callable $next): PromiseInterface; /** - * @param UpsertSearchAttributesInput $input * @param callable(UpsertSearchAttributesInput): PromiseInterface $next * - * @return PromiseInterface */ public function upsertSearchAttributes(UpsertSearchAttributesInput $input, callable $next): PromiseInterface; /** - * @param AwaitInput $input * @param callable(AwaitInput): PromiseInterface $next * - * @return PromiseInterface */ public function await(AwaitInput $input, callable $next): PromiseInterface; /** - * @param AwaitWithTimeoutInput $input * @param callable(AwaitWithTimeoutInput): PromiseInterface $next * - * @return PromiseInterface */ public function awaitWithTimeout(AwaitWithTimeoutInput $input, callable $next): PromiseInterface; } diff --git a/src/Interceptor/WorkflowOutboundRequestInterceptor.php b/src/Interceptor/WorkflowOutboundRequestInterceptor.php index 58fe921bd..9619a1006 100644 --- a/src/Interceptor/WorkflowOutboundRequestInterceptor.php +++ b/src/Interceptor/WorkflowOutboundRequestInterceptor.php @@ -39,10 +39,8 @@ interface WorkflowOutboundRequestInterceptor extends Interceptor { /** - * @param RequestInterface $request * @param callable(RequestInterface): PromiseInterface $next * - * @return PromiseInterface */ public function handleOutboundRequest(RequestInterface $request, callable $next): PromiseInterface; } diff --git a/src/Internal/Activity/ActivityContext.php b/src/Internal/Activity/ActivityContext.php index 070264ebb..e46a82b5a 100644 --- a/src/Internal/Activity/ActivityContext.php +++ b/src/Internal/Activity/ActivityContext.php @@ -37,18 +37,12 @@ final class ActivityContext implements ActivityContextInterface, HeaderCarrier private ValuesInterface $input; private HeaderInterface $header; - /** - * @param RPCConnectionInterface $rpc - * @param DataConverterInterface $converter - * @param ValuesInterface $input - * @param ValuesInterface|null $lastHeartbeatDetails - */ public function __construct( RPCConnectionInterface $rpc, DataConverterInterface $converter, ValuesInterface $input, HeaderInterface $header, - ValuesInterface $lastHeartbeatDetails = null, + ?ValuesInterface $lastHeartbeatDetails = null, ) { $this->info = new ActivityInfo(); $this->rpc = $rpc; @@ -58,17 +52,11 @@ public function __construct( $this->header = $header; } - /** - * {@inheritDoc} - */ public function getInfo(): ActivityInfo { return $this->info; } - /** - * {@inheritDoc} - */ public function getInput(): ValuesInterface { return $this->input; @@ -95,17 +83,11 @@ public function withHeader(HeaderInterface $header): self return $context; } - /** - * @return DataConverterInterface - */ public function getDataConverter(): DataConverterInterface { return $this->converter; } - /** - * @return bool - */ public function hasHeartbeatDetails(): bool { return $this->heartbeatDetails !== null; @@ -124,17 +106,11 @@ public function getHeartbeatDetails($type = null) return $this->heartbeatDetails->getValue(0, $type); } - /** - * {@inheritDoc} - */ public function doNotCompleteOnReturn(): void { $this->doNotCompleteOnReturn = true; } - /** - * @return bool - */ public function isDoNotCompleteOnReturn(): bool { return $this->doNotCompleteOnReturn; diff --git a/src/Internal/Assert.php b/src/Internal/Assert.php index 99ef88e7e..2827d6101 100644 --- a/src/Internal/Assert.php +++ b/src/Internal/Assert.php @@ -16,7 +16,6 @@ final class Assert /** * @param mixed $value * @param class-string $enum - * @return bool */ public static function enum($value, string $enum): bool { @@ -38,7 +37,6 @@ public static function enum($value, string $enum): bool /** * @param array $values * @param class-string $of - * @return bool */ public static function valuesInstanceOf(array $values, string $of): bool { @@ -48,7 +46,6 @@ public static function valuesInstanceOf(array $values, string $of): bool /** * @param array $values * @param class-string $of - * @return bool */ public static function valuesSubclassOfOrSameClass(array $values, string $of): bool { @@ -57,8 +54,6 @@ public static function valuesSubclassOfOrSameClass(array $values, string $of): b /** * @param array $values - * @param callable $filter - * @return bool */ public static function all(array $values, callable $filter): bool { diff --git a/src/Internal/Client/ActivityCompletionClient.php b/src/Internal/Client/ActivityCompletionClient.php index 930a9a016..55a2cdd35 100644 --- a/src/Internal/Client/ActivityCompletionClient.php +++ b/src/Internal/Client/ActivityCompletionClient.php @@ -30,11 +30,6 @@ final class ActivityCompletionClient implements ActivityCompletionClientInterfac private ClientOptions $clientOptions; private DataConverterInterface $converter; - /** - * @param ServiceClientInterface $client - * @param ClientOptions $clientOptions - * @param DataConverterInterface $converter - */ public function __construct( ServiceClientInterface $client, ClientOptions $clientOptions, @@ -45,9 +40,6 @@ public function __construct( $this->converter = $converter; } - /** - * {@inheritDoc} - */ public function complete(string $workflowId, ?string $runId, string $activityId, $result = null): void { $r = new Proto\RespondActivityTaskCompletedByIdRequest(); @@ -74,9 +66,6 @@ public function complete(string $workflowId, ?string $runId, string $activityId, } } - /** - * {@inheritDoc} - */ public function completeByToken(string $taskToken, $result = null): void { $r = new Proto\RespondActivityTaskCompletedRequest(); @@ -102,9 +91,6 @@ public function completeByToken(string $taskToken, $result = null): void } } - /** - * {@inheritDoc} - */ public function completeExceptionally( string $workflowId, ?string $runId, @@ -131,9 +117,6 @@ public function completeExceptionally( } } - /** - * {@inheritDoc} - */ public function completeExceptionallyByToken(string $taskToken, \Throwable $error): void { $r = new Proto\RespondActivityTaskFailedRequest(); @@ -154,9 +137,6 @@ public function completeExceptionallyByToken(string $taskToken, \Throwable $erro } } - /** - * {@inheritDoc} - */ public function reportCancellation(string $workflowId, ?string $runId, string $activityId, $details = null): void { $r = new Proto\RespondActivityTaskCanceledByIdRequest(); @@ -178,9 +158,6 @@ public function reportCancellation(string $workflowId, ?string $runId, string $a } } - /** - * {@inheritDoc} - */ public function reportCancellationByToken(string $taskToken, $details = null): void { $r = new Proto\RespondActivityTaskCanceledRequest(); @@ -200,9 +177,6 @@ public function reportCancellationByToken(string $taskToken, $details = null): v } } - /** - * {@inheritDoc} - */ public function recordHeartbeat(string $workflowId, ?string $runId, string $activityId, $details = null): void { $r = new Proto\RecordActivityTaskHeartbeatByIdRequest(); @@ -231,9 +205,6 @@ public function recordHeartbeat(string $workflowId, ?string $runId, string $acti } } - /** - * {@inheritDoc} - */ public function recordHeartbeatByToken(string $taskToken, $details = null): void { $r = new Proto\RecordActivityTaskHeartbeatRequest(); diff --git a/src/Internal/Client/ResponseToResultMapper.php b/src/Internal/Client/ResponseToResultMapper.php new file mode 100644 index 000000000..cad78996b --- /dev/null +++ b/src/Internal/Client/ResponseToResultMapper.php @@ -0,0 +1,80 @@ +getOutcome(); + $updateRef = $result->getUpdateRef(); + \assert($updateRef !== null); + $updateRefDto = new UpdateRef( + new WorkflowExecution( + (string) $updateRef->getWorkflowExecution()?->getWorkflowId(), + $updateRef->getWorkflowExecution()?->getRunId(), + ), + $updateRef->getUpdateId(), + ); + + if ($outcome === null) { + // Not completed + return new StartUpdateOutput($updateRefDto, false, null); + } + + $failure = $outcome->getFailure(); + $success = $outcome->getSuccess(); + + + if ($success !== null) { + return new StartUpdateOutput( + $updateRefDto, + true, + EncodedValues::fromPayloads($success, $this->converter), + ); + } + + if ($failure !== null) { + $execution = $updateRef->getWorkflowExecution(); + throw new WorkflowUpdateException( + null, + $execution === null + ? $workflowExecution + : new WorkflowExecution($execution->getWorkflowId(), $execution->getRunId()), + workflowType: $workflowType, + updateId: $updateRef->getUpdateId(), + updateName: $updateName, + previous: FailureConverter::mapFailureToException($failure, $this->converter), + ); + } + + throw new \RuntimeException( + \sprintf( + 'Received unexpected outcome from update request: %s', + $outcome->getValue(), + ), + ); + } +} diff --git a/src/Internal/Client/WorkflowProxy.php b/src/Internal/Client/WorkflowProxy.php index 6b8d5821f..9b0331ddf 100644 --- a/src/Internal/Client/WorkflowProxy.php +++ b/src/Internal/Client/WorkflowProxy.php @@ -42,9 +42,6 @@ public function hasHandler(): bool return $this->prototype->getHandler() !== null; } - /** - * @return \ReflectionMethod - */ public function getHandlerReflection(): \ReflectionMethod { return $this->prototype->getHandler() ?? throw new \LogicException( diff --git a/src/Internal/Client/WorkflowRun.php b/src/Internal/Client/WorkflowRun.php index 64620b6ef..76a2bb3d9 100644 --- a/src/Internal/Client/WorkflowRun.php +++ b/src/Internal/Client/WorkflowRun.php @@ -20,7 +20,6 @@ final class WorkflowRun implements WorkflowRunInterface { /** - * @param WorkflowStubInterface $stub * @param \ReflectionClass|\ReflectionType|string|Type|null $returnType */ public function __construct( @@ -28,18 +27,12 @@ public function __construct( private $returnType = null, ) {} - /** - * @return WorkflowExecution - */ public function getExecution(): WorkflowExecution { return $this->stub->getExecution(); } - /** - * {@inheritDoc} - */ - public function getResult($type = null, int $timeout = null): mixed + public function getResult($type = null, ?int $timeout = null): mixed { return $this->stub->getResult($type ?? $this->returnType, $timeout); } diff --git a/src/Internal/Client/WorkflowStarter.php b/src/Internal/Client/WorkflowStarter.php index 4d9b2cd1b..c80944f40 100644 --- a/src/Internal/Client/WorkflowStarter.php +++ b/src/Internal/Client/WorkflowStarter.php @@ -12,22 +12,34 @@ namespace Temporal\Internal\Client; use Temporal\Api\Common\V1\WorkflowType; +use Temporal\Api\Errordetails\V1\MultiOperationExecutionFailure; use Temporal\Api\Errordetails\V1\WorkflowExecutionAlreadyStartedFailure; +use Temporal\Api\Failure\V1\MultiOperationExecutionAborted; use Temporal\Api\Taskqueue\V1\TaskQueue; +use Temporal\Api\Update\V1\Request as UpdateRequestMessage; +use Temporal\Api\Workflowservice\V1\ExecuteMultiOperationRequest; +use Temporal\Api\Workflowservice\V1\ExecuteMultiOperationRequest\Operation; +use Temporal\Api\Workflowservice\V1\ExecuteMultiOperationResponse\Response; use Temporal\Api\Workflowservice\V1\SignalWithStartWorkflowExecutionRequest; use Temporal\Api\Workflowservice\V1\StartWorkflowExecutionRequest; +use Temporal\Api\Workflowservice\V1\UpdateWorkflowExecutionRequest; use Temporal\Client\ClientOptions; use Temporal\Client\GRPC\ServiceClientInterface; +use Temporal\Client\Update\UpdateHandle; +use Temporal\Client\Update\UpdateOptions; use Temporal\Client\WorkflowOptions; use Temporal\Common\Uuid; use Temporal\DataConverter\DataConverterInterface; use Temporal\DataConverter\EncodedValues; +use Temporal\Exception\Client\MultyOperation\OperationStatus; use Temporal\Exception\Client\ServiceClientException; use Temporal\Exception\Client\WorkflowExecutionAlreadyStartedException; +use Temporal\Exception\Client\WorkflowServiceException; use Temporal\Interceptor\Header; -use Temporal\Interceptor\HeaderInterface; use Temporal\Interceptor\WorkflowClient\SignalWithStartInput; use Temporal\Interceptor\WorkflowClient\StartInput; +use Temporal\Interceptor\WorkflowClient\UpdateInput; +use Temporal\Interceptor\WorkflowClient\UpdateWithStartInput; use Temporal\Interceptor\WorkflowClientCallsInterceptor; use Temporal\Internal\Interceptor\Pipeline; use Temporal\Internal\Support\DateInterval; @@ -39,9 +51,6 @@ final class WorkflowStarter { /** - * @param ServiceClientInterface $serviceClient - * @param DataConverterInterface $converter - * @param ClientOptions $clientOptions * @param Pipeline $interceptors */ public function __construct( @@ -52,13 +61,6 @@ public function __construct( ) {} /** - * @param string $workflowType - * @param WorkflowOptions $options - * @param array $args - * @param HeaderInterface|null $header - * - * @return WorkflowExecution - * * @throws ServiceClientException * @throws WorkflowExecutionAlreadyStartedException */ @@ -80,14 +82,8 @@ public function start( } /** - * @param string $workflowType - * @param WorkflowOptions $options - * @param string $signal - * @param array $signalArgs - * @param array $startArgs - * @param HeaderInterface|null $header - * - * @return WorkflowExecution + * @param non-empty-string $workflowType + * @param non-empty-string $signal * * @throws ServiceClientException * @throws WorkflowExecutionAlreadyStartedException @@ -129,6 +125,149 @@ function (SignalWithStartInput $input): WorkflowExecution { ); } + /** + * @param non-empty-string $workflowType + * + * @return array{WorkflowExecution, UpdateHandle|\Throwable} + */ + public function updateWithStart( + string $workflowType, + WorkflowOptions $options, + UpdateOptions $update, + array $updateArgs = [], + array $startArgs = [], + ): array { + $arguments = EncodedValues::fromValues($startArgs, $this->converter); + $updateArguments = EncodedValues::fromValues($updateArgs, $this->converter); + + return $this->interceptors->with( + function (UpdateWithStartInput $input): array { + $startRequest = $this->configureExecutionRequest( + new StartWorkflowExecutionRequest(), + $input->workflowStartInput, + ); + + $updateRequest = (new UpdateWorkflowExecutionRequest()) + ->setNamespace($this->clientOptions->namespace) + ->setWorkflowExecution($input->updateInput->workflowExecution->toProtoWorkflowExecution()) + ->setRequest($r = new UpdateRequestMessage()) + ->setWaitPolicy( + (new \Temporal\Api\Update\V1\WaitPolicy()) + ->setLifecycleStage($input->updateInput->waitPolicy->lifecycleStage->value), + ); + + // Configure Meta + $meta = new \Temporal\Api\Update\V1\Meta(); + $meta->setIdentity($this->clientOptions->identity); + $meta->setUpdateId($input->updateInput->updateId); + $r->setMeta($meta); + + // Configure update Input + $i = new \Temporal\Api\Update\V1\Input(); + $i->setName($input->updateInput->updateName); + $input->updateInput->arguments->setDataConverter($this->converter); + $input->updateInput->arguments->isEmpty() or $i->setArgs($input->updateInput->arguments->toPayloads()); + $input->updateInput->header->isEmpty() or $i->setHeader($input->updateInput->header->toHeader()); + $r->setInput($i); + + $ops = [ + (new Operation())->setStartWorkflow($startRequest), + (new Operation())->setUpdateWorkflow($updateRequest), + ]; + + try { + $response = $this->serviceClient->ExecuteMultiOperation( + (new ExecuteMultiOperationRequest()) + ->setNamespace($this->clientOptions->namespace) + ->setOperations($ops), + ); + } catch (ServiceClientException $e) { + $failure = $e->getFailure(MultiOperationExecutionFailure::class) ?? throw $e; + /** @var \ArrayAccess $fails */ + $fails = $failure->getStatuses(); + + $updateStatus = isset($fails[1]) ? OperationStatus::fromMessage($fails[1]) : null; + if ($updateStatus?->getFailure(MultiOperationExecutionAborted::class)) { + $startStatus = OperationStatus::fromMessage($fails[0]); + if ($f = $startStatus?->getFailure(WorkflowExecutionAlreadyStartedFailure::class)) { + \assert($f instanceof WorkflowExecutionAlreadyStartedFailure); + $execution = new WorkflowExecution($input->workflowStartInput->workflowId, $f->getRunId()); + + throw new WorkflowExecutionAlreadyStartedException( + $execution, + $input->workflowStartInput->workflowType, + $e, + ); + } + + throw $e; + } + + throw new WorkflowServiceException( + $updateStatus?->getMessage(), + $input->updateInput->workflowExecution, + $input->workflowStartInput->workflowType, + $e, + ); + } + + // Extract result + /** @var \ArrayAccess $responses */ + $responses = $response->getResponses(); + + // Start Workflow: get execution + $startResponse = $responses[0]->getStartWorkflow(); + \assert($startResponse !== null); + $execution = new WorkflowExecution($input->workflowStartInput->workflowId, $startResponse->getRunId()); + + // Update Workflow: get handler + $updateResponse = $responses[1]->getUpdateWorkflow(); + \assert($updateResponse !== null); + + try { + $updateResult = (new \Temporal\Internal\Client\ResponseToResultMapper($this->converter)) + ->mapUpdateWorkflowResponse( + $updateResponse, + updateName: $input->updateInput->updateName, + workflowType: $input->workflowStartInput->workflowType, + workflowExecution: $execution, + ); + } catch (\RuntimeException $e) { + return [$execution, $e]; + } + + return [$execution, new UpdateHandle( + client: $this->serviceClient, + clientOptions: $this->clientOptions, + converter: $this->converter, + execution: $updateResult->getReference()->workflowExecution, + workflowType: $input->updateInput->workflowType, + updateName: $input->updateInput->updateName, + resultType: $input->updateInput->resultType, + updateId: $updateResult->getReference()->updateId, + result: $updateResult->getResult(), + )]; + }, + /** @see WorkflowClientCallsInterceptor::updateWithStart() */ + 'updateWithStart', + )( + new UpdateWithStartInput( + new StartInput($options->workflowId, $workflowType, Header::empty(), $arguments, $options), + new UpdateInput( + new WorkflowExecution($options->workflowId), + $workflowType, + $update->updateName, + $updateArguments, + Header::empty(), + $update->waitPolicy, + $update->updateId ?? Uuid::v4(), + '', + null, // todo? + ), + ), + ); + } + /** * @param StartWorkflowExecutionRequest|SignalWithStartWorkflowExecutionRequest $request * use {@see configureExecutionRequest()} to prepare request @@ -144,19 +283,16 @@ private function executeRequest( ? $this->serviceClient->StartWorkflowExecution($request) : $this->serviceClient->SignalWithStartWorkflowExecution($request); } catch (ServiceClientException $e) { - $f = $e->getFailure(WorkflowExecutionAlreadyStartedFailure::class); + $f = $e->getFailure(WorkflowExecutionAlreadyStartedFailure::class) ?? throw $e; - if ($f instanceof WorkflowExecutionAlreadyStartedFailure) { - $execution = new WorkflowExecution($request->getWorkflowId(), $f->getRunId()); - - throw new WorkflowExecutionAlreadyStartedException( - $execution, - $request->getWorkflowType()->getName(), - $e, - ); - } + \assert($f instanceof WorkflowExecutionAlreadyStartedFailure); + $execution = new WorkflowExecution($request->getWorkflowId(), $f->getRunId()); - throw $e; + throw new WorkflowExecutionAlreadyStartedException( + $execution, + $request->getWorkflowType()->getName(), + $e, + ); } return new WorkflowExecution( @@ -169,7 +305,6 @@ private function executeRequest( * @template TRequest of StartWorkflowExecutionRequest|SignalWithStartWorkflowExecutionRequest * * @param TRequest $req - * @param StartInput $input * * @return TRequest * diff --git a/src/Internal/Client/WorkflowStub.php b/src/Internal/Client/WorkflowStub.php index 9d85c55ea..7a6dbc1f8 100644 --- a/src/Internal/Client/WorkflowStub.php +++ b/src/Internal/Client/WorkflowStub.php @@ -49,7 +49,6 @@ use Temporal\Exception\Client\WorkflowQueryException; use Temporal\Exception\Client\WorkflowQueryRejectedException; use Temporal\Exception\Client\WorkflowServiceException; -use Temporal\Exception\Client\WorkflowUpdateException; use Temporal\Exception\Client\WorkflowUpdateRPCTimeoutOrCanceledException; use Temporal\Exception\Failure\CanceledFailure; use Temporal\Exception\Failure\FailureConverter; @@ -67,7 +66,6 @@ use Temporal\Interceptor\WorkflowClient\StartUpdateOutput; use Temporal\Interceptor\WorkflowClient\TerminateInput; use Temporal\Interceptor\WorkflowClient\UpdateInput; -use Temporal\Interceptor\WorkflowClient\UpdateRef; use Temporal\Interceptor\WorkflowClientCallsInterceptor; use Temporal\Internal\Interceptor\HeaderCarrier; use Temporal\Internal\Interceptor\Pipeline; @@ -82,12 +80,8 @@ final class WorkflowStub implements WorkflowStubInterface, HeaderCarrier private HeaderInterface $header; /** - * @param ServiceClientInterface $serviceClient - * @param ClientOptions $clientOptions - * @param DataConverterInterface $converter * @param Pipeline $interceptors * @param non-empty-string|null $workflowType - * @param WorkflowOptions|null $options */ public function __construct( private readonly ServiceClientInterface $serviceClient, @@ -100,17 +94,11 @@ public function __construct( $this->header = Header::empty(); } - /** - * {@inheritDoc} - */ public function getWorkflowType(): ?string { return $this->workflowType; } - /** - * {@inheritDoc} - */ public function getOptions(): ?WorkflowOptions { return $this->options; @@ -121,9 +109,6 @@ public function getHeader(): HeaderInterface return $this->header; } - /** - * {@inheritDoc} - */ public function getExecution(): WorkflowExecution { $this->assertStarted(__FUNCTION__); @@ -134,24 +119,17 @@ public function getExecution(): WorkflowExecution /** * Connects stub to running workflow. * - * @param WorkflowExecution $execution */ public function setExecution(WorkflowExecution $execution): void { $this->execution = $execution; } - /** - * @return bool - */ public function hasExecution(): bool { return $this->execution !== null; } - /** - * {@inheritDoc} - */ public function signal(string $name, ...$args): void { $this->assertStarted(__FUNCTION__); @@ -195,9 +173,6 @@ static function (SignalInput $input) use ($request, $serviceClient): void { )); } - /** - * {@inheritDoc} - */ public function query(string $name, ...$args): ?ValuesInterface { $this->assertStarted(__FUNCTION__); @@ -264,9 +239,6 @@ static function (QueryInput $input) use ($serviceClient, $converter, $clientOpti )); } - /** - * {@inheritDoc} - */ public function update(string $name, ...$args): ?ValuesInterface { $options = UpdateOptions::new($name) @@ -275,9 +247,6 @@ public function update(string $name, ...$args): ?ValuesInterface return $this->startUpdate($options, ...$args)->getEncodedValues(); } - /** - * {@inheritDoc} - */ public function startUpdate(string|UpdateOptions $nameOrOptions, ...$args): UpdateHandle { $nameOrOptions = \is_string($nameOrOptions) @@ -338,52 +307,13 @@ static function ( throw new WorkflowServiceException(null, $input->workflowExecution, $input->workflowType, $e); } - $outcome = $result->getOutcome(); - $updateRef = $result->getUpdateRef(); - \assert($updateRef !== null); - $updateRefDto = new UpdateRef( - new WorkflowExecution( - (string) $updateRef->getWorkflowExecution()?->getWorkflowId(), - $updateRef->getWorkflowExecution()?->getRunId(), - ), - $updateRef->getUpdateId(), - ); - - if ($outcome === null) { - // Not completed - return new StartUpdateOutput($updateRefDto, false, null); - } - - $failure = $outcome->getFailure(); - $success = $outcome->getSuccess(); - - - if ($success !== null) { - return new StartUpdateOutput( - $updateRefDto, - true, - EncodedValues::fromPayloads($success, $converter), - ); - } - - if ($failure !== null) { - $execution = $updateRef->getWorkflowExecution(); - throw new WorkflowUpdateException( - null, - $execution === null - ? $input->workflowExecution - : new WorkflowExecution($execution->getWorkflowId(), $execution->getRunId()), - workflowType: $input->workflowType, - updateId: $updateRef->getUpdateId(), - updateName: $input->updateName, - previous: FailureConverter::mapFailureToException($failure, $converter), + return (new \Temporal\Internal\Client\ResponseToResultMapper($converter)) + ->mapUpdateWorkflowResponse( + $result, + $input->updateName, + $input->workflowType, + $input->workflowExecution, ); - } - - throw new \RuntimeException(\sprintf( - 'Received unexpected outcome from update request: %s', - $outcome->getValue(), - )); }, /** @see WorkflowClientCallsInterceptor::update() */ 'update', @@ -412,9 +342,6 @@ static function ( ); } - /** - * {@inheritDoc} - */ public function getUpdateHandle(string $updateId, mixed $resultType = null): UpdateHandle { return new UpdateHandle( @@ -430,9 +357,6 @@ public function getUpdateHandle(string $updateId, mixed $resultType = null): Upd ); } - /** - * {@inheritDoc} - */ public function cancel(): void { $this->assertStarted(__FUNCTION__); @@ -457,9 +381,6 @@ static function (CancelInput $input) use ($serviceClient, $clientOptions): void )); } - /** - * {@inheritDoc} - */ public function terminate(string $reason, array $details = []): void { $this->assertStarted(__FUNCTION__); @@ -491,11 +412,10 @@ static function (TerminateInput $input) use ($serviceClient, $clientOptions, $de } /** - * {@inheritDoc} - * + * @param null|mixed $type * @throws \Throwable */ - public function getResult($type = null, int $timeout = null): mixed + public function getResult($type = null, ?int $timeout = null): mixed { /** @var ValuesInterface|null $result */ $result = $this->interceptors->with( @@ -551,7 +471,6 @@ function (DescribeInput $input): WorkflowExecutionDescription { } /** - * @param string $method * @psalm-assert !null $this->execution */ private function assertStarted(string $method): void @@ -564,11 +483,9 @@ private function assertStarted(string $method): void } /** - * @param int|null $timeout - * @return EncodedValues|null * @throws \ErrorException */ - private function fetchResult(int $timeout = null): ?EncodedValues + private function fetchResult(?int $timeout = null): ?EncodedValues { $this->assertStarted(__FUNCTION__); @@ -644,11 +561,9 @@ private function fetchResult(int $timeout = null): ?EncodedValues } /** - * @param int|null $timeout - * @return HistoryEvent * @throws \ErrorException */ - private function getCloseEvent(int $timeout = null): HistoryEvent + private function getCloseEvent(?int $timeout = null): HistoryEvent { $historyRequest = new GetWorkflowExecutionHistoryRequest(); $historyRequest @@ -703,10 +618,6 @@ private function getCloseEvent(int $timeout = null): HistoryEvent } while (true); } - /** - * @param \Throwable $failure - * @return \Throwable - */ private function mapWorkflowFailureToException(\Throwable $failure): \Throwable { switch (true) { diff --git a/src/Internal/Declaration/ActivityInstance.php b/src/Internal/Declaration/ActivityInstance.php index e34b5d173..81e8c0c80 100644 --- a/src/Internal/Declaration/ActivityInstance.php +++ b/src/Internal/Declaration/ActivityInstance.php @@ -15,10 +15,6 @@ final class ActivityInstance extends Instance implements ActivityInstanceInterface { - /** - * @param ActivityPrototype $prototype - * @param object $context - */ public function __construct( ActivityPrototype $prototype, object $context, diff --git a/src/Internal/Declaration/Dispatcher/Dispatcher.php b/src/Internal/Declaration/Dispatcher/Dispatcher.php index 9e3eb2cfd..8d5bcc187 100644 --- a/src/Internal/Declaration/Dispatcher/Dispatcher.php +++ b/src/Internal/Declaration/Dispatcher/Dispatcher.php @@ -39,47 +39,29 @@ class Dispatcher implements DispatcherInterface */ private $types; - /** - * @var int - */ private int $scope = 0; - /** - * @param \ReflectionFunctionAbstract $fun - */ public function __construct(\ReflectionFunctionAbstract $fun) { $this->boot($fun); } - /** - * @return bool - */ public function isObjectContextRequired(): bool { return $this->scope === static::SCOPE_OBJECT; } - /** - * @return bool - */ #[Pure] public function isObjectContextAllowed(): bool { return $this->scopeMatches(static::SCOPE_OBJECT); } - /** - * @return bool - */ public function isStaticContextRequired(): bool { return $this->scope === static::SCOPE_STATIC; } - /** - * @return bool - */ #[Pure] public function isStaticContextAllowed(): bool { @@ -99,10 +81,6 @@ public function dispatch(object $ctx, array $arguments): mixed return ($this->executor)($ctx, $arguments); } - /** - * @param int $scope - * @return bool - */ #[Pure] private function scopeMatches(int $scope): bool { @@ -112,7 +90,6 @@ private function scopeMatches(int $scope): bool /** * @psalm-return FunctionExecutor * - * @param \ReflectionMethod $fun * @return \Closure(object, array): mixed */ private function createExecutorFromMethod(\ReflectionMethod $fun): \Closure @@ -129,7 +106,6 @@ private function createExecutorFromMethod(\ReflectionMethod $fun): \Closure /** * @psalm-return FunctionExecutor * - * @param \ReflectionFunction $fun * @return \Closure(object, array): mixed */ private function createExecutorFromFunction(\ReflectionFunction $fun): \Closure @@ -154,8 +130,6 @@ private function createExecutorFromFunction(\ReflectionFunction $fun): \Closure /** * @psalm-return FunctionExecutor * - * @param \ReflectionFunctionAbstract $fun - * @return void */ private function boot(\ReflectionFunctionAbstract $fun): void { diff --git a/src/Internal/Declaration/Graph/ClassNode.php b/src/Internal/Declaration/Graph/ClassNode.php index b0dd7888f..dea4b08f0 100644 --- a/src/Internal/Declaration/Graph/ClassNode.php +++ b/src/Internal/Declaration/Graph/ClassNode.php @@ -13,14 +13,8 @@ final class ClassNode implements NodeInterface { - /** - * @var array|null - */ private ?array $inheritance = null; - /** - * @param \ReflectionClass $class - */ public function __construct( private \ReflectionClass $class, ) {} @@ -53,9 +47,6 @@ public function getAllMethods(): array return $result; } - /** - * {@inheritDoc} - */ public function count(): int { return \count( @@ -96,17 +87,11 @@ public function getIterator(): \Traversable ); } - /** - * @return string - */ public function __toString(): string { return $this->class->getName(); } - /** - * @return array - */ private function getClassInheritance(): array { $result = []; @@ -161,10 +146,6 @@ private function getSiblings(): \Traversable } } - /** - * @param \ReflectionClass $interface - * @return bool - */ private function isDirectInterfaceImplementation(\ReflectionClass $interface): bool { if ($parent = $this->class->getParentClass()) { @@ -175,8 +156,6 @@ private function isDirectInterfaceImplementation(\ReflectionClass $interface): b } /** - * @param string $name - * @return bool * @throws \ReflectionException */ private function isDirectMethodImplementation(string $name): bool @@ -192,9 +171,6 @@ private function isDirectMethodImplementation(string $name): bool return false; } - /** - * @return ClassNode|null - */ private function getParent(): ?ClassNode { if ($parent = $this->class->getParentClass()) { @@ -214,8 +190,6 @@ private function getInheritance(): array /** * @param iterable $classes - * @param string $name - * @return array * @throws \ReflectionException */ private function boxMethods(iterable $classes, string $name): array @@ -231,10 +205,6 @@ private function boxMethods(iterable $classes, string $name): array return $result; } - /** - * @param array $boxed - * @return \Traversable - */ private function unboxMethods(array $boxed): \Traversable { $unpack = static function () use ($boxed) { diff --git a/src/Internal/Declaration/Instance.php b/src/Internal/Declaration/Instance.php index 9150b09f8..8b047412e 100644 --- a/src/Internal/Declaration/Instance.php +++ b/src/Internal/Declaration/Instance.php @@ -47,9 +47,6 @@ public function getContext(): object return $this->context; } - /** - * {@inheritDoc} - */ public function getHandler(): callable { return $this->handler; @@ -61,7 +58,6 @@ public function destroy(): void } /** - * @param \ReflectionFunctionAbstract $func * @return \Closure(ValuesInterface): mixed * * @psalm-return DispatchableHandler diff --git a/src/Internal/Declaration/Instantiator/ActivityInstantiator.php b/src/Internal/Declaration/Instantiator/ActivityInstantiator.php index a94fb378c..533196f67 100644 --- a/src/Internal/Declaration/Instantiator/ActivityInstantiator.php +++ b/src/Internal/Declaration/Instantiator/ActivityInstantiator.php @@ -20,9 +20,6 @@ */ final class ActivityInstantiator extends Instantiator { - /** - * {@inheritDoc} - */ public function instantiate(PrototypeInterface $prototype): ActivityInstance { \assert($prototype instanceof ActivityPrototype, 'Precondition failed'); diff --git a/src/Internal/Declaration/Instantiator/Instantiator.php b/src/Internal/Declaration/Instantiator/Instantiator.php index ebde7d2c5..600343074 100644 --- a/src/Internal/Declaration/Instantiator/Instantiator.php +++ b/src/Internal/Declaration/Instantiator/Instantiator.php @@ -16,8 +16,6 @@ abstract class Instantiator implements InstantiatorInterface { /** - * @param PrototypeInterface $prototype - * @return object * @throws \ReflectionException */ protected function getInstance(PrototypeInterface $prototype): object diff --git a/src/Internal/Declaration/Instantiator/WorkflowInstantiator.php b/src/Internal/Declaration/Instantiator/WorkflowInstantiator.php index c6ac77857..6f675a0c2 100644 --- a/src/Internal/Declaration/Instantiator/WorkflowInstantiator.php +++ b/src/Internal/Declaration/Instantiator/WorkflowInstantiator.php @@ -27,9 +27,6 @@ public function __construct( private PipelineProvider $interceptorProvider, ) {} - /** - * {@inheritDoc} - */ public function instantiate(PrototypeInterface $prototype): WorkflowInstance { \assert($prototype instanceof WorkflowPrototype, 'Precondition failed'); @@ -42,8 +39,6 @@ public function instantiate(PrototypeInterface $prototype): WorkflowInstance } /** - * @param PrototypeInterface $prototype - * @return object * @throws \ReflectionException */ protected function getInstance(PrototypeInterface $prototype): object diff --git a/src/Internal/Declaration/Prototype/ActivityPrototype.php b/src/Internal/Declaration/Prototype/ActivityPrototype.php index 325edb643..066cbebfb 100644 --- a/src/Internal/Declaration/Prototype/ActivityPrototype.php +++ b/src/Internal/Declaration/Prototype/ActivityPrototype.php @@ -18,16 +18,8 @@ final class ActivityPrototype extends Prototype { - /** - * @var MethodRetry|null - */ private ?MethodRetry $methodRetry = null; - - /** - * @var ActivityInstance|null - */ private ?ActivityInstance $instance = null; - private ?\Closure $factory = null; private bool $isLocalActivity; @@ -45,9 +37,6 @@ public function __construct( parent::__construct($name, $handler, $class); } - /** - * @return \ReflectionMethod - */ public function getHandler(): \ReflectionMethod { $handler = parent::getHandler(); @@ -56,17 +45,11 @@ public function getHandler(): \ReflectionMethod return $handler; } - /** - * @return MethodRetry|null - */ public function getMethodRetry(): ?MethodRetry { return $this->methodRetry; } - /** - * @param MethodRetry|null $attribute - */ public function setMethodRetry(?MethodRetry $attribute): void { $this->methodRetry = $attribute; @@ -87,7 +70,6 @@ public function getInstance(): ActivityInstance } /** - * @param object $instance * @return $this */ public function withInstance(object $instance): self diff --git a/src/Internal/Declaration/Prototype/Prototype.php b/src/Internal/Declaration/Prototype/Prototype.php index 895f9fc06..8c026a11d 100644 --- a/src/Internal/Declaration/Prototype/Prototype.php +++ b/src/Internal/Declaration/Prototype/Prototype.php @@ -15,26 +15,10 @@ abstract class Prototype implements PrototypeInterface { - /** - * @var string - */ protected string $name; - - /** - * @var \ReflectionMethod|null - */ protected ?\ReflectionMethod $handler; - - /** - * @var \ReflectionClass - */ private \ReflectionClass $class; - /** - * @param string $name - * @param \ReflectionMethod|null $handler - * @param \ReflectionClass $class - */ public function __construct(string $name, ?\ReflectionMethod $handler, \ReflectionClass $class) { $this->handler = $handler; @@ -45,8 +29,6 @@ public function __construct(string $name, ?\ReflectionMethod $handler, \Reflecti /** * @template T of PrototypeInterface * - * @param string $class - * @param string $method * @param RepositoryInterface $repository * @return T|null */ @@ -62,35 +44,21 @@ public static function find(string $class, string $method, RepositoryInterface $ return null; } - /** - * @return string - */ public function getID(): string { return $this->name; } - /** - * @return \ReflectionClass - */ public function getClass(): \ReflectionClass { return $this->class; } - /** - * @return \ReflectionMethod|null - */ public function getHandler(): ?\ReflectionMethod { return $this->handler; } - /** - * @param PrototypeInterface $prototype - * @param string $class - * @return bool - */ private static function matchClass(PrototypeInterface $prototype, string $class): bool { $reflection = $prototype->getClass(); @@ -98,11 +66,6 @@ private static function matchClass(PrototypeInterface $prototype, string $class) return $reflection && $reflection->getName() === \trim($class, '\\'); } - /** - * @param PrototypeInterface $prototype - * @param string $method - * @return bool - */ private static function matchMethod(PrototypeInterface $prototype, string $method): bool { $handler = $prototype->getHandler(); diff --git a/src/Internal/Declaration/Prototype/PrototypeInterface.php b/src/Internal/Declaration/Prototype/PrototypeInterface.php index 83292151c..a3e293ead 100644 --- a/src/Internal/Declaration/Prototype/PrototypeInterface.php +++ b/src/Internal/Declaration/Prototype/PrototypeInterface.php @@ -18,21 +18,18 @@ interface PrototypeInterface extends Identifiable /** * Returns the name of the main handler. * - * @return string */ public function getID(): string; /** * Returns a link to the class within which the handler is defined. * - * @return \ReflectionClass */ public function getClass(): \ReflectionClass; /** * Returns the reflection of the handler function. * - * @return \ReflectionMethod|null */ public function getHandler(): ?\ReflectionMethod; } diff --git a/src/Internal/Declaration/Prototype/WorkflowPrototype.php b/src/Internal/Declaration/Prototype/WorkflowPrototype.php index 0ea832735..020363596 100644 --- a/src/Internal/Declaration/Prototype/WorkflowPrototype.php +++ b/src/Internal/Declaration/Prototype/WorkflowPrototype.php @@ -37,64 +37,35 @@ final class WorkflowPrototype extends Prototype */ private array $updateValidators = []; - /** - * @var CronSchedule|null - */ private ?CronSchedule $cronSchedule = null; - - /** - * @var MethodRetry|null - */ private ?MethodRetry $methodRetry = null; - - /** - * @var ReturnType|null - */ private ?ReturnType $returnType = null; - /** - * @return CronSchedule|null - */ public function getCronSchedule(): ?CronSchedule { return $this->cronSchedule; } - /** - * @param CronSchedule|null $attribute - */ public function setCronSchedule(?CronSchedule $attribute): void { $this->cronSchedule = $attribute; } - /** - * @return MethodRetry|null - */ public function getMethodRetry(): ?MethodRetry { return $this->methodRetry; } - /** - * @param MethodRetry|null $attribute - */ public function setMethodRetry(?MethodRetry $attribute): void { $this->methodRetry = $attribute; } - /** - * @return ReturnType|null - */ public function getReturnType(): ?ReturnType { return $this->returnType; } - /** - * @param ReturnType|null $attribute - */ public function setReturnType(?ReturnType $attribute): void { $this->returnType = $attribute; @@ -133,7 +104,6 @@ public function addUpdateHandler(UpdateDefinition $definition): void /** * @param non-empty-string $name - * @param \ReflectionFunctionAbstract $fun */ public function addValidateUpdateHandler(string $name, \ReflectionFunctionAbstract $fun): void { diff --git a/src/Internal/Declaration/Reader/ActivityReader.php b/src/Internal/Declaration/Reader/ActivityReader.php index c818764a2..8d3b4c49e 100644 --- a/src/Internal/Declaration/Reader/ActivityReader.php +++ b/src/Internal/Declaration/Reader/ActivityReader.php @@ -47,7 +47,6 @@ public function fromClass(string $class): array } /** - * @param \ReflectionClass $class * @return array * @throws \ReflectionException */ @@ -68,8 +67,6 @@ protected function getActivityPrototypes(\ReflectionClass $class): array } /** - * @param ClassNode $graph - * @param \ReflectionMethod $root * @return array * @throws \ReflectionException */ @@ -165,12 +162,6 @@ private function getMethodGroups(ClassNode $graph, \ReflectionMethod $root): arr return $prototypes; } - /** - * @param \ReflectionMethod $ref - * @param ActivityInterface $int - * @param ActivityMethod|null $method - * @return string - */ private function activityName( \ReflectionMethod $ref, ActivityInterface $int, @@ -181,12 +172,6 @@ private function activityName( : $int->prefix . ($method->name ?? $ref->getName()); } - /** - * @param string $name - * @param array $activities - * @param \ReflectionClass $class - * @param \ReflectionMethod $method - */ private function assertActivityNotExists( string $name, array $activities, diff --git a/src/Internal/Declaration/Reader/Reader.php b/src/Internal/Declaration/Reader/Reader.php index 5a0805f08..c462e53a3 100644 --- a/src/Internal/Declaration/Reader/Reader.php +++ b/src/Internal/Declaration/Reader/Reader.php @@ -18,14 +18,8 @@ */ abstract class Reader { - /** - * @var ReaderInterface - */ protected ReaderInterface $reader; - /** - * @param ReaderInterface $reader - */ public function __construct(ReaderInterface $reader) { $this->reader = $reader; @@ -37,10 +31,6 @@ public function __construct(ReaderInterface $reader) */ abstract public function fromClass(string $class); - /** - * @param \ReflectionMethod $method - * @return bool - */ protected function isValidMethod(\ReflectionMethod $method): bool { return !$method->isStatic() && $method->isPublic(); diff --git a/src/Internal/Declaration/Reader/RecursiveAttributeReducerInterface.php b/src/Internal/Declaration/Reader/RecursiveAttributeReducerInterface.php index 48efaf8fb..62ec776ff 100644 --- a/src/Internal/Declaration/Reader/RecursiveAttributeReducerInterface.php +++ b/src/Internal/Declaration/Reader/RecursiveAttributeReducerInterface.php @@ -14,10 +14,6 @@ interface RecursiveAttributeReducerInterface { /** - * @param \ReflectionClass $class - * @param \ReflectionMethod $method - * @param object|null $interface - * @param array $attributes * @return mixed */ public function root( @@ -28,10 +24,6 @@ public function root( ); /** - * @param \ReflectionClass $class - * @param \ReflectionMethod $method - * @param object|null $interface - * @param array $attributes * @return mixed */ public function each( diff --git a/src/Internal/Declaration/Reader/WorkflowReader.php b/src/Internal/Declaration/Reader/WorkflowReader.php index 5b8183f6f..32b3deae3 100644 --- a/src/Internal/Declaration/Reader/WorkflowReader.php +++ b/src/Internal/Declaration/Reader/WorkflowReader.php @@ -69,8 +69,6 @@ class WorkflowReader extends Reader ; /** - * @param string $class - * @return WorkflowPrototype * @throws \ReflectionException */ public function fromClass(string $class): WorkflowPrototype @@ -101,7 +99,6 @@ public function fromObject(object $object): WorkflowPrototype } /** - * @param ClassNode $graph * @return \Traversable * @throws \ReflectionException */ @@ -119,9 +116,6 @@ protected function getWorkflowPrototypes(ClassNode $graph): \Traversable } /** - * @param ClassNode $graph - * @param WorkflowPrototype $prototype - * @return WorkflowPrototype * @throws \ReflectionException */ private function withMethods(ClassNode $graph, WorkflowPrototype $prototype): WorkflowPrototype @@ -247,9 +241,6 @@ private function withMethods(ClassNode $graph, WorkflowPrototype $prototype): Wo return $prototype; } - /** - * @param ClassNode $graph - */ private function assertWorkflowInterface(ClassNode $graph): void { foreach ($graph as $edge) { @@ -268,10 +259,6 @@ private function assertWorkflowInterface(ClassNode $graph): void } /** - * @param ClassNode $graph - * @param \ReflectionMethod $handler - * @param string $name - * @return object|null * @throws \ReflectionException */ private function getAttributedMethod(ClassNode $graph, \ReflectionMethod $handler, string $name): ?object @@ -290,9 +277,6 @@ private function getAttributedMethod(ClassNode $graph, \ReflectionMethod $handle } /** - * @param ClassNode $graph - * @param \ReflectionMethod $handler - * @return WorkflowPrototype|null * @throws \ReflectionException */ private function getPrototype(ClassNode $graph, \ReflectionMethod $handler): ?WorkflowPrototype @@ -387,7 +371,6 @@ private function getDefaultPrototype(ClassNode $graph): WorkflowPrototype * @param \ReflectionMethod $ctx Current method in the inheritance chain * @param \ReflectionClass $interface Class or Interface with #[WorkflowInterface] attribute * @param \ReflectionClass $class Target class - * @return WorkflowPrototype|null */ private function findProto( \ReflectionMethod $handler, diff --git a/src/Internal/Declaration/WorkflowInstance.php b/src/Internal/Declaration/WorkflowInstance.php index 3108f1554..0cff3bb88 100644 --- a/src/Internal/Declaration/WorkflowInstance.php +++ b/src/Internal/Declaration/WorkflowInstance.php @@ -147,9 +147,6 @@ public function initConstructor(): void } } - /** - * @return SignalQueue - */ public function getSignalQueue(): SignalQueue { return $this->signalQueue; @@ -189,8 +186,6 @@ public function findValidateUpdateHandler(string $name): ?\Closure } /** - * @param string $name - * @param callable $handler * @throws \ReflectionException */ public function addQueryHandler(string $name, callable $handler): void @@ -208,7 +203,6 @@ function (QueryInput $input) use ($fn) { /** * @param non-empty-string $name - * @param callable $handler * @throws \ReflectionException */ public function addUpdateHandler(string $name, callable $handler): void @@ -226,7 +220,6 @@ function (UpdateInput $input, Deferred $deferred) use ($fn) { /** * @param non-empty-string $name - * @param callable $handler * @throws \ReflectionException */ public function addValidateUpdateHandler(string $name, callable $handler): void @@ -257,8 +250,6 @@ public function getSignalHandler(string $name): \Closure } /** - * @param string $name - * @param callable $handler * @throws \ReflectionException */ public function addSignalHandler(string $name, callable $handler): void @@ -297,8 +288,6 @@ public function getPrototype(): WorkflowPrototype /** * Make a Closure from a callable. * - * @param callable $handler - * * @return \Closure(ValuesInterface): mixed * @throws \ReflectionException * diff --git a/src/Internal/Declaration/WorkflowInstance/SignalQueue.php b/src/Internal/Declaration/WorkflowInstance/SignalQueue.php index 13e3b17df..d4b61a919 100644 --- a/src/Internal/Declaration/WorkflowInstance/SignalQueue.php +++ b/src/Internal/Declaration/WorkflowInstance/SignalQueue.php @@ -37,7 +37,6 @@ final class SignalQueue /** * @param non-empty-string $signal - * @param ValuesInterface $values */ public function push(string $signal, ValuesInterface $values): void { @@ -59,9 +58,7 @@ public function onSignal(callable $handler): void } /** - * @param string $signal * @param Consumer $consumer - * @return void */ public function attach(string $signal, callable $consumer): void { @@ -75,7 +72,6 @@ public function clear(): void } /** - * @param string $signal * @psalm-suppress UnusedVariable */ private function flush(string $signal): void diff --git a/src/Internal/Declaration/WorkflowInstanceInterface.php b/src/Internal/Declaration/WorkflowInstanceInterface.php index 56c3c5e56..f64905f46 100644 --- a/src/Internal/Declaration/WorkflowInstanceInterface.php +++ b/src/Internal/Declaration/WorkflowInstanceInterface.php @@ -31,21 +31,15 @@ public function initConstructor(): void; */ public function findQueryHandler(string $name): ?\Closure; - /** - * @param string $name - * @param callable $handler - */ public function addQueryHandler(string $name, callable $handler): void; /** * @param non-empty-string $name - * @param callable $handler */ public function addUpdateHandler(string $name, callable $handler): void; /** * @param non-empty-string $name - * @param callable $handler */ public function addValidateUpdateHandler(string $name, callable $handler): void; @@ -61,10 +55,6 @@ public function getSignalHandler(string $name): \Closure; */ public function findUpdateHandler(string $name): ?\Closure; - /** - * @param string $name - * @param callable $handler - */ public function addSignalHandler(string $name, callable $handler): void; public function clearSignalQueue(): void; diff --git a/src/Internal/Events/EventEmitterInterface.php b/src/Internal/Events/EventEmitterInterface.php index 028587530..a49df23c6 100644 --- a/src/Internal/Events/EventEmitterInterface.php +++ b/src/Internal/Events/EventEmitterInterface.php @@ -18,8 +18,6 @@ interface EventEmitterInterface { /** * @param T $event - * @param array $arguments - * @return void */ public function emit(string $event, array $arguments = []): void; } diff --git a/src/Internal/Events/EventEmitterTrait.php b/src/Internal/Events/EventEmitterTrait.php index 9819dc385..c03b71657 100644 --- a/src/Internal/Events/EventEmitterTrait.php +++ b/src/Internal/Events/EventEmitterTrait.php @@ -27,9 +27,6 @@ trait EventEmitterTrait */ protected array $once = []; - /** - * {@inheritDoc} - */ public function once(string $event, callable $then): self { $this->once[$event][] = $then; @@ -37,9 +34,6 @@ public function once(string $event, callable $then): self return $this; } - /** - * {@inheritDoc} - */ public function emit(string $event, array $arguments = []): void { while (($this->once[$event] ?? []) !== []) { diff --git a/src/Internal/Events/EventListenerInterface.php b/src/Internal/Events/EventListenerInterface.php index d834f0148..c9cf01516 100644 --- a/src/Internal/Events/EventListenerInterface.php +++ b/src/Internal/Events/EventListenerInterface.php @@ -18,7 +18,6 @@ interface EventListenerInterface { /** * @param T $event - * @param callable $then * @return $this */ public function once(string $event, callable $then): self; diff --git a/src/Internal/Interceptor/HeaderCarrier.php b/src/Internal/Interceptor/HeaderCarrier.php index 8848fd343..4b7417a5a 100644 --- a/src/Internal/Interceptor/HeaderCarrier.php +++ b/src/Internal/Interceptor/HeaderCarrier.php @@ -21,8 +21,6 @@ interface HeaderCarrier /** * Get configured Header set. * - * @return HeaderInterface - * * @psalm-mutation-free */ public function getHeader(): HeaderInterface; diff --git a/src/Internal/Interceptor/Pipeline.php b/src/Internal/Interceptor/Pipeline.php index c6d8fd1f7..484b777b6 100644 --- a/src/Internal/Interceptor/Pipeline.php +++ b/src/Internal/Interceptor/Pipeline.php @@ -30,7 +30,6 @@ final class Pipeline /** @var non-empty-string */ private string $method; - /** @var \Closure */ private \Closure $last; /** @var list */ @@ -66,7 +65,6 @@ public static function prepare(iterable $interceptors): self } /** - * @param \Closure $last * @param non-empty-string $method Method name of the all interceptors. * * @return TCallable @@ -84,8 +82,6 @@ public function with(\Closure $last, string $method): callable /** * Must be used after {@see self::with()} method. * - * @param mixed ...$arguments - * * @return TReturn */ public function __invoke(mixed ...$arguments): mixed diff --git a/src/Internal/Marshaller/Mapper/AttributeMapper.php b/src/Internal/Marshaller/Mapper/AttributeMapper.php index 19a0336a4..7606f0cf2 100644 --- a/src/Internal/Marshaller/Mapper/AttributeMapper.php +++ b/src/Internal/Marshaller/Mapper/AttributeMapper.php @@ -25,14 +25,7 @@ */ class AttributeMapper implements MapperInterface { - /** - * @var \ReflectionClass - */ private \ReflectionClass $class; - - /** - * @var ReaderInterface - */ private ReaderInterface $reader; /** @@ -45,21 +38,9 @@ class AttributeMapper implements MapperInterface */ private array $setters = []; - /** - * @var Scope - */ private Scope $scope; - - /** - * @var TypeFactoryInterface - */ private TypeFactoryInterface $factory; - /** - * @param \ReflectionClass $class - * @param TypeFactoryInterface $factory - * @param ReaderInterface $reader - */ public function __construct(\ReflectionClass $class, TypeFactoryInterface $factory, ReaderInterface $reader) { $this->class = $class; @@ -76,33 +57,21 @@ public function __construct(\ReflectionClass $class, TypeFactoryInterface $facto } } - /** - * @return bool - */ public function isCopyOnWrite(): bool { return $this->scope->copyOnWrite; } - /** - * {@inheritDoc} - */ public function getGetters(): iterable { return $this->getters; } - /** - * {@inheritDoc} - */ public function getSetters(): iterable { return $this->setters; } - /** - * @return Scope - */ private function getScope(): Scope { return $this->reader->firstClassMetadata($this->class, Scope::class) ?? new Scope(); @@ -112,8 +81,6 @@ private function getScope(): Scope * Generates property name as key and related {@see MarshallingRule} or {@see null} (if no {@see Marshal} * attributes found) as value. * - * @param Scope $scope - * * @return iterable<\ReflectionProperty, array{MarshallingRule|null, bool}> */ private function getPropertyMappings(Scope $scope): iterable @@ -136,22 +103,11 @@ private function getPropertyMappings(Scope $scope): iterable } } - /** - * @param \ReflectionProperty $property - * @param Scope $scope - * @return bool - */ private function isValidScope(\ReflectionProperty $property, Scope $scope): bool { return ($property->getModifiers() & $scope->properties) === $scope->properties; } - /** - * @param \ReflectionProperty $property - * @param MarshallingRule|null $rule - * - * @return TypeInterface|null - */ private function detectType(\ReflectionProperty $property, ?MarshallingRule &$rule): ?TypeInterface { if (($rule === null || !$rule->hasType()) && $this->factory instanceof RuleFactoryInterface) { @@ -175,11 +131,6 @@ private function detectType(\ReflectionProperty $property, ?MarshallingRule &$ru return $this->factory->create($rule->type, $rule->getConstructorArgs()); } - /** - * @param string $name - * @param TypeInterface|null $type - * @return \Closure - */ private function createGetter(string $name, ?TypeInterface $type): \Closure { return function () use ($name, $type) { @@ -193,11 +144,6 @@ private function createGetter(string $name, ?TypeInterface $type): \Closure }; } - /** - * @param string $name - * @param TypeInterface|null $type - * @return \Closure - */ private function createSetter(string $name, ?TypeInterface $type): \Closure { return function ($value) use ($name, $type): void { diff --git a/src/Internal/Marshaller/Mapper/AttributeMapperFactory.php b/src/Internal/Marshaller/Mapper/AttributeMapperFactory.php index 1aa56e4bb..b1d57f475 100644 --- a/src/Internal/Marshaller/Mapper/AttributeMapperFactory.php +++ b/src/Internal/Marshaller/Mapper/AttributeMapperFactory.php @@ -16,22 +16,13 @@ class AttributeMapperFactory implements MapperFactoryInterface { - /** - * @var ReaderInterface - */ private ReaderInterface $reader; - /** - * @param ReaderInterface $reader - */ public function __construct(ReaderInterface $reader) { $this->reader = $reader; } - /** - * {@inheritDoc} - */ public function create(\ReflectionClass $class, TypeFactoryInterface $types): MapperInterface { return new AttributeMapper($class, $types, $this->reader); diff --git a/src/Internal/Marshaller/Mapper/MapperFactoryInterface.php b/src/Internal/Marshaller/Mapper/MapperFactoryInterface.php index 8167b26ef..565cbe575 100644 --- a/src/Internal/Marshaller/Mapper/MapperFactoryInterface.php +++ b/src/Internal/Marshaller/Mapper/MapperFactoryInterface.php @@ -15,10 +15,5 @@ interface MapperFactoryInterface { - /** - * @param \ReflectionClass $class - * @param TypeFactoryInterface $types - * @return MapperInterface - */ public function create(\ReflectionClass $class, TypeFactoryInterface $types): MapperInterface; } diff --git a/src/Internal/Marshaller/Mapper/MapperInterface.php b/src/Internal/Marshaller/Mapper/MapperInterface.php index 227c289b0..48eda1b96 100644 --- a/src/Internal/Marshaller/Mapper/MapperInterface.php +++ b/src/Internal/Marshaller/Mapper/MapperInterface.php @@ -17,9 +17,6 @@ */ interface MapperInterface { - /** - * @return bool - */ public function isCopyOnWrite(): bool; /** diff --git a/src/Internal/Marshaller/Marshaller.php b/src/Internal/Marshaller/Marshaller.php index 535bddc64..574c732fe 100644 --- a/src/Internal/Marshaller/Marshaller.php +++ b/src/Internal/Marshaller/Marshaller.php @@ -26,18 +26,10 @@ class Marshaller implements MarshallerInterface */ private array $mappers = []; - /** - * @var TypeFactory - */ private TypeFactory $type; - - /** - * @var MapperFactoryInterface - */ private MapperFactoryInterface $mapper; /** - * @param MapperFactoryInterface $mapper * @param array $matchers */ public function __construct(MapperFactoryInterface $mapper, array $matchers = []) @@ -47,8 +39,6 @@ public function __construct(MapperFactoryInterface $mapper, array $matchers = [] } /** - * {@inheritDoc} - * * @throws \ReflectionException */ public function marshal(object $from): array @@ -72,8 +62,6 @@ public function marshal(object $from): array } /** - * {@inheritDoc} - * * @throws \ReflectionException */ public function unmarshal(array $from, object $to): object @@ -111,7 +99,6 @@ public function unmarshal(array $from, object $to): object /** * @param class-string $class - * @return MapperInterface * @throws \ReflectionException */ private function factory(string $class): MapperInterface @@ -123,7 +110,6 @@ private function factory(string $class): MapperInterface /** * @param class-string $class - * @return MapperInterface * @throws \ReflectionException */ private function getMapper(string $class): MapperInterface diff --git a/src/Internal/Marshaller/MarshallerInterface.php b/src/Internal/Marshaller/MarshallerInterface.php index d275af9fa..6557c94bb 100644 --- a/src/Internal/Marshaller/MarshallerInterface.php +++ b/src/Internal/Marshaller/MarshallerInterface.php @@ -27,7 +27,6 @@ public function marshal(object $from): mixed; /** * @template T of object - * @param array $from * @param T $to * @return T * diff --git a/src/Internal/Marshaller/MarshallingRule.php b/src/Internal/Marshaller/MarshallingRule.php index fb4bae40c..b08635fba 100644 --- a/src/Internal/Marshaller/MarshallingRule.php +++ b/src/Internal/Marshaller/MarshallingRule.php @@ -19,7 +19,6 @@ class MarshallingRule { /** - * @param string|null $name * @param class-string|null $type * @param self|class-string|string|null $of */ diff --git a/src/Internal/Marshaller/Meta/Marshal.php b/src/Internal/Marshaller/Meta/Marshal.php index d1b44c816..93200d733 100644 --- a/src/Internal/Marshaller/Meta/Marshal.php +++ b/src/Internal/Marshaller/Meta/Marshal.php @@ -28,10 +28,7 @@ class Marshal extends MarshallingRule { /** - * @param string|null $name * @param class-string|null $type - * @param null|Marshal|string $of - * @param bool $nullable */ public function __construct( ?string $name = null, @@ -42,9 +39,6 @@ public function __construct( parent::__construct($name, $type, $of); } - /** - * @return MarshallingRule - */ public function toTypeDto(): MarshallingRule { if (!$this->nullable) { diff --git a/src/Internal/Marshaller/Meta/MarshalArray.php b/src/Internal/Marshaller/Meta/MarshalArray.php index 8bf7ef7cc..75d1527a8 100644 --- a/src/Internal/Marshaller/Meta/MarshalArray.php +++ b/src/Internal/Marshaller/Meta/MarshalArray.php @@ -27,13 +27,8 @@ #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::IS_REPEATABLE), NamedArgumentConstructor] final class MarshalArray extends Marshal { - /** - * @param string|null $name - * @param Marshal|string|null $of - * @param bool $nullable - */ public function __construct( - string $name = null, + ?string $name = null, Marshal|string|null $of = null, bool $nullable = true, ) { diff --git a/src/Internal/Marshaller/Meta/MarshalAssocArray.php b/src/Internal/Marshaller/Meta/MarshalAssocArray.php index c051f6065..1c6325841 100644 --- a/src/Internal/Marshaller/Meta/MarshalAssocArray.php +++ b/src/Internal/Marshaller/Meta/MarshalAssocArray.php @@ -26,13 +26,8 @@ #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::IS_REPEATABLE), NamedArgumentConstructor] final class MarshalAssocArray extends Marshal { - /** - * @param string|null $name - * @param Marshal|string|null $of - * @param bool $nullable - */ public function __construct( - string $name = null, + ?string $name = null, Marshal|string|null $of = null, bool $nullable = true, ) { diff --git a/src/Internal/Marshaller/Meta/MarshalDateTime.php b/src/Internal/Marshaller/Meta/MarshalDateTime.php index bbc047d35..1dfe67241 100644 --- a/src/Internal/Marshaller/Meta/MarshalDateTime.php +++ b/src/Internal/Marshaller/Meta/MarshalDateTime.php @@ -24,10 +24,9 @@ final class MarshalDateTime extends Marshal * @param class-string<\DateTimeInterface>|null $of Local representation of the date. * May be any of internal or Carbon {@see DatetimeInterface} implementations. * @param non-empty-string $to Datetime format or {@see Timestamp} class name. - * @param bool $nullable */ public function __construct( - string $name = null, + ?string $name = null, ?string $of = null, private string $to = \DateTimeInterface::RFC3339, bool $nullable = true, diff --git a/src/Internal/Marshaller/Meta/MarshalNullable.php b/src/Internal/Marshaller/Meta/MarshalNullable.php index a3fc66bad..d390737a5 100644 --- a/src/Internal/Marshaller/Meta/MarshalNullable.php +++ b/src/Internal/Marshaller/Meta/MarshalNullable.php @@ -25,7 +25,7 @@ final class MarshalNullable extends Marshal * @param non-empty-string|null $name */ public function __construct( - string $name = null, + ?string $name = null, string|MarshallingRule|null $rule = null, ) { parent::__construct($name, NullableType::class, $rule); diff --git a/src/Internal/Marshaller/Meta/MarshalOneOf.php b/src/Internal/Marshaller/Meta/MarshalOneOf.php index 69eedfb59..d914721a7 100644 --- a/src/Internal/Marshaller/Meta/MarshalOneOf.php +++ b/src/Internal/Marshaller/Meta/MarshalOneOf.php @@ -21,11 +21,10 @@ final class MarshalOneOf extends Marshal * @param non-empty-array $cases * @param non-empty-string|null $name * @param class-string|null $of - * @param bool $nullable */ public function __construct( private array $cases, - string $name = null, + ?string $name = null, ?string $of = null, bool $nullable = true, ) { diff --git a/src/Internal/Marshaller/Meta/Scope.php b/src/Internal/Marshaller/Meta/Scope.php index 8473f0123..761ad1310 100644 --- a/src/Internal/Marshaller/Meta/Scope.php +++ b/src/Internal/Marshaller/Meta/Scope.php @@ -50,14 +50,10 @@ class Scope #[ExpectedValues(valuesFromClass: Scope::class)] public int $properties; - /** - * @var bool - */ public bool $copyOnWrite; /** * @param ExportScope $properties - * @param bool $copyOnWrite */ public function __construct( int $properties = self::VISIBILITY_PUBLIC, diff --git a/src/Internal/Marshaller/RuleFactoryInterface.php b/src/Internal/Marshaller/RuleFactoryInterface.php index 014881209..0f4d19d7c 100644 --- a/src/Internal/Marshaller/RuleFactoryInterface.php +++ b/src/Internal/Marshaller/RuleFactoryInterface.php @@ -17,10 +17,5 @@ */ interface RuleFactoryInterface extends TypeFactoryInterface { - /** - * @param \ReflectionProperty $property - * - * @return null|MarshallingRule - */ public function makeRule(\ReflectionProperty $property): ?MarshallingRule; } diff --git a/src/Internal/Marshaller/Type/ArrayType.php b/src/Internal/Marshaller/Type/ArrayType.php index 271331a4b..be6ae4db4 100644 --- a/src/Internal/Marshaller/Type/ArrayType.php +++ b/src/Internal/Marshaller/Type/ArrayType.php @@ -24,18 +24,12 @@ class ArrayType extends Type implements DetectableTypeInterface, RuleFactoryInte */ private const ERROR_INVALID_TYPE = 'Passed value must be a type of array, but %s given'; - /** - * @var TypeInterface|null - */ private ?TypeInterface $type = null; /** - * @param MarshallerInterface $marshaller - * @param MarshallingRule|string|null $typeOrClass - * * @throws \ReflectionException */ - public function __construct(MarshallerInterface $marshaller, MarshallingRule|string $typeOrClass = null) + public function __construct(MarshallerInterface $marshaller, MarshallingRule|string|null $typeOrClass = null) { if ($typeOrClass !== null) { $this->type = $this->ofType($marshaller, $typeOrClass); @@ -44,17 +38,11 @@ public function __construct(MarshallerInterface $marshaller, MarshallingRule|str parent::__construct($marshaller); } - /** - * {@inheritDoc} - */ public static function match(\ReflectionNamedType $type): bool { return $type->getName() === 'array' || $type->getName() === 'iterable'; } - /** - * {@inheritDoc} - */ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule { $type = $property->getType(); @@ -95,7 +83,6 @@ public function parse($value, $current): array /** * @param iterable $value * - * @return array */ public function serialize($value): array { diff --git a/src/Internal/Marshaller/Type/AssocArrayType.php b/src/Internal/Marshaller/Type/AssocArrayType.php index 39154f057..96c325b2f 100644 --- a/src/Internal/Marshaller/Type/AssocArrayType.php +++ b/src/Internal/Marshaller/Type/AssocArrayType.php @@ -26,18 +26,12 @@ class AssocArrayType extends Type */ private const ERROR_INVALID_TYPE = 'Passed value must be a type of array, but %s given'; - /** - * @var TypeInterface|null - */ private ?TypeInterface $type = null; /** - * @param MarshallerInterface $marshaller - * @param MarshallingRule|string|null $typeOrClass - * * @throws \ReflectionException */ - public function __construct(MarshallerInterface $marshaller, MarshallingRule|string $typeOrClass = null) + public function __construct(MarshallerInterface $marshaller, MarshallingRule|string|null $typeOrClass = null) { if ($typeOrClass !== null) { $this->type = $this->ofType($marshaller, $typeOrClass); diff --git a/src/Internal/Marshaller/Type/CronType.php b/src/Internal/Marshaller/Type/CronType.php index ae5657cb0..5dec24744 100644 --- a/src/Internal/Marshaller/Type/CronType.php +++ b/src/Internal/Marshaller/Type/CronType.php @@ -23,9 +23,6 @@ class CronType extends Type 'Passed value must be a type of ' . 'cron-like string or cron expression, but %s given'; - /** - * {@inheritDoc} - */ public function parse($value, $current) { if ($value === '') { @@ -40,9 +37,6 @@ public function parse($value, $current) throw new \InvalidArgumentException(\sprintf(self::ERROR_INVALID_TYPE, \get_debug_type($value))); } - /** - * {@inheritDoc} - */ public function serialize($value): string { if (\is_string($value) || $value instanceof \Stringable) { diff --git a/src/Internal/Marshaller/Type/DateIntervalType.php b/src/Internal/Marshaller/Type/DateIntervalType.php index 27af8485c..819394213 100644 --- a/src/Internal/Marshaller/Type/DateIntervalType.php +++ b/src/Internal/Marshaller/Type/DateIntervalType.php @@ -24,15 +24,8 @@ */ class DateIntervalType extends Type implements DetectableTypeInterface, RuleFactoryInterface { - /** - * @var string - */ private string $format; - /** - * @param MarshallerInterface $marshaller - * @param string $format - */ public function __construct(MarshallerInterface $marshaller, string $format = DateInterval::FORMAT_NANOSECONDS) { $this->format = $format; @@ -40,17 +33,11 @@ public function __construct(MarshallerInterface $marshaller, string $format = Da parent::__construct($marshaller); } - /** - * {@inheritDoc} - */ public static function match(\ReflectionNamedType $type): bool { return !$type->isBuiltin() && Inheritance::extends($type->getName(), \DateInterval::class); } - /** - * {@inheritDoc} - */ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule { $type = $property->getType(); @@ -64,9 +51,6 @@ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule : new MarshallingRule($property->getName(), self::class); } - /** - * {@inheritDoc} - */ public function serialize($value): int|Duration { if ($this->format === DateInterval::FORMAT_NANOSECONDS) { @@ -89,9 +73,6 @@ public function serialize($value): int|Duration return (int) (DateInterval::parse($value, $this->format)->$method); } - /** - * {@inheritDoc} - */ public function parse($value, $current): CarbonInterval { return DateInterval::parse($value, $this->format); diff --git a/src/Internal/Marshaller/Type/DateTimeType.php b/src/Internal/Marshaller/Type/DateTimeType.php index 7e15d5e74..f9be701f3 100644 --- a/src/Internal/Marshaller/Type/DateTimeType.php +++ b/src/Internal/Marshaller/Type/DateTimeType.php @@ -23,9 +23,6 @@ */ class DateTimeType extends Type implements DetectableTypeInterface, RuleFactoryInterface { - /** - * @var string - */ private string $format; /** @@ -34,9 +31,7 @@ class DateTimeType extends Type implements DetectableTypeInterface, RuleFactoryI private string $class; /** - * @param MarshallerInterface $marshaller * @param class-string<\DateTimeInterface>|null $class - * @param string $format */ #[Pure] public function __construct( @@ -51,17 +46,11 @@ public function __construct( $this->class = $class; } - /** - * {@inheritDoc} - */ public static function match(\ReflectionNamedType $type): bool { return !$type->isBuiltin() && Inheritance::implements($type->getName(), \DateTimeInterface::class); } - /** - * {@inheritDoc} - */ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule { $type = $property->getType(); @@ -79,9 +68,6 @@ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule : new MarshallingRule($property->getName(), self::class, $type->getName()); } - /** - * {@inheritDoc} - */ public function parse($value, $current): \DateTimeInterface { return DateTime::parse($value, class: $this->class); diff --git a/src/Internal/Marshaller/Type/DetectableTypeInterface.php b/src/Internal/Marshaller/Type/DetectableTypeInterface.php index aedf9e65d..bbb4ed98e 100644 --- a/src/Internal/Marshaller/Type/DetectableTypeInterface.php +++ b/src/Internal/Marshaller/Type/DetectableTypeInterface.php @@ -13,9 +13,5 @@ interface DetectableTypeInterface { - /** - * @param \ReflectionNamedType $type - * @return bool - */ public static function match(\ReflectionNamedType $type): bool; } diff --git a/src/Internal/Marshaller/Type/DurationJsonType.php b/src/Internal/Marshaller/Type/DurationJsonType.php index 0605f6bdb..67e895e7a 100644 --- a/src/Internal/Marshaller/Type/DurationJsonType.php +++ b/src/Internal/Marshaller/Type/DurationJsonType.php @@ -30,7 +30,6 @@ class DurationJsonType extends Type implements DetectableTypeInterface, RuleFact private string $fallbackFormat; /** - * @param MarshallerInterface $marshaller * @param DateIntervalFormat $format Fall back format for parsing when the value is not an array. */ public function __construct(MarshallerInterface $marshaller, string $format = DateInterval::FORMAT_NANOSECONDS) @@ -40,17 +39,11 @@ public function __construct(MarshallerInterface $marshaller, string $format = Da parent::__construct($marshaller); } - /** - * {@inheritDoc} - */ public static function match(\ReflectionNamedType $type): bool { return !$type->isBuiltin() && Inheritance::extends($type->getName(), \DateInterval::class); } - /** - * {@inheritDoc} - */ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule { $type = $property->getType(); @@ -64,9 +57,6 @@ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule : new MarshallingRule($property->getName(), self::class); } - /** - * {@inheritDoc} - */ public function serialize($value): ?array { $duration = match (true) { @@ -82,9 +72,6 @@ public function serialize($value): ?array return ['seconds' => $duration->getSeconds(), 'nanos' => $duration->getNanos()]; } - /** - * {@inheritDoc} - */ public function parse($value, $current): CarbonInterval { if (\is_array($value) && isset($value['seconds']) && isset($value['nanos'])) { diff --git a/src/Internal/Marshaller/Type/EnumType.php b/src/Internal/Marshaller/Type/EnumType.php index 202740ff3..372e22665 100644 --- a/src/Internal/Marshaller/Type/EnumType.php +++ b/src/Internal/Marshaller/Type/EnumType.php @@ -25,7 +25,7 @@ class EnumType extends Type implements RuleFactoryInterface /** @var class-string<\UnitEnum> */ private string $classFQCN; - public function __construct(MarshallerInterface $marshaller, string $class = null) + public function __construct(MarshallerInterface $marshaller, ?string $class = null) { if ($class === null) { throw new \RuntimeException('Enum is required'); @@ -35,9 +35,6 @@ public function __construct(MarshallerInterface $marshaller, string $class = nul parent::__construct($marshaller); } - /** - * {@inheritDoc} - */ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule { $type = $property->getType(); @@ -55,9 +52,6 @@ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule : new MarshallingRule($property->getName(), self::class, $type->getName()); } - /** - * {@inheritDoc} - */ public function parse($value, $current) { if (\is_object($value)) { diff --git a/src/Internal/Marshaller/Type/EnumValueType.php b/src/Internal/Marshaller/Type/EnumValueType.php index 92420bbb7..9ad8a12dd 100644 --- a/src/Internal/Marshaller/Type/EnumValueType.php +++ b/src/Internal/Marshaller/Type/EnumValueType.php @@ -36,9 +36,6 @@ public function __construct(MarshallerInterface $marshaller, ?string $class = nu parent::__construct($marshaller); } - /** - * {@inheritDoc} - */ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule { $type = $property->getType(); @@ -56,9 +53,6 @@ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule : new MarshallingRule($property->getName(), self::class, $type->getName()); } - /** - * {@inheritDoc} - */ public function parse($value, $current) { if (\is_object($value)) { diff --git a/src/Internal/Marshaller/Type/NullableType.php b/src/Internal/Marshaller/Type/NullableType.php index c303821e1..ad2dd8294 100644 --- a/src/Internal/Marshaller/Type/NullableType.php +++ b/src/Internal/Marshaller/Type/NullableType.php @@ -19,18 +19,12 @@ */ class NullableType extends Type { - /** - * @var TypeInterface|null - */ private ?TypeInterface $type = null; /** - * @param MarshallerInterface $marshaller - * @param MarshallingRule|string|null $typeOrClass - * * @throws \ReflectionException */ - public function __construct(MarshallerInterface $marshaller, MarshallingRule|string $typeOrClass = null) + public function __construct(MarshallerInterface $marshaller, MarshallingRule|string|null $typeOrClass = null) { if ($typeOrClass !== null) { $this->type = $this->ofType($marshaller, $typeOrClass); diff --git a/src/Internal/Marshaller/Type/ObjectType.php b/src/Internal/Marshaller/Type/ObjectType.php index 424b53806..06e87f646 100644 --- a/src/Internal/Marshaller/Type/ObjectType.php +++ b/src/Internal/Marshaller/Type/ObjectType.php @@ -26,28 +26,21 @@ class ObjectType extends Type implements DetectableTypeInterface, RuleFactoryInt private \ReflectionClass $reflection; /** - * @param MarshallerInterface $marshaller * @param class-string|null $class * @throws \ReflectionException */ - public function __construct(MarshallerInterface $marshaller, string $class = null) + public function __construct(MarshallerInterface $marshaller, ?string $class = null) { $this->reflection = new \ReflectionClass($class ?? \stdClass::class); parent::__construct($marshaller); } - /** - * {@inheritDoc} - */ public static function match(\ReflectionNamedType $type): bool { return !$type->isBuiltin() || $type->getName() === 'object'; } - /** - * {@inheritDoc} - */ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule { $type = $property->getType(); @@ -65,9 +58,6 @@ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule : new MarshallingRule($property->getName(), self::class, $type->getName()); } - /** - * {@inheritDoc} - */ public function parse($value, $current): object { if (\is_object($value)) { @@ -89,9 +79,6 @@ public function parse($value, $current): object return $this->marshaller->unmarshal($value ?? [], $current); } - /** - * {@inheritDoc} - */ public function serialize($value): array { return $this->reflection->getName() === \stdClass::class @@ -110,8 +97,6 @@ protected function emptyInstance(): object } /** - * @param array $data - * * @return TClass * @throws \ReflectionException * diff --git a/src/Internal/Marshaller/Type/OneOfType.php b/src/Internal/Marshaller/Type/OneOfType.php index 9338d0acb..fc5d8a7c0 100644 --- a/src/Internal/Marshaller/Type/OneOfType.php +++ b/src/Internal/Marshaller/Type/OneOfType.php @@ -32,9 +32,6 @@ public function __construct( parent::__construct($marshaller); } - /** - * {@inheritDoc} - */ public function parse(mixed $value, mixed $current): ?object { if (\is_object($value)) { @@ -84,9 +81,6 @@ public function parse(mixed $value, mixed $current): ?object return $this->marshaller->unmarshal($value, $dto); } - /** - * {@inheritDoc} - */ public function serialize(mixed $value): array { if ($this->nullable && $value === null) { diff --git a/src/Internal/Marshaller/Type/RuleFactoryInterface.php b/src/Internal/Marshaller/Type/RuleFactoryInterface.php index 1b5396444..753ce7a8c 100644 --- a/src/Internal/Marshaller/Type/RuleFactoryInterface.php +++ b/src/Internal/Marshaller/Type/RuleFactoryInterface.php @@ -23,9 +23,6 @@ interface RuleFactoryInterface extends TypeInterface /** * Make a marshalling rule for the given property. * - * @param \ReflectionProperty $property - * - * @return null|MarshallingRule */ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule; } diff --git a/src/Internal/Marshaller/Type/Type.php b/src/Internal/Marshaller/Type/Type.php index e92981659..9aeaac4e5 100644 --- a/src/Internal/Marshaller/Type/Type.php +++ b/src/Internal/Marshaller/Type/Type.php @@ -29,10 +29,6 @@ public function __construct( ) {} /** - * @param MarshallerInterface $marshaller - * @param string|MarshallingRule $type - * - * @return TypeInterface|null * @throws \ReflectionException */ protected function ofType(MarshallerInterface $marshaller, MarshallingRule|string $type): ?TypeInterface diff --git a/src/Internal/Marshaller/TypeFactory.php b/src/Internal/Marshaller/TypeFactory.php index d5b21575d..fb7d533cf 100644 --- a/src/Internal/Marshaller/TypeFactory.php +++ b/src/Internal/Marshaller/TypeFactory.php @@ -44,13 +44,9 @@ class TypeFactory implements RuleFactoryInterface */ private array $typeDtoMatchers = []; - /** - * @var MarshallerInterface - */ private MarshallerInterface $marshaller; /** - * @param MarshallerInterface $marshaller * @param array $matchers */ public function __construct(MarshallerInterface $marshaller, array $matchers) @@ -61,9 +57,6 @@ public function __construct(MarshallerInterface $marshaller, array $matchers) $this->createMatchers($this->getDefaultMatchers()); } - /** - * {@inheritDoc} - */ public function create(string $type, array $args): ?TypeInterface { if (!\is_subclass_of($type, TypeInterface::class)) { @@ -73,9 +66,6 @@ public function create(string $type, array $args): ?TypeInterface return new $type($this->marshaller, ...$args); } - /** - * {@inheritDoc} - */ public function detect(?\ReflectionType $type): ?string { /** @@ -96,9 +86,6 @@ public function detect(?\ReflectionType $type): ?string return null; } - /** - * {@inheritDoc} - */ public function makeRule(\ReflectionProperty $property): ?MarshallingRule { foreach ($this->typeDtoMatchers as $matcher) { diff --git a/src/Internal/Marshaller/TypeFactoryInterface.php b/src/Internal/Marshaller/TypeFactoryInterface.php index ea6b10a04..338ad115c 100644 --- a/src/Internal/Marshaller/TypeFactoryInterface.php +++ b/src/Internal/Marshaller/TypeFactoryInterface.php @@ -17,15 +17,11 @@ interface TypeFactoryInterface { /** * @param class-string $type - * @param array $args * - * @return TypeInterface|null */ public function create(string $type, array $args): ?TypeInterface; /** - * @param \ReflectionType|null $type - * * @return class-string|null */ public function detect(?\ReflectionType $type): ?string; diff --git a/src/Internal/Queue/ArrayQueue.php b/src/Internal/Queue/ArrayQueue.php index abdcb34ae..bfff183d0 100644 --- a/src/Internal/Queue/ArrayQueue.php +++ b/src/Internal/Queue/ArrayQueue.php @@ -25,10 +25,6 @@ class ArrayQueue implements QueueInterface */ public function __construct() {} - /** - * @param int $commandId - * @return CommandInterface|null - */ public function pull(int $commandId): ?CommandInterface { foreach ($this->commands as $i => $command) { @@ -41,10 +37,6 @@ public function pull(int $commandId): ?CommandInterface return null; } - /** - * @param int $commandId - * @return bool - */ public function has(int $commandId): bool { foreach ($this->commands as $command) { @@ -56,9 +48,6 @@ public function has(int $commandId): bool return false; } - /** - * {@inheritDoc} - */ public function getIterator(): \Traversable { while (\count($this->commands)) { @@ -66,17 +55,11 @@ public function getIterator(): \Traversable } } - /** - * {@inheritDoc} - */ public function count(): int { return \count($this->commands); } - /** - * {@inheritDoc} - */ public function push(CommandInterface $command): void { $this->commands[] = $command; diff --git a/src/Internal/Queue/QueueInterface.php b/src/Internal/Queue/QueueInterface.php index 625f05cf7..1de678d7e 100644 --- a/src/Internal/Queue/QueueInterface.php +++ b/src/Internal/Queue/QueueInterface.php @@ -18,20 +18,9 @@ */ interface QueueInterface extends \IteratorAggregate, \Countable { - /** - * @param CommandInterface $command - */ public function push(CommandInterface $command): void; - /** - * @param int $commandId - * @return CommandInterface|null - */ public function pull(int $commandId): ?CommandInterface; - /** - * @param int $commandId - * @return bool - */ public function has(int $commandId): bool; } diff --git a/src/Internal/Repository/ArrayRepository.php b/src/Internal/Repository/ArrayRepository.php index c6e060f9f..1781f6cf1 100644 --- a/src/Internal/Repository/ArrayRepository.php +++ b/src/Internal/Repository/ArrayRepository.php @@ -31,7 +31,6 @@ class ArrayRepository implements RepositoryInterface /** * @param iterable $entries - * @param bool $overwrite */ public function __construct(iterable $entries = [], bool $overwrite = false) { @@ -40,33 +39,21 @@ public function __construct(iterable $entries = [], bool $overwrite = false) } } - /** - * {@inheritDoc} - */ public function filter(callable $filter): RepositoryInterface { return new static(\array_filter($this->entries, $filter)); } - /** - * {@inheritDoc} - */ public function getIterator(): \Traversable { return new \ArrayIterator($this->entries); } - /** - * {@inheritDoc} - */ public function count(): int { return \count($this->entries); } - /** - * {@inheritDoc} - */ public function add(Identifiable $entry, bool $overwrite = false): void { $name = $entry->getID(); @@ -78,25 +65,16 @@ public function add(Identifiable $entry, bool $overwrite = false): void $this->entries[$name] = $entry; } - /** - * {@inheritDoc} - */ public function find($id): ?Identifiable { return $this->entries[$id] ?? null; } - /** - * {@inheritDoc} - */ public function has($id): bool { return isset($this->entries[$id]); } - /** - * {@inheritDoc} - */ public function remove($id): void { unset($this->entries[$id]); diff --git a/src/Internal/Repository/RepositoryInterface.php b/src/Internal/Repository/RepositoryInterface.php index 8259f7d2a..2078d0721 100644 --- a/src/Internal/Repository/RepositoryInterface.php +++ b/src/Internal/Repository/RepositoryInterface.php @@ -31,8 +31,6 @@ public function filter(callable $filter): self; /** * Register a new {@see Identifiable} inside the repository. * - * @param Identifiable $entry - * @param bool $overwrite */ public function add(Identifiable $entry, bool $overwrite = false): void; @@ -51,7 +49,6 @@ public function find($id): ?Identifiable; * otherwise. * * @param Identifier $id - * @return bool */ public function has($id): bool; diff --git a/src/Internal/Support/DateInterval.php b/src/Internal/Support/DateInterval.php index 8c84a154c..f23eb4e56 100644 --- a/src/Internal/Support/DateInterval.php +++ b/src/Internal/Support/DateInterval.php @@ -48,7 +48,6 @@ final class DateInterval /** * @param DateIntervalValue $interval * @param DateIntervalFormat $format - * @return CarbonInterval * @psalm-suppress InvalidOperand */ public static function parse($interval, string $format = self::FORMAT_MILLISECONDS): CarbonInterval @@ -114,7 +113,6 @@ public static function parse($interval, string $format = self::FORMAT_MILLISECON /** * @param DateIntervalValue|null $interval * @param DateIntervalFormat $format - * @return CarbonInterval|null */ public static function parseOrNull($interval, string $format = self::FORMAT_MILLISECONDS): ?CarbonInterval { @@ -127,7 +125,6 @@ public static function parseOrNull($interval, string $format = self::FORMAT_MILL /** * @param DateIntervalValue $interval - * @return bool */ public static function assert($interval): bool { @@ -137,10 +134,9 @@ public static function assert($interval): bool } /** - * @param \DateInterval|null $i * @return ($i is null ? null : Duration) */ - public static function toDuration(\DateInterval $i = null): ?Duration + public static function toDuration(?\DateInterval $i = null): ?Duration { if ($i === null) { return null; @@ -154,10 +150,6 @@ public static function toDuration(\DateInterval $i = null): ?Duration return $d; } - /** - * @param string $format - * @return void - */ private static function validateFormat(string $format): void { if (!\in_array($format, self::AVAILABLE_FORMATS, true)) { diff --git a/src/Internal/Support/DateTime.php b/src/Internal/Support/DateTime.php index 14a2f0a25..39b28b918 100644 --- a/src/Internal/Support/DateTime.php +++ b/src/Internal/Support/DateTime.php @@ -63,7 +63,6 @@ public static function parse($time = null, $tz = null, string $class = \DateTime * TODO: This match function can only parse the "Z" timezone, and in the * case of an explicit timezone "+00:00" this case will be ignored. * - * @param string $time * @return null|array{0: string, 1: string} */ private static function extractRfc3339Accuracy(string $time): ?array diff --git a/src/Internal/Support/Diff.php b/src/Internal/Support/Diff.php index caa1233a7..0cfc8d847 100644 --- a/src/Internal/Support/Diff.php +++ b/src/Internal/Support/Diff.php @@ -60,21 +60,17 @@ public function __construct(object $context) } /** - * @param object $context * @param non-empty-string|null $property - * @return bool */ - public function isPresent(object $context, string $property = null): bool + public function isPresent(object $context, ?string $property = null): bool { return !$this->isChanged($context, $property); } /** - * @param object $context * @param non-empty-string|null $property - * @return bool */ - public function isChanged(object $context, string $property = null): bool + public function isChanged(object $context, ?string $property = null): bool { $this->matchContext($context); @@ -91,7 +87,6 @@ public function isChanged(object $context, string $property = null): bool } /** - * @param object $context * @return array */ public function getPresentPropertyNames(object $context): array @@ -108,7 +103,6 @@ public function getDefaultProperties(): array } /** - * @param object $context * @return array */ public function getPresentProperties(object $context): array @@ -120,7 +114,6 @@ public function getPresentProperties(object $context): array } /** - * @param object $context * @return array */ public function getChangedPropertyNames(object $context): array @@ -129,7 +122,6 @@ public function getChangedPropertyNames(object $context): array } /** - * @param object $context * @return array */ public function getChangedProperties(object $context): array @@ -164,10 +156,6 @@ private function matchContext(object $context): void } } - /** - * @param object $context - * @return bool - */ private function isChangedAnyProperty(object $context): bool { foreach ($this->properties as $name => $value) { diff --git a/src/Internal/Support/Facade.php b/src/Internal/Support/Facade.php index 6d860bf21..dea6ef857 100644 --- a/src/Internal/Support/Facade.php +++ b/src/Internal/Support/Facade.php @@ -62,7 +62,6 @@ public static function getCurrentContext(): object } /** - * @return int * @throws OutOfContextException */ public static function getContextId(): int @@ -75,8 +74,6 @@ public static function getContextId(): int } /** - * @param string $name - * @param array $arguments * @return mixed */ public static function __callStatic(string $name, array $arguments) diff --git a/src/Internal/Support/Inheritance.php b/src/Internal/Support/Inheritance.php index 132351fb7..7f534968a 100644 --- a/src/Internal/Support/Inheritance.php +++ b/src/Internal/Support/Inheritance.php @@ -16,7 +16,6 @@ class Inheritance /** * @param class-string $haystack * @param class-string $trait - * @return bool */ public static function uses(string $haystack, string $trait): bool { @@ -40,7 +39,6 @@ public static function uses(string $haystack, string $trait): bool /** * @param class-string $haystack * @param class-string $class - * @return bool */ public static function extends(string $haystack, string $class): bool { @@ -67,7 +65,6 @@ public static function extends(string $haystack, string $class): bool * @param class-string $haystack * @param class-string $interface * - * @return bool * @psalm-assert-if-true class-string $haystack */ public static function implements(string $haystack, string $interface): bool diff --git a/src/Internal/Support/Options.php b/src/Internal/Support/Options.php index dc0e1cd6c..56d60da62 100644 --- a/src/Internal/Support/Options.php +++ b/src/Internal/Support/Options.php @@ -15,9 +15,6 @@ abstract class Options { - /** - * @var Diff - */ protected Diff $diff; /** @@ -28,18 +25,12 @@ public function __construct() $this->diff = new Diff($this); } - /** - * @return static - */ #[Pure] public static function new(): static { return new static(); } - /** - * @return array - */ public function __debugInfo(): array { $properties = \get_object_vars($this); diff --git a/src/Internal/Support/Process.php b/src/Internal/Support/Process.php index 9eb0d7222..f08b5038f 100644 --- a/src/Internal/Support/Process.php +++ b/src/Internal/Support/Process.php @@ -21,8 +21,6 @@ class Process /** * Run process with arguments and get result. * - * @param string ...$cmd - * @return string */ public static function run(string ...$cmd): string { diff --git a/src/Internal/Support/Reflection.php b/src/Internal/Support/Reflection.php index 734332ab9..a6ee820a3 100644 --- a/src/Internal/Support/Reflection.php +++ b/src/Internal/Support/Reflection.php @@ -18,7 +18,6 @@ final class Reflection * * @template T * - * @param \ReflectionFunctionAbstract $method * @param array $args * @return list Unnamed list of arguments in the correct order. */ diff --git a/src/Internal/Support/StackRenderer.php b/src/Internal/Support/StackRenderer.php index d503f1001..6cc8ce152 100644 --- a/src/Internal/Support/StackRenderer.php +++ b/src/Internal/Support/StackRenderer.php @@ -16,14 +16,12 @@ class StackRenderer /** * Sets files and prefixes to be ignored from the stack trace. * - * @var array */ private static array $ignorePaths = [ 'temporal/sdk/src/Internal/', ]; /** - * @param array $files * @internal please consult Temporal SDK prior to use of this function. */ public static function setIgnoredPaths(array $files): void @@ -34,8 +32,6 @@ public static function setIgnoredPaths(array $files): void /** * Renders trace in easy to digest form, removes references to internal functionality. * - * @param array $stackTrace - * @return string */ public static function renderTrace(array $stackTrace): string { diff --git a/src/Internal/Transport/ClientInterface.php b/src/Internal/Transport/ClientInterface.php index 338feb75c..4e2ab2a96 100644 --- a/src/Internal/Transport/ClientInterface.php +++ b/src/Internal/Transport/ClientInterface.php @@ -31,21 +31,14 @@ public function send(CommandInterface $request): void; /** * Check if command still in sending queue. * - * @param CommandInterface $command - * @return bool */ public function isQueued(CommandInterface $command): bool; - /** - * @param CommandInterface $command - */ public function cancel(CommandInterface $command): void; /** * Reject pending promise. * - * @param CommandInterface $command - * @param \Throwable $reason */ public function reject(CommandInterface $command, \Throwable $reason): void; } diff --git a/src/Internal/Transport/CompletableResult.php b/src/Internal/Transport/CompletableResult.php index 93a81805f..b57a0dbbb 100644 --- a/src/Internal/Transport/CompletableResult.php +++ b/src/Internal/Transport/CompletableResult.php @@ -23,9 +23,6 @@ */ class CompletableResult implements CompletableResultInterface { - /** - * @var bool - */ private bool $resolved = false; /** @@ -33,37 +30,14 @@ class CompletableResult implements CompletableResultInterface */ private $value; - /** - * @var WorkflowContextInterface - */ private WorkflowContextInterface $context; - - /** - * @var LoopInterface - */ private LoopInterface $loop; - - /** - * @var PromiseInterface - */ private PromiseInterface $promise; - - /** - * @var Deferred - */ private Deferred $deferred; - - /** - * @var string - */ private string $layer; /** * CompletableResult constructor. - * @param WorkflowContextInterface $context - * @param LoopInterface $loop - * @param PromiseInterface $promise - * @param string $layer */ public function __construct( WorkflowContextInterface $context, @@ -82,9 +56,6 @@ public function __construct( ); } - /** - * {@inheritDoc} - */ public function isComplete(): bool { return $this->resolved; @@ -101,9 +72,7 @@ public function getValue() /** * @param (callable(mixed): mixed)|null $onFulfilled * @param (callable(\Throwable): mixed)|null $onRejected - * @param callable|null $onProgress * - * @return PromiseInterface */ public function then( ?callable $onFulfilled = null, @@ -171,9 +140,6 @@ function (): void { ); } - /** - * @param \Throwable $e - */ private function onRejected(\Throwable $e): void { $this->resolved = true; diff --git a/src/Internal/Transport/CompletableResultInterface.php b/src/Internal/Transport/CompletableResultInterface.php index f4ceff288..8b4c8610b 100644 --- a/src/Internal/Transport/CompletableResultInterface.php +++ b/src/Internal/Transport/CompletableResultInterface.php @@ -19,9 +19,6 @@ */ interface CompletableResultInterface extends PromiseInterface { - /** - * @return bool - */ public function isComplete(): bool; /** diff --git a/src/Internal/Transport/Request/Cancel.php b/src/Internal/Transport/Request/Cancel.php index 0dfecbae1..a68ac9d79 100644 --- a/src/Internal/Transport/Request/Cancel.php +++ b/src/Internal/Transport/Request/Cancel.php @@ -25,9 +25,6 @@ final class Cancel extends Request /** @var int[] */ private array $requestIds; - /** - * @param int ...$requestId - */ public function __construct(int ...$requestId) { $this->requestIds = $requestId; diff --git a/src/Internal/Transport/Request/CancelExternalWorkflow.php b/src/Internal/Transport/Request/CancelExternalWorkflow.php index 5189270ac..5864788b7 100644 --- a/src/Internal/Transport/Request/CancelExternalWorkflow.php +++ b/src/Internal/Transport/Request/CancelExternalWorkflow.php @@ -20,11 +20,6 @@ class CancelExternalWorkflow extends Request { public const NAME = 'CancelExternalWorkflow'; - /** - * @param string $namespace - * @param string $workflowId - * @param string|null $runId - */ public function __construct( private string $namespace, private string $workflowId, @@ -39,25 +34,16 @@ public function __construct( parent::__construct(self::NAME, $options, null); } - /** - * @return string - */ public function getNamespace(): string { return $this->namespace; } - /** - * @return string - */ public function getWorkflowId(): string { return $this->workflowId; } - /** - * @return null|string - */ public function getRunId(): ?string { return $this->runId; diff --git a/src/Internal/Transport/Request/CompleteWorkflow.php b/src/Internal/Transport/Request/CompleteWorkflow.php index 920976d1c..c03c2042a 100644 --- a/src/Internal/Transport/Request/CompleteWorkflow.php +++ b/src/Internal/Transport/Request/CompleteWorkflow.php @@ -21,11 +21,7 @@ final class CompleteWorkflow extends Request { public const NAME = 'CompleteWorkflow'; - /** - * @param ValuesInterface $values - * @param \Throwable|null $failure - */ - public function __construct(ValuesInterface $values, \Throwable $failure = null) + public function __construct(ValuesInterface $values, ?\Throwable $failure = null) { parent::__construct(self::NAME, [], $values); $this->setFailure($failure); diff --git a/src/Internal/Transport/Request/ContinueAsNew.php b/src/Internal/Transport/Request/ContinueAsNew.php index aee7d2825..3d8ba7d44 100644 --- a/src/Internal/Transport/Request/ContinueAsNew.php +++ b/src/Internal/Transport/Request/ContinueAsNew.php @@ -29,7 +29,6 @@ final class ContinueAsNew extends Request /** * @param non-empty-string $name - * @param ValuesInterface $input * @param RequestOptions $options */ public function __construct(string $name, ValuesInterface $input, array $options, HeaderInterface $header) diff --git a/src/Internal/Transport/Request/ExecuteActivity.php b/src/Internal/Transport/Request/ExecuteActivity.php index ac4104d14..3b5fd276a 100644 --- a/src/Internal/Transport/Request/ExecuteActivity.php +++ b/src/Internal/Transport/Request/ExecuteActivity.php @@ -31,9 +31,7 @@ final class ExecuteActivity extends Request /** * @param non-empty-string $name Activity name - * @param ValuesInterface $args * @param RequestOptions $options - * @param HeaderInterface $header */ public function __construct(string $name, ValuesInterface $args, array $options, HeaderInterface $header) { diff --git a/src/Internal/Transport/Request/ExecuteChildWorkflow.php b/src/Internal/Transport/Request/ExecuteChildWorkflow.php index 55f713c0a..b04781c47 100644 --- a/src/Internal/Transport/Request/ExecuteChildWorkflow.php +++ b/src/Internal/Transport/Request/ExecuteChildWorkflow.php @@ -29,9 +29,7 @@ final class ExecuteChildWorkflow extends Request /** * @param non-empty-string $name Workflow name - * @param ValuesInterface $input * @param RequestOptions $options - * @param HeaderInterface $header */ public function __construct(string $name, ValuesInterface $input, array $options, HeaderInterface $header) { diff --git a/src/Internal/Transport/Request/ExecuteLocalActivity.php b/src/Internal/Transport/Request/ExecuteLocalActivity.php index 2d5df9b2c..6d906769b 100644 --- a/src/Internal/Transport/Request/ExecuteLocalActivity.php +++ b/src/Internal/Transport/Request/ExecuteLocalActivity.php @@ -31,9 +31,7 @@ final class ExecuteLocalActivity extends Request /** * @param non-empty-string $name Activity name - * @param ValuesInterface $args * @param RequestOptions $options - * @param HeaderInterface $header */ public function __construct(string $name, ValuesInterface $args, array $options, HeaderInterface $header) { diff --git a/src/Internal/Transport/Request/GetChildWorkflowExecution.php b/src/Internal/Transport/Request/GetChildWorkflowExecution.php index d56dea7f7..99616c5a2 100644 --- a/src/Internal/Transport/Request/GetChildWorkflowExecution.php +++ b/src/Internal/Transport/Request/GetChildWorkflowExecution.php @@ -21,9 +21,6 @@ final class GetChildWorkflowExecution extends Request /** @see ParentClosePolicy */ private int $parentClosePolicy; - /** - * @param ExecuteChildWorkflow $execution - */ public function __construct(ExecuteChildWorkflow $execution) { $this->parentClosePolicy = $execution->getOptions()['options']['ParentClosePolicy'] ?? ParentClosePolicy::POLICY_UNSPECIFIED; diff --git a/src/Internal/Transport/Request/GetVersion.php b/src/Internal/Transport/Request/GetVersion.php index 8bf4ddaef..a3a554adc 100644 --- a/src/Internal/Transport/Request/GetVersion.php +++ b/src/Internal/Transport/Request/GetVersion.php @@ -18,7 +18,6 @@ final class GetVersion extends Request public const NAME = 'GetVersion'; /** - * @param string $changeId * @param positive-int $minSupported * @param positive-int $maxSupported */ @@ -37,25 +36,16 @@ public function __construct( ); } - /** - * @return string - */ public function getChangeId(): string { return $this->changeId; } - /** - * @return int - */ public function getMinSupported(): int { return $this->minSupported; } - /** - * @return int - */ public function getMaxSupported(): int { return $this->maxSupported; diff --git a/src/Internal/Transport/Request/NewTimer.php b/src/Internal/Transport/Request/NewTimer.php index 1cafcaa02..077a4d0eb 100644 --- a/src/Internal/Transport/Request/NewTimer.php +++ b/src/Internal/Transport/Request/NewTimer.php @@ -21,17 +21,11 @@ final class NewTimer extends Request { public const NAME = 'NewTimer'; - /** - * @param \DateInterval $interval - */ public function __construct(private \DateInterval $interval) { parent::__construct(self::NAME, ['ms' => (int) CarbonInterval::make($interval)->totalMilliseconds]); } - /** - * @return \DateInterval - */ public function getInterval(): \DateInterval { return $this->interval; diff --git a/src/Internal/Transport/Request/Panic.php b/src/Internal/Transport/Request/Panic.php index b06711e68..378c971ce 100644 --- a/src/Internal/Transport/Request/Panic.php +++ b/src/Internal/Transport/Request/Panic.php @@ -20,10 +20,7 @@ final class Panic extends Request { public const NAME = 'Panic'; - /** - * @param \Throwable|null $failure - */ - public function __construct(\Throwable $failure = null) + public function __construct(?\Throwable $failure = null) { parent::__construct(self::NAME, [], null); $this->setFailure($failure); diff --git a/src/Internal/Transport/Request/SideEffect.php b/src/Internal/Transport/Request/SideEffect.php index 4c53ec4ac..07c9cf97f 100644 --- a/src/Internal/Transport/Request/SideEffect.php +++ b/src/Internal/Transport/Request/SideEffect.php @@ -18,9 +18,6 @@ final class SideEffect extends Request { public const NAME = 'SideEffect'; - /** - * @param ValuesInterface $values - */ public function __construct(ValuesInterface $values) { parent::__construct(self::NAME, [], $values); diff --git a/src/Internal/Transport/Request/SignalExternalWorkflow.php b/src/Internal/Transport/Request/SignalExternalWorkflow.php index a2f3f6aa3..234d264e3 100644 --- a/src/Internal/Transport/Request/SignalExternalWorkflow.php +++ b/src/Internal/Transport/Request/SignalExternalWorkflow.php @@ -21,20 +21,12 @@ final class SignalExternalWorkflow extends Request { public const NAME = 'SignalExternalWorkflow'; - /** - * @param string $namespace - * @param string $workflowId - * @param string|null $runId - * @param string $signal - * @param ValuesInterface|null $input - * @param bool $childWorkflowOnly - */ public function __construct( string $namespace, string $workflowId, ?string $runId, string $signal, - ValuesInterface $input = null, + ?ValuesInterface $input = null, bool $childWorkflowOnly = false, ) { $options = [ diff --git a/src/Internal/Transport/Router.php b/src/Internal/Transport/Router.php index 64b421362..4fdef1fc5 100644 --- a/src/Internal/Transport/Router.php +++ b/src/Internal/Transport/Router.php @@ -35,9 +35,6 @@ final class Router implements RouterInterface */ private array $routes = []; - /** - * {@inheritDoc} - */ public function add(RouteInterface $route, bool $overwrite = false): void { if ($overwrite === false && isset($this->routes[$route->getName()])) { @@ -47,26 +44,16 @@ public function add(RouteInterface $route, bool $overwrite = false): void $this->routes[$route->getName()] = $route; } - /** - * {@inheritDoc} - */ public function remove(ServerRequestInterface $route): void { unset($this->routes[$route->getName()]); } - /** - * @param ServerRequestInterface $request - * @return RouteInterface|null - */ public function match(ServerRequestInterface $request): ?RouteInterface { return $this->routes[$request->getName()] ?? null; } - /** - * {@inheritDoc} - */ public function dispatch(ServerRequestInterface $request, array $headers = []): PromiseInterface { // assert($request instanceof ServerRequestInterface); diff --git a/src/Internal/Transport/Router/CancelWorkflow.php b/src/Internal/Transport/Router/CancelWorkflow.php index a2694e365..61d77b9cf 100644 --- a/src/Internal/Transport/Router/CancelWorkflow.php +++ b/src/Internal/Transport/Router/CancelWorkflow.php @@ -23,9 +23,6 @@ class CancelWorkflow extends WorkflowProcessAwareRoute */ private const ERROR_PROCESS_NOT_DEFINED = 'Unable to cancel workflow because workflow process #%s was not found'; - /** - * {@inheritDoc} - */ public function handle(ServerRequestInterface $request, array $headers, Deferred $resolver): void { $this->cancel($request->getID()); @@ -33,10 +30,6 @@ public function handle(ServerRequestInterface $request, array $headers, Deferred $resolver->resolve(EncodedValues::fromValues([null])); } - /** - * @param string $runId - * @return array - */ public function cancel(string $runId): array { /** @var Process $process */ diff --git a/src/Internal/Transport/Router/DestroyWorkflow.php b/src/Internal/Transport/Router/DestroyWorkflow.php index 538b5d5d2..6d5d804ad 100644 --- a/src/Internal/Transport/Router/DestroyWorkflow.php +++ b/src/Internal/Transport/Router/DestroyWorkflow.php @@ -38,9 +38,6 @@ public function __construct( parent::__construct($running); } - /** - * {@inheritDoc} - */ public function handle(ServerRequestInterface $request, array $headers, Deferred $resolver): void { $this->kill($request->getID()); @@ -48,10 +45,6 @@ public function handle(ServerRequestInterface $request, array $headers, Deferred $resolver->resolve(EncodedValues::fromValues([null])); } - /** - * @param string $runId - * @return array - */ public function kill(string $runId): array { /** @var Process $process */ diff --git a/src/Internal/Transport/Router/GetWorkerInfo.php b/src/Internal/Transport/Router/GetWorkerInfo.php index a3556de8b..709257278 100644 --- a/src/Internal/Transport/Router/GetWorkerInfo.php +++ b/src/Internal/Transport/Router/GetWorkerInfo.php @@ -18,34 +18,18 @@ use Temporal\Internal\Declaration\Prototype\WorkflowPrototype; use Temporal\Internal\Marshaller\MarshallerInterface; use Temporal\Internal\Repository\RepositoryInterface; +use Temporal\Worker\ServiceCredentials; use Temporal\Worker\Transport\Command\ServerRequestInterface; use Temporal\Worker\WorkerInterface; final class GetWorkerInfo extends Route { - /** - * @var RepositoryInterface - */ - private RepositoryInterface $queues; - - /** - * @var MarshallerInterface - */ - private MarshallerInterface $marshaller; - - /** - * @param RepositoryInterface $queues - * @param MarshallerInterface $marshaller - */ - public function __construct(RepositoryInterface $queues, MarshallerInterface $marshaller) - { - $this->queues = $queues; - $this->marshaller = $marshaller; - } + public function __construct( + private readonly RepositoryInterface $queues, + private readonly MarshallerInterface $marshaller, + private readonly ServiceCredentials $credentials, + ) {} - /** - * {@inheritDoc} - */ public function handle(ServerRequestInterface $request, array $headers, Deferred $resolver): void { $result = []; @@ -57,10 +41,6 @@ public function handle(ServerRequestInterface $request, array $headers, Deferred $resolver->resolve(EncodedValues::fromValues($result)); } - /** - * @param WorkerInterface $worker - * @return array - */ private function workerToArray(WorkerInterface $worker): array { $workflowMap = static fn(WorkflowPrototype $workflow): array => [ @@ -82,15 +62,10 @@ private function workerToArray(WorkerInterface $worker): array // ActivityInfo[] 'Activities' => $this->map($worker->getActivities(), $activityMap), 'PhpSdkVersion' => SdkVersion::getSdkVersion(), - 'Flags' => (object) [], + 'Flags' => (object) $this->prepareFlags(), ]; } - /** - * @param iterable $items - * @param \Closure $map - * @return array - */ private function map(iterable $items, \Closure $map): array { $result = []; @@ -101,4 +76,14 @@ private function map(iterable $items, \Closure $map): array return $result; } + + /** + * @return array + */ + private function prepareFlags(): array + { + return [ + 'ApiKey' => $this->credentials->apiKey, + ]; + } } diff --git a/src/Internal/Transport/Router/InvokeActivity.php b/src/Internal/Transport/Router/InvokeActivity.php index 7d6e8056e..413ff0dee 100644 --- a/src/Internal/Transport/Router/InvokeActivity.php +++ b/src/Internal/Transport/Router/InvokeActivity.php @@ -36,11 +36,6 @@ class InvokeActivity extends Route private RPCConnectionInterface $rpc; private PipelineProvider $interceptorProvider; - /** - * @param ServiceContainer $services - * @param RPCConnectionInterface $rpc - * @param PipelineProvider $interceptorProvider - */ public function __construct( ServiceContainer $services, RPCConnectionInterface $rpc, @@ -51,9 +46,6 @@ public function __construct( $this->interceptorProvider = $interceptorProvider; } - /** - * {@inheritDoc} - */ public function handle(ServerRequestInterface $request, array $headers, Deferred $resolver): void { $options = $request->getOptions(); @@ -121,10 +113,6 @@ static function (ActivityInput $input) use ($handler, $context): mixed { } } - /** - * @param ActivityInfo $info - * @return ActivityPrototype - */ private function findDeclarationOrFail(ActivityInfo $info): ActivityPrototype { $activity = $this->services->activities->find($info->type->name); diff --git a/src/Internal/Transport/Router/InvokeQuery.php b/src/Internal/Transport/Router/InvokeQuery.php index 87a1fc8dc..ee1f9a628 100644 --- a/src/Internal/Transport/Router/InvokeQuery.php +++ b/src/Internal/Transport/Router/InvokeQuery.php @@ -28,15 +28,8 @@ final class InvokeQuery extends WorkflowProcessAwareRoute */ private const ERROR_QUERY_NOT_FOUND = 'unknown queryType %s. KnownQueryTypes=[%s]'; - /** - * @var LoopInterface - */ private LoopInterface $loop; - /** - * @param RepositoryInterface $running - * @param LoopInterface $loop - */ #[Pure] public function __construct( RepositoryInterface $running, @@ -47,9 +40,6 @@ public function __construct( parent::__construct($running); } - /** - * {@inheritDoc} - */ public function handle(ServerRequestInterface $request, array $headers, Deferred $resolver): void { /** @var non-empty-string $name */ @@ -75,7 +65,7 @@ static function () use ($name, $request, $resolver, $handler, $context, $headers /** @psalm-suppress InaccessibleProperty */ $info->shouldContinueAsNew = $tickInfo->continueAsNewSuggested; - $result = $handler(new QueryInput($name, $request->getPayloads())); + $result = $handler(new QueryInput($name, $request->getPayloads(), $info)); $resolver->resolve(EncodedValues::fromValues([$result])); } catch (\Throwable $e) { $resolver->reject($e); @@ -85,7 +75,6 @@ static function () use ($name, $request, $resolver, $handler, $context, $headers } /** - * @param WorkflowInstanceInterface $instance * @param non-empty-string $name * @return \Closure(QueryInput): mixed */ diff --git a/src/Internal/Transport/Router/InvokeSignal.php b/src/Internal/Transport/Router/InvokeSignal.php index 8a333a5e6..e0b598d16 100644 --- a/src/Internal/Transport/Router/InvokeSignal.php +++ b/src/Internal/Transport/Router/InvokeSignal.php @@ -17,9 +17,6 @@ final class InvokeSignal extends WorkflowProcessAwareRoute { - /** - * {@inheritDoc} - */ public function handle(ServerRequestInterface $request, array $headers, Deferred $resolver): void { $instance = $this->findInstanceOrFail($request->getID()); diff --git a/src/Internal/Transport/Router/InvokeUpdate.php b/src/Internal/Transport/Router/InvokeUpdate.php index b7282cd25..802bbca9e 100644 --- a/src/Internal/Transport/Router/InvokeUpdate.php +++ b/src/Internal/Transport/Router/InvokeUpdate.php @@ -23,9 +23,6 @@ final class InvokeUpdate extends WorkflowProcessAwareRoute { private const ERROR_HANDLER_NOT_FOUND = 'unknown update method %s. KnownUpdateNames=[%s]'; - /** - * {@inheritDoc} - */ public function handle(ServerRequestInterface $request, array $headers, Deferred $resolver): void { $process = $this->findProcessOrFail($request->getID()); @@ -55,6 +52,7 @@ public function handle(ServerRequestInterface $request, array $headers, Deferred info: $context->getInfo(), arguments: $request->getPayloads(), header: $request->getHeader(), + isReplaying: $context->isReplaying(), ); // Validation diff --git a/src/Internal/Transport/Router/StackTrace.php b/src/Internal/Transport/Router/StackTrace.php index b66f76e48..7c305c4aa 100644 --- a/src/Internal/Transport/Router/StackTrace.php +++ b/src/Internal/Transport/Router/StackTrace.php @@ -17,9 +17,6 @@ final class StackTrace extends WorkflowProcessAwareRoute { - /** - * {@inheritDoc} - */ public function handle(ServerRequestInterface $request, array $headers, Deferred $resolver): void { $process = $this->findProcessOrFail($request->getID()); diff --git a/src/Internal/Transport/Router/StartWorkflow.php b/src/Internal/Transport/Router/StartWorkflow.php index d24608d59..99f968355 100644 --- a/src/Internal/Transport/Router/StartWorkflow.php +++ b/src/Internal/Transport/Router/StartWorkflow.php @@ -112,7 +112,12 @@ public function handle(ServerRequestInterface $request, array $headers, Deferred /** @see WorkflowInboundCallsInterceptor::execute() */ 'execute', )( - new WorkflowInput($context->getInfo(), $context->getInput(), $context->getHeader()), + new WorkflowInput( + $context->getInfo(), + $context->getInput(), + $context->getHeader(), + $context->isReplaying(), + ), ); } diff --git a/src/Internal/Transport/RouterInterface.php b/src/Internal/Transport/RouterInterface.php index 1a732afe4..223f2fbf8 100644 --- a/src/Internal/Transport/RouterInterface.php +++ b/src/Internal/Transport/RouterInterface.php @@ -17,20 +17,9 @@ interface RouterInterface extends DispatcherInterface { - /** - * @param RouteInterface $route - * @param bool $overwrite - */ public function add(RouteInterface $route, bool $overwrite = false): void; - /** - * @param ServerRequestInterface $route - */ public function remove(ServerRequestInterface $route): void; - /** - * @param ServerRequestInterface $request - * @return RouteInterface|null - */ public function match(ServerRequestInterface $request): ?RouteInterface; } diff --git a/src/Internal/Transport/Server.php b/src/Internal/Transport/Server.php index b8a3e401a..9926f9fec 100644 --- a/src/Internal/Transport/Server.php +++ b/src/Internal/Transport/Server.php @@ -35,8 +35,6 @@ final class Server implements ServerInterface /** * @psalm-param OnMessageHandler $onMessage - * @param QueueInterface $queue - * @param callable $onMessage */ public function __construct(QueueInterface $queue, callable $onMessage) { @@ -45,9 +43,6 @@ public function __construct(QueueInterface $queue, callable $onMessage) $this->onMessage($onMessage); } - /** - * {@inheritDoc} - */ public function onMessage(callable $then): void { $this->onMessage = $then(...); @@ -55,7 +50,6 @@ public function onMessage(callable $then): void /** * @param RequestInterface $request - * @param array $headers */ public function dispatch(ServerRequestInterface $request, array $headers): void { diff --git a/src/Internal/Transport/ServerInterface.php b/src/Internal/Transport/ServerInterface.php index fce538c8c..0d1dad707 100644 --- a/src/Internal/Transport/ServerInterface.php +++ b/src/Internal/Transport/ServerInterface.php @@ -24,7 +24,6 @@ interface ServerInterface { /** * @psalm-param OnMessageHandler $then - * @param callable $then */ public function onMessage(callable $then): void; } diff --git a/src/Internal/Workflow/ActivityProxy.php b/src/Internal/Workflow/ActivityProxy.php index c529dfca4..22528988d 100644 --- a/src/Internal/Workflow/ActivityProxy.php +++ b/src/Internal/Workflow/ActivityProxy.php @@ -35,26 +35,12 @@ final class ActivityProxy extends Proxy */ private array $activities; - /** - * @var string - */ private string $class; - - /** - * @var ActivityOptionsInterface - */ private ActivityOptionsInterface $options; - - /** - * @var WorkflowContextInterface - */ private WorkflowContextInterface $ctx; /** - * @param string $class * @param array $activities - * @param ActivityOptionsInterface $options - * @param WorkflowContextInterface $ctx * @param Pipeline $callsInterceptor */ public function __construct( @@ -71,8 +57,6 @@ public function __construct( } /** - * @param string $method - * @param array $args * @return CompletableResultInterface */ public function __call(string $method, array $args = []): PromiseInterface @@ -119,10 +103,6 @@ public function __call(string $method, array $args = []): PromiseInterface ); } - /** - * @param string $name - * @return ActivityPrototype - */ private function findPrototypeByHandlerNameOrFail(string $name): ActivityPrototype { $prototype = $this->findPrototypeByHandlerName($this->activities, $name); diff --git a/src/Internal/Workflow/ActivityStub.php b/src/Internal/Workflow/ActivityStub.php index 09d3e5a17..980455f03 100644 --- a/src/Internal/Workflow/ActivityStub.php +++ b/src/Internal/Workflow/ActivityStub.php @@ -34,8 +34,6 @@ final class ActivityStub implements ActivityStubInterface /** * @param MarshallerInterface $marshaller - * @param ActivityOptionsInterface $options - * @param HeaderInterface|array $header */ public function __construct( MarshallerInterface $marshaller, @@ -47,29 +45,20 @@ public function __construct( $this->header = \is_array($header) ? Header::fromValues($header) : $header; } - /** - * {@inheritDoc} - */ public function getOptions(): ActivityOptionsInterface { return $this->options; } - /** - * @return array - */ public function getOptionsArray(): array { return $this->marshaller->marshal($this->getOptions()); } - /** - * {@inheritDoc} - */ public function execute( string $name, array $args = [], - Type|string|\ReflectionClass|\ReflectionType $returnType = null, + Type|string|\ReflectionClass|\ReflectionType|null $returnType = null, bool $isLocalActivity = false, ): PromiseInterface { $request = $isLocalActivity ? @@ -79,10 +68,6 @@ public function execute( return EncodedValues::decodePromise($this->request($request), $returnType); } - /** - * @param RequestInterface $request - * @return PromiseInterface - */ protected function request(RequestInterface $request): PromiseInterface { /** @var Workflow\WorkflowContextInterface $context */ diff --git a/src/Internal/Workflow/ChildWorkflowProxy.php b/src/Internal/Workflow/ChildWorkflowProxy.php index 4410db93e..04ac4dc47 100644 --- a/src/Internal/Workflow/ChildWorkflowProxy.php +++ b/src/Internal/Workflow/ChildWorkflowProxy.php @@ -44,7 +44,6 @@ public function __construct( /** * @param non-empty-string $method - * @param array $args * @return CompletableResultInterface */ public function __call(string $method, array $args): PromiseInterface @@ -102,10 +101,6 @@ public function __call(string $method, array $args): PromiseInterface ); } - /** - * @param WorkflowPrototype $prototype - * @return Type|null - */ private function resolveReturnType(WorkflowPrototype $prototype): ?Type { if ($attribute = $prototype->getReturnType()) { diff --git a/src/Internal/Workflow/ChildWorkflowStub.php b/src/Internal/Workflow/ChildWorkflowStub.php index c8733bf4f..36514ec51 100644 --- a/src/Internal/Workflow/ChildWorkflowStub.php +++ b/src/Internal/Workflow/ChildWorkflowStub.php @@ -36,9 +36,6 @@ final class ChildWorkflowStub implements ChildWorkflowStubInterface /** * @param MarshallerInterface $marshaller - * @param string $workflow - * @param ChildWorkflowOptions $options - * @param HeaderInterface|array $header */ public function __construct( private readonly MarshallerInterface $marshaller, @@ -50,17 +47,11 @@ public function __construct( $this->header = \is_array($header) ? Header::fromValues($header) : $header; } - /** - * @return string - */ public function getChildWorkflowType(): string { return $this->workflow; } - /** - * @return PromiseInterface - */ public function getExecution(): PromiseInterface { return $this->execution->promise(); @@ -99,25 +90,16 @@ public function getResult($returnType = null): PromiseInterface return EncodedValues::decodePromise($this->result, $returnType); } - /** - * {@inheritDoc} - */ public function execute(array $args = [], $returnType = null): PromiseInterface { return $this->start(...$args)->then(fn() => $this->getResult($returnType)); } - /** - * @return ChildWorkflowOptions - */ public function getOptions(): ChildWorkflowOptions { return $this->options; } - /** - * {@inheritDoc} - */ public function signal(string $name, array $args = []): PromiseInterface { return $this->execution->promise()->then( @@ -136,10 +118,6 @@ function (WorkflowExecution $execution) use ($name, $args) { ); } - /** - * @param RequestInterface $request - * @return PromiseInterface - */ protected function request(RequestInterface $request): PromiseInterface { /** @var Workflow\WorkflowContextInterface $context */ @@ -148,9 +126,6 @@ protected function request(RequestInterface $request): PromiseInterface return $context->request($request); } - /** - * @return array - */ private function getOptionArray(): array { return $this->marshaller->marshal($this->getOptions()); diff --git a/src/Internal/Workflow/ContinueAsNewProxy.php b/src/Internal/Workflow/ContinueAsNewProxy.php index 3c3949936..3f8c23f67 100644 --- a/src/Internal/Workflow/ContinueAsNewProxy.php +++ b/src/Internal/Workflow/ContinueAsNewProxy.php @@ -31,37 +31,12 @@ class ContinueAsNewProxy extends Proxy private const ERROR_ALREADY_CONTINUED = 'Workflow "%s" has already been called within this "continue as new" stub'; - /** - * @var string - */ private string $class; - - /** - * @var WorkflowPrototype - */ private WorkflowPrototype $workflow; - - /** - * @var ContinueAsNewOptions - */ private ContinueAsNewOptions $options; - - /** - * @var WorkflowContextInterface - */ private WorkflowContextInterface $context; - - /** - * @var bool - */ private bool $isContinued = false; - /** - * @param string $class - * @param WorkflowPrototype $workflow - * @param ContinueAsNewOptions $options - * @param WorkflowContextInterface $context - */ public function __construct( string $class, WorkflowPrototype $workflow, @@ -75,8 +50,6 @@ public function __construct( } /** - * @param string $method - * @param array $args * @return PromiseInterface */ public function __call(string $method, array $args) @@ -104,9 +77,6 @@ public function __call(string $method, array $args) return $this->context->continueAsNew($this->workflow->getID(), $args, $this->options); } - /** - * @return bool - */ private function isContinued(): bool { return $this->isContinued; diff --git a/src/Internal/Workflow/ExternalWorkflowProxy.php b/src/Internal/Workflow/ExternalWorkflowProxy.php index 91f511c8e..916e3391e 100644 --- a/src/Internal/Workflow/ExternalWorkflowProxy.php +++ b/src/Internal/Workflow/ExternalWorkflowProxy.php @@ -31,20 +31,11 @@ class ExternalWorkflowProxy extends Proxy */ private string $class; - /** - * @var WorkflowPrototype - */ private WorkflowPrototype $workflow; - - /** - * @var ExternalWorkflowStubInterface - */ private ExternalWorkflowStubInterface $stub; /** * @param class-string $class - * @param WorkflowPrototype $workflow - * @param ExternalWorkflowStubInterface $stub */ public function __construct(string $class, WorkflowPrototype $workflow, ExternalWorkflowStubInterface $stub) { @@ -53,11 +44,6 @@ public function __construct(string $class, WorkflowPrototype $workflow, External $this->stub = $stub; } - /** - * @param string $method - * @param array $args - * @return PromiseInterface - */ public function __call(string $method, array $args): PromiseInterface { foreach ($this->workflow->getSignalHandlers() as $name => $definition) { diff --git a/src/Internal/Workflow/ExternalWorkflowStub.php b/src/Internal/Workflow/ExternalWorkflowStub.php index a8d3af5a3..9f047fb7f 100644 --- a/src/Internal/Workflow/ExternalWorkflowStub.php +++ b/src/Internal/Workflow/ExternalWorkflowStub.php @@ -27,7 +27,6 @@ final class ExternalWorkflowStub implements ExternalWorkflowStubInterface { /** - * @param WorkflowExecution $execution * @param Pipeline $callsInterceptor */ public function __construct( @@ -35,17 +34,11 @@ public function __construct( private Pipeline $callsInterceptor, ) {} - /** - * {@inheritDoc} - */ public function getExecution(): WorkflowExecution { return $this->execution; } - /** - * {@inheritDoc} - */ public function signal(string $name, array $args = []): PromiseInterface { return $this->callsInterceptor->with( @@ -71,9 +64,6 @@ public function signal(string $name, array $args = []): PromiseInterface )); } - /** - * {@inheritDoc} - */ public function cancel(): PromiseInterface { return $this->callsInterceptor->with( @@ -84,10 +74,6 @@ public function cancel(): PromiseInterface )(new CancelExternalWorkflowInput('', $this->execution->getID(), $this->execution->getRunID())); } - /** - * @param RequestInterface $request - * @return PromiseInterface - */ private function request(RequestInterface $request): PromiseInterface { // todo intercept diff --git a/src/Internal/Workflow/Input.php b/src/Internal/Workflow/Input.php index ee58a36dc..00f4fd9d8 100644 --- a/src/Internal/Workflow/Input.php +++ b/src/Internal/Workflow/Input.php @@ -23,7 +23,6 @@ final class Input { /** - * @var WorkflowInfo * @psalm-readonly */ #[Marshal(name: 'info')] @@ -31,7 +30,6 @@ final class Input public WorkflowInfo $info; /** - * @var ValuesInterface * @psalm-readonly */ #[Immutable] @@ -43,11 +41,7 @@ final class Input #[Immutable] public Header $header; - /** - * @param WorkflowInfo|null $info - * @param ValuesInterface|null $args - */ - public function __construct(WorkflowInfo $info = null, ValuesInterface $args = null, HeaderInterface $header = null) + public function __construct(?WorkflowInfo $info = null, ?ValuesInterface $args = null, ?HeaderInterface $header = null) { $this->info = $info ?? new WorkflowInfo(); $this->input = $args ?? EncodedValues::empty(); diff --git a/src/Internal/Workflow/Process/DeferredGenerator.php b/src/Internal/Workflow/Process/DeferredGenerator.php index 880732341..17d4a40cc 100644 --- a/src/Internal/Workflow/Process/DeferredGenerator.php +++ b/src/Internal/Workflow/Process/DeferredGenerator.php @@ -18,9 +18,6 @@ final class DeferredGenerator implements \Iterator { private bool $started = false; private bool $finished = false; - private mixed $key = null; - private mixed $value = null; - private mixed $result = null; private \Generator $generator; /** @var array<\Closure(\Throwable): mixed> */ @@ -50,7 +47,6 @@ public static function fromGenerator(\Generator $generator): self $self = new self(); $self->generator = $generator; $self->started = true; - $self->fill(); return $self; } @@ -67,7 +63,6 @@ public function throw(\Throwable $exception): void ); try { $this->generator->throw($exception); - $this->fill(); } catch (\Throwable $e) { $this->handleException($e); } @@ -80,15 +75,12 @@ public function throw(\Throwable $exception): void */ public function send(mixed $value): mixed { - $this->started or throw new \LogicException('Cannot send value to a generator that was not started.'); + $this->start(); $this->finished and throw new \LogicException('Cannot send value to a generator that was already finished.'); try { - $result = $this->generator->send($value); - $this->fill(); - return $result; + return $this->generator->send($value); } catch (\Throwable $e) { $this->handleException($e); - return null; } } @@ -97,8 +89,12 @@ public function send(mixed $value): mixed */ public function getReturn(): mixed { - $this->finished or throw new \LogicException('Cannot get return value of a generator that was not finished.'); - return $this->result; + // $this->start(); + try { + return $this->generator->getReturn(); + } catch (\Throwable $e) { + $this->handleException($e); + } } /** @@ -107,7 +103,11 @@ public function getReturn(): mixed public function current(): mixed { $this->start(); - return $this->value; + try { + return $this->generator->current(); + } catch (\Throwable $e) { + $this->handleException($e); + } } /** @@ -116,7 +116,11 @@ public function current(): mixed public function key(): mixed { $this->start(); - return $this->key; + try { + return $this->generator->key(); + } catch (\Throwable $e) { + $this->handleException($e); + } } /** @@ -131,7 +135,6 @@ public function next(): void try { $this->generator->next(); - $this->fill(); } catch (\Throwable $e) { $this->handleException($e); } @@ -145,12 +148,16 @@ public function next(): void public function valid(): bool { $this->start(); - return !$this->finished; + try { + return $this->generator->valid(); + } catch (\Throwable $e) { + $this->handleException($e); + } } public function rewind(): void { - $this->started and throw new \LogicException('Cannot rewind a generator that was already run.'); + $this->generator->rewind(); } /** @@ -164,6 +171,20 @@ public function catch(callable $handler): self return $this; } + private static function getDummyGenerator(): \Generator + { + static $generator; + + if ($generator === null) { + $generator = (static function (): \Generator { + yield; + })(); + $generator->current(); + } + + return $generator; + } + private function start(): void { if ($this->started) { @@ -176,33 +197,36 @@ private function start(): void if ($result instanceof \Generator) { $this->generator = $result; - $this->fill(); return; } - $this->result = $result; + /** @psalm-suppress all */ + $this->generator = (static function (mixed $result): \Generator { + return $result; + yield; + })($result); $this->finished = true; } catch (\Throwable $e) { + $this->generator = self::getDummyGenerator(); $this->handleException($e); } finally { unset($this->handler, $this->values); } } - private function fill(): void + private function handleException(\Throwable $e): never { - $this->key = $this->generator->key(); - $this->value = $this->generator->current(); - $this->finished = !$this->generator->valid() and $this->result = $this->generator->getReturn(); - } - - private function handleException(\Throwable $e): void - { - $this->key = null; - $this->value = null; + $this->finished and throw $e; $this->finished = true; foreach ($this->catchers as $catch) { - $catch($e); + try { + $catch($e); + } catch (\Throwable) { + // Do nothing. + } } + + $this->catchers = []; + throw $e; } } diff --git a/src/Internal/Workflow/Process/Process.php b/src/Internal/Workflow/Process/Process.php index bbf30e9aa..29cdca489 100644 --- a/src/Internal/Workflow/Process/Process.php +++ b/src/Internal/Workflow/Process/Process.php @@ -155,6 +155,7 @@ function (?\Throwable $error): void { $this->scopeContext->getInfo(), $arguments, $this->scopeContext->getHeader(), + $this->scopeContext->isReplaying(), )); }, ); diff --git a/src/Internal/Workflow/Process/Scope.php b/src/Internal/Workflow/Process/Scope.php index 105e70441..eb961f758 100644 --- a/src/Internal/Workflow/Process/Scope.php +++ b/src/Internal/Workflow/Process/Scope.php @@ -39,28 +39,20 @@ */ class Scope implements CancellationScopeInterface, Destroyable { - /** - * @var ServiceContainer - */ protected ServiceContainer $services; /** * Workflow context. * - * @var WorkflowContext */ protected WorkflowContext $context; /** * Coroutine scope context. * - * @var ScopeContext */ protected ScopeContext $scopeContext; - /** - * @var Deferred - */ protected Deferred $deferred; /** @@ -139,7 +131,8 @@ public function getContext(): WorkflowContext public function start(\Closure $handler, ?ValuesInterface $values, bool $deferred): void { // Create a coroutine generator - $this->coroutine = $this->call($handler, $values ?? EncodedValues::empty()); + $this->coroutine = DeferredGenerator::fromHandler($handler, $values ?? EncodedValues::empty()) + ->catch($this->onException(...)); $deferred ? $this->services->loop->once($this->layer, $this->next(...)) @@ -174,7 +167,6 @@ function (\Throwable $error) use ($resolver): void { } /** - * @param callable $handler * @param non-empty-string $name */ public function startSignal(callable $handler, ValuesInterface $values, string $name): void @@ -218,9 +210,6 @@ public function onClose(callable $then): self return $this; } - /** - * @param \Throwable|null $reason - */ public function cancel(?\Throwable $reason = null): void { if ($this->detached && !$reason instanceof DestructMemorizedInstanceException) { @@ -243,7 +232,7 @@ public function cancel(?\Throwable $reason = null): void /** * @param non-empty-string|null $layer */ - public function startScope(callable $handler, bool $detached, string $layer = null): CancellationScopeInterface + public function startScope(callable $handler, bool $detached, ?string $layer = null): CancellationScopeInterface { $scope = $this->createScope($detached, $layer); $scope->start($handler, null, false); @@ -257,9 +246,9 @@ public function promise(): PromiseInterface } public function then( - callable $onFulfilled = null, - callable $onRejected = null, - callable $onProgress = null, + ?callable $onFulfilled = null, + ?callable $onRejected = null, + ?callable $onProgress = null, ): PromiseInterface { return $this->deferred->promise()->then($onFulfilled, $onRejected); } @@ -287,7 +276,6 @@ public function always(callable $onFulfilledOrRejected): PromiseInterface /** * Connects promise to scope context to be cancelled on promise cancel. * - * @param Deferred $deferred */ public function onAwait(Deferred $deferred): void { @@ -321,7 +309,7 @@ public function destroy(): void protected function createScope( bool $detached, ?string $layer = null, - WorkflowContext $context = null, + ?WorkflowContext $context = null, ?Workflow\UpdateContext $updateContext = null, ): self { $scope = new Scope($this->services, $context ?? $this->context, $updateContext); @@ -343,14 +331,6 @@ function () use ($cancelID): void { return $scope; } - /** - * @param \Closure(ValuesInterface): mixed $handler - */ - protected function call(\Closure $handler, ValuesInterface $values): DeferredGenerator - { - return DeferredGenerator::fromHandler($handler, $values)->catch($this->onException(...)); - } - /** * Call a Signal or Update method. In this case deserialization errors are skipped. * @@ -368,10 +348,6 @@ protected function callSignalOrUpdateHandler(callable $handler, ValuesInterface }, $values)->catch($this->onException(...)); } - /** - * @param RequestInterface $request - * @param PromiseInterface $promise - */ protected function onRequest(RequestInterface $request, PromiseInterface $promise): void { $this->onCancel[++$this->cancelID] = function (?\Throwable $reason = null) use ($request): void { @@ -402,17 +378,11 @@ protected function onRequest(RequestInterface $request, PromiseInterface $promis $promise->then($cleanup, $cleanup); } - /** - * @return void - */ protected function makeCurrent(): void { Workflow::setCurrentContext($this->scopeContext); } - /** - * @return void - */ protected function next(): void { $this->makeCurrent(); @@ -420,7 +390,11 @@ protected function next(): void $this->context->resolveConditions(); if (!$this->coroutine->valid()) { - $this->onResult($this->coroutine->getReturn()); + try { + $this->onResult($this->coroutine->getReturn()); + } catch (\Throwable) { + $this->onResult(null); + } return; } @@ -455,7 +429,11 @@ protected function next(): void break; default: - $this->coroutine->send($current); + try { + $this->coroutine->send($current); + } catch (\Throwable) { + // Ignore + } goto begin; } } @@ -523,9 +501,6 @@ private function handleError(\Throwable $e): void $this->next(); } - /** - * @param \Throwable $e - */ private function onException(\Throwable $e): void { $this->deferred->reject($e); @@ -538,9 +513,6 @@ private function onException(\Throwable $e): void } } - /** - * @param mixed $result - */ private function onResult(mixed $result): void { $this->deferred->resolve($result); diff --git a/src/Internal/Workflow/ProcessCollection.php b/src/Internal/Workflow/ProcessCollection.php index 344ab782a..3727f0e90 100644 --- a/src/Internal/Workflow/ProcessCollection.php +++ b/src/Internal/Workflow/ProcessCollection.php @@ -22,9 +22,7 @@ class ProcessCollection extends ArrayRepository private const ERROR_PROCESS_NOT_FOUND = 'Process #%s not found.'; /** - * @param string $runId * @param non-empty-string|null $error Error message if the process was not found. - * @return Process */ public function pull(string $runId, ?string $error = null): Process { diff --git a/src/Internal/Workflow/Proxy.php b/src/Internal/Workflow/Proxy.php index fbdedae85..bb3aef8e8 100644 --- a/src/Internal/Workflow/Proxy.php +++ b/src/Internal/Workflow/Proxy.php @@ -15,17 +15,12 @@ abstract class Proxy { - /** - * @param string $method - * @param array $args - */ abstract public function __call(string $method, array $args); /** * @psalm-template T of Prototype * * @param array $prototypes - * @param string $name * @return T|null */ protected function findPrototypeByHandlerName(array $prototypes, string $name): ?Prototype diff --git a/src/Internal/Workflow/WorkflowContext.php b/src/Internal/Workflow/WorkflowContext.php index 23c4bf3fd..d42d4d28e 100644 --- a/src/Internal/Workflow/WorkflowContext.php +++ b/src/Internal/Workflow/WorkflowContext.php @@ -103,49 +103,31 @@ public function __construct( ->getPipeline(WorkflowOutboundCallsInterceptor::class); } - /** - * @return WorkflowInstanceInterface - */ public function getWorkflowInstance(): WorkflowInstanceInterface { return $this->workflowInstance; } - /** - * {@inheritDoc} - */ public function now(): \DateTimeInterface { return $this->services->env->now(); } - /** - * @return string - */ public function getRunId(): string { return $this->input->info->execution->getRunID(); } - /** - * {@inheritDoc} - */ public function getInfo(): WorkflowInfo { return $this->input->info; } - /** - * @inheritDoc - */ public function getHeader(): HeaderInterface { return $this->input->header; } - /** - * {@inheritDoc} - */ public function getInput(): ValuesInterface { return $this->input->input; @@ -160,9 +142,6 @@ public function withInput(Input $input): static return $clone; } - /** - * @return ValuesInterface|null - */ public function getLastCompletionResultValues(): ?ValuesInterface { return $this->lastCompletionResult; @@ -183,17 +162,11 @@ public function getLastCompletionResult($type = null) return $this->lastCompletionResult->getValue(0, $type); } - /** - * @return ClientInterface - */ public function getClient(): ClientInterface { return $this->client; } - /** - * {@inheritDoc} - */ public function registerQuery(string $queryType, callable $handler): WorkflowContextInterface { $this->getWorkflowInstance()->addQueryHandler($queryType, $handler); @@ -201,9 +174,6 @@ public function registerQuery(string $queryType, callable $handler): WorkflowCon return $this; } - /** - * {@inheritDoc} - */ public function registerSignal(string $queryType, callable $handler): WorkflowContextInterface { $this->getWorkflowInstance()->addSignalHandler($queryType, $handler); @@ -211,9 +181,6 @@ public function registerSignal(string $queryType, callable $handler): WorkflowCo return $this; } - /** - * {@inheritDoc} - */ public function registerUpdate(string $name, callable $handler, ?callable $validator): static { $this->getWorkflowInstance()->addUpdateHandler($name, $handler); @@ -222,9 +189,6 @@ public function registerUpdate(string $name, callable $handler, ?callable $valid return $this; } - /** - * {@inheritDoc} - */ public function getVersion(string $changeId, int $minSupported, int $maxSupported): PromiseInterface { return $this->callsInterceptor->with( @@ -237,9 +201,6 @@ public function getVersion(string $changeId, int $minSupported, int $maxSupporte )(new GetVersionInput($changeId, $minSupported, $maxSupported)); } - /** - * {@inheritDoc} - */ public function sideEffect(callable $context): PromiseInterface { $value = null; @@ -271,18 +232,12 @@ public function sideEffect(callable $context): PromiseInterface return $last(); } - /** - * {@inheritDoc} - */ public function isReplaying(): bool { return $this->services->env->isReplaying(); } - /** - * {@inheritDoc} - */ - public function complete(array $result = null, \Throwable $failure = null): PromiseInterface + public function complete(?array $result = null, ?\Throwable $failure = null): PromiseInterface { if ($failure !== null) { $this->workflowInstance->clearSignalQueue(); @@ -301,10 +256,7 @@ function (CompleteInput $input): PromiseInterface { )(new CompleteInput($result, $failure)); } - /** - * {@inheritDoc} - */ - public function panic(\Throwable $failure = null): PromiseInterface + public function panic(?\Throwable $failure = null): PromiseInterface { return $this->callsInterceptor->with( fn(PanicInput $failure): PromiseInterface => $this->request(new Panic($failure->failure), false), @@ -313,13 +265,10 @@ public function panic(\Throwable $failure = null): PromiseInterface )(new PanicInput($failure)); } - /** - * {@inheritDoc} - */ public function continueAsNew( string $type, array $args = [], - ContinueAsNewOptions $options = null, + ?ContinueAsNewOptions $options = null, ): PromiseInterface { return $this->callsInterceptor->with( function (ContinueAsNewInput $input): PromiseInterface { @@ -340,10 +289,7 @@ function (ContinueAsNewInput $input): PromiseInterface { )(new ContinueAsNewInput($type, $args, $options)); } - /** - * {@inheritDoc} - */ - public function newContinueAsNewStub(string $class, ContinueAsNewOptions $options = null): object + public function newContinueAsNewStub(string $class, ?ContinueAsNewOptions $options = null): object { $options ??= new ContinueAsNewOptions(); @@ -352,21 +298,15 @@ public function newContinueAsNewStub(string $class, ContinueAsNewOptions $option return new ContinueAsNewProxy($class, $workflow, $options, $this); } - /** - * @return bool - */ public function isContinuedAsNew(): bool { return $this->continueAsNew; } - /** - * {@inheritDoc} - */ public function executeChildWorkflow( string $type, array $args = [], - ChildWorkflowOptions $options = null, + ?ChildWorkflowOptions $options = null, mixed $returnType = null, ): PromiseInterface { return $this->callsInterceptor->with( @@ -378,24 +318,18 @@ public function executeChildWorkflow( )(new ExecuteChildWorkflowInput($type, $args, $options, $returnType)); } - /** - * {@inheritDoc} - */ public function newUntypedChildWorkflowStub( string $type, - ChildWorkflowOptions $options = null, + ?ChildWorkflowOptions $options = null, ): ChildWorkflowStubInterface { $options ??= new ChildWorkflowOptions(); return new ChildWorkflowStub($this->services->marshaller, $type, $options, $this->getHeader()); } - /** - * {@inheritDoc} - */ public function newChildWorkflowStub( string $class, - ChildWorkflowOptions $options = null, + ?ChildWorkflowOptions $options = null, ): object { $workflow = $this->services->workflowsReader->fromClass($class); $options = $options ?? (new ChildWorkflowOptions()) @@ -409,9 +343,6 @@ public function newChildWorkflowStub( ); } - /** - * {@inheritDoc} - */ public function newExternalWorkflowStub(string $class, WorkflowExecution $execution): object { $workflow = $this->services->workflowsReader->fromClass($class); @@ -421,22 +352,16 @@ public function newExternalWorkflowStub(string $class, WorkflowExecution $execut return new ExternalWorkflowProxy($class, $workflow, $stub); } - /** - * {@inheritDoc} - */ public function newUntypedExternalWorkflowStub(WorkflowExecution $execution): ExternalWorkflowStubInterface { return new ExternalWorkflowStub($execution, $this->callsInterceptor); } - /** - * {@inheritDoc} - */ public function executeActivity( string $type, array $args = [], - ActivityOptionsInterface $options = null, - Type|string|\ReflectionClass|\ReflectionType $returnType = null, + ?ActivityOptionsInterface $options = null, + Type|string|\ReflectionClass|\ReflectionType|null $returnType = null, ): PromiseInterface { $isLocal = $options instanceof LocalActivityOptions; @@ -457,23 +382,17 @@ public function executeActivity( )(new ExecuteActivityInput($type, $args, $options, $returnType)); } - /** - * {@inheritDoc} - */ public function newUntypedActivityStub( - ActivityOptionsInterface $options = null, + ?ActivityOptionsInterface $options = null, ): ActivityStubInterface { $options ??= new ActivityOptions(); return new ActivityStub($this->services->marshaller, $options, $this->getHeader()); } - /** - * {@inheritDoc} - */ public function newActivityStub( string $class, - ActivityOptionsInterface $options = null, + ?ActivityOptionsInterface $options = null, ): ActivityProxy { $activities = $this->services->activitiesReader->fromClass($class); @@ -490,9 +409,6 @@ public function newActivityStub( ); } - /** - * {@inheritDoc} - */ public function timer($interval): PromiseInterface { $dateInterval = DateInterval::parse($interval, DateInterval::FORMAT_SECONDS); @@ -504,9 +420,6 @@ public function timer($interval): PromiseInterface )(new TimerInput($dateInterval)); } - /** - * {@inheritDoc} - */ public function request(RequestInterface $request, bool $cancellable = true): PromiseInterface { $this->recordTrace(); @@ -521,25 +434,16 @@ function (RequestInterface $request): PromiseInterface { )($request); } - /** - * {@inheritDoc} - */ public function getStackTrace(): string { return StackRenderer::renderTrace($this->trace); } - /** - * {@inheritDoc} - */ public function allHandlersFinished(): bool { return !$this->handlers->hasRunningHandlers(); } - /** - * {@inheritDoc} - */ public function upsertSearchAttributes(array $searchAttributes): void { $this->callsInterceptor->with( @@ -550,9 +454,6 @@ public function upsertSearchAttributes(array $searchAttributes): void )(new UpsertSearchAttributesInput($searchAttributes)); } - /** - * {@inheritDoc} - */ public function await(callable|Mutex|PromiseInterface ...$conditions): PromiseInterface { return $this->callsInterceptor->with( @@ -562,9 +463,6 @@ public function await(callable|Mutex|PromiseInterface ...$conditions): PromiseIn )(new AwaitInput($conditions)); } - /** - * {@inheritDoc} - */ public function awaitWithTimeout($interval, callable|Mutex|PromiseInterface ...$conditions): PromiseInterface { $intervalObject = DateInterval::parse($interval, DateInterval::FORMAT_SECONDS); @@ -618,25 +516,16 @@ public function rejectConditionGroup(string $conditionGroupId): void unset($this->awaits[$conditionGroupId]); } - /** - * {@inheritDoc} - */ public function uuid(): PromiseInterface { return $this->sideEffect(static fn(): UuidInterface => \Ramsey\Uuid\Uuid::uuid4()); } - /** - * {@inheritDoc} - */ public function uuid4(): PromiseInterface { return $this->sideEffect(static fn(): UuidInterface => \Ramsey\Uuid\Uuid::uuid4()); } - /** - * {@inheritDoc} - */ public function uuid7(?\DateTimeInterface $dateTime = null): PromiseInterface { return $this->sideEffect(static fn(): UuidInterface => \Ramsey\Uuid\Uuid::uuid7($dateTime)); @@ -711,8 +600,6 @@ function ($reason) use ($conditionGroupId): void { /** * @param non-empty-string $conditionGroupId - * @param callable $condition - * @return PromiseInterface */ protected function addCondition(string $conditionGroupId, callable $condition): PromiseInterface { @@ -725,7 +612,6 @@ protected function addCondition(string $conditionGroupId, callable $condition): /** * Record last stack trace of the call. * - * @return void */ protected function recordTrace(): void { diff --git a/src/Promise.php b/src/Promise.php index 4ff55f80f..151303696 100644 --- a/src/Promise.php +++ b/src/Promise.php @@ -33,7 +33,6 @@ final class Promise * the resolution values of each item in `$promises`. * * @param iterable $promises - * @return PromiseInterface */ public static function all(iterable $promises): PromiseInterface { @@ -51,7 +50,6 @@ public static function all(iterable $promises): PromiseInterface * {@see LengthException}. * * @param iterable $promises - * @return PromiseInterface */ public static function any(iterable $promises): PromiseInterface { @@ -74,8 +72,6 @@ public static function any(iterable $promises): PromiseInterface * reject with a {@see LengthException}. * * @param iterable $promises - * @param int $count - * @return PromiseInterface */ public static function some(iterable $promises, int $count): PromiseInterface { @@ -159,8 +155,6 @@ static function (iterable $array) use ($count, $cancellationQueue, $resolve, $re * * @psalm-param PromiseMapCallback $map * @param iterable $promises - * @param callable $map - * @return PromiseInterface */ public static function map(iterable $promises, callable $map): PromiseInterface { @@ -213,7 +207,6 @@ static function (mixed $mapped) use ($i, &$values, &$toResolve, $resolve): void * @param iterable $promises * @param callable(mixed $current, mixed $carry, int $current, positive-int $items): mixed $reduce * @param mixed $initial - * @return PromiseInterface */ public static function reduce(iterable $promises, callable $reduce, $initial = null): PromiseInterface { @@ -280,8 +273,7 @@ static function (iterable $array) use ( * * If `$promiseOrValue` is a promise, it will be returned as is. * - * @param $promiseOrValue - * @return PromiseInterface + * @param null|mixed $promiseOrValue */ public static function resolve($promiseOrValue = null): PromiseInterface { @@ -301,7 +293,7 @@ public static function resolve($promiseOrValue = null): PromiseInterface * throwing an exception. For example, it allows you to propagate a rejection with * the value of another promise. * - * @param $promiseOrValue + * @param null|mixed $promiseOrValue * @return PromiseInterface */ public static function reject($promiseOrValue = null): PromiseInterface diff --git a/src/Worker/ActivityInvocationCache/ActivityInvocationResult.php b/src/Worker/ActivityInvocationCache/ActivityInvocationResult.php index 76b9f0244..6400c2a1b 100644 --- a/src/Worker/ActivityInvocationCache/ActivityInvocationResult.php +++ b/src/Worker/ActivityInvocationCache/ActivityInvocationResult.php @@ -20,7 +20,7 @@ public static function fromValue(mixed $value, ?DataConverterInterface $dataConv return new self($value->toPayloads()); } - public function toValue(Type|string $type = null, ?DataConverterInterface $dataConverter = null) + public function toValue(Type|string|null $type = null, ?DataConverterInterface $dataConverter = null) { return $this->toEncodedValues($dataConverter)->getValue(0, $type); } diff --git a/src/Worker/ActivityInvocationCache/InMemoryActivityInvocationCache.php b/src/Worker/ActivityInvocationCache/InMemoryActivityInvocationCache.php index f5e8442d2..0c1c7a864 100644 --- a/src/Worker/ActivityInvocationCache/InMemoryActivityInvocationCache.php +++ b/src/Worker/ActivityInvocationCache/InMemoryActivityInvocationCache.php @@ -21,7 +21,7 @@ final class InMemoryActivityInvocationCache implements ActivityInvocationCacheIn private DataConverterInterface $dataConverter; - public function __construct(DataConverterInterface $dataConverter = null) + public function __construct(?DataConverterInterface $dataConverter = null) { $this->dataConverter = $dataConverter ?? DataConverter::createDefault(); } diff --git a/src/Worker/ActivityInvocationCache/RoadRunnerActivityInvocationCache.php b/src/Worker/ActivityInvocationCache/RoadRunnerActivityInvocationCache.php index c9ab2a12b..d70f90833 100644 --- a/src/Worker/ActivityInvocationCache/RoadRunnerActivityInvocationCache.php +++ b/src/Worker/ActivityInvocationCache/RoadRunnerActivityInvocationCache.php @@ -24,13 +24,13 @@ final class RoadRunnerActivityInvocationCache implements ActivityInvocationCache private StorageInterface $cache; private DataConverterInterface $dataConverter; - public function __construct(string $host, string $cacheName, DataConverterInterface $dataConverter = null) + public function __construct(string $host, string $cacheName, ?DataConverterInterface $dataConverter = null) { $this->cache = (new Factory(RPC::create($host)))->select($cacheName); $this->dataConverter = $dataConverter ?? DataConverter::createDefault(); } - public static function create(DataConverterInterface $dataConverter = null): self + public static function create(?DataConverterInterface $dataConverter = null): self { $env = Environment::fromGlobals(); return new self($env->getRPCAddress(), self::CACHE_NAME, $dataConverter); diff --git a/src/Worker/DispatcherInterface.php b/src/Worker/DispatcherInterface.php index 7ad225fe9..958cc9f70 100644 --- a/src/Worker/DispatcherInterface.php +++ b/src/Worker/DispatcherInterface.php @@ -16,10 +16,5 @@ interface DispatcherInterface { - /** - * @param ServerRequestInterface $request - * @param array $headers - * @return PromiseInterface - */ public function dispatch(ServerRequestInterface $request, array $headers): PromiseInterface; } diff --git a/src/Worker/Environment/EnvironmentInterface.php b/src/Worker/Environment/EnvironmentInterface.php index dcba1824f..1ece33a7a 100644 --- a/src/Worker/Environment/EnvironmentInterface.php +++ b/src/Worker/Environment/EnvironmentInterface.php @@ -13,13 +13,7 @@ interface EnvironmentInterface { - /** - * @return \DateTimeInterface - */ public function now(): \DateTimeInterface; - /** - * @return bool - */ public function isReplaying(): bool; } diff --git a/src/Worker/ServiceCredentials.php b/src/Worker/ServiceCredentials.php new file mode 100644 index 000000000..536f72bfb --- /dev/null +++ b/src/Worker/ServiceCredentials.php @@ -0,0 +1,47 @@ +apiKey = ''; + } + + public static function create(): self + { + return new self(); + } + + /** + * Set the authentication token for API calls. + * + * To update the API key in runtime, call the `UpdateAPIKey` RPC method with the new key: + * + * $result = \Temporal\Worker\Transport\Goridge::create()->call( + * 'temporal.UpdateAPIKey', + * $newApiKey, + * ); + * + * @link https://docs.temporal.io/cloud/api-keys + * @since SDK 2.12.0 + * @since RoadRunner 2024.3.0 + */ + public function withApiKey(string $key): static + { + /** @see self::$apiKey */ + return $this->with('apiKey', $key); + } +} diff --git a/src/Worker/Transport/Codec/CodecInterface.php b/src/Worker/Transport/Codec/CodecInterface.php index d8cd18fc6..401b50b06 100644 --- a/src/Worker/Transport/Codec/CodecInterface.php +++ b/src/Worker/Transport/Codec/CodecInterface.php @@ -20,13 +20,11 @@ interface CodecInterface { /** * @param iterable $commands - * @return string * @throws ProtocolException */ public function encode(iterable $commands): string; /** - * @param string $batch * @return iterable * @throws ProtocolException */ diff --git a/src/Worker/Transport/Codec/JsonCodec.php b/src/Worker/Transport/Codec/JsonCodec.php index fc48ef298..730435e79 100644 --- a/src/Worker/Transport/Codec/JsonCodec.php +++ b/src/Worker/Transport/Codec/JsonCodec.php @@ -24,10 +24,6 @@ final class JsonCodec implements CodecInterface private Decoder $parser; private Encoder $serializer; - /** - * @param DataConverterInterface $dataConverter - * @param int $maxDepth - */ public function __construct(DataConverterInterface $dataConverter, int $maxDepth = 64) { $this->maxDepth = $maxDepth; @@ -36,9 +32,6 @@ public function __construct(DataConverterInterface $dataConverter, int $maxDepth $this->serializer = new Encoder($dataConverter); } - /** - * {@inheritDoc} - */ public function encode(iterable $commands): string { try { @@ -55,9 +48,6 @@ public function encode(iterable $commands): string } } - /** - * {@inheritDoc} - */ public function decode(string $batch, array $headers = []): iterable { static $tz = new \DateTimeZone('UTC'); diff --git a/src/Worker/Transport/Codec/JsonCodec/Encoder.php b/src/Worker/Transport/Codec/JsonCodec/Encoder.php index fd59fe386..aeb027254 100644 --- a/src/Worker/Transport/Codec/JsonCodec/Encoder.php +++ b/src/Worker/Transport/Codec/JsonCodec/Encoder.php @@ -25,9 +25,6 @@ class Encoder private DataConverterInterface $converter; - /** - * @param DataConverterInterface $dataConverter - */ public function __construct(DataConverterInterface $dataConverter) { $this->converter = $dataConverter; diff --git a/src/Worker/Transport/Codec/ProtoCodec.php b/src/Worker/Transport/Codec/ProtoCodec.php index 5a7ebffd9..007da6b78 100644 --- a/src/Worker/Transport/Codec/ProtoCodec.php +++ b/src/Worker/Transport/Codec/ProtoCodec.php @@ -25,28 +25,15 @@ */ final class ProtoCodec implements CodecInterface { - /** - * @var Decoder - */ private Decoder $parser; - - /** - * @var Encoder - */ private Encoder $encoder; - /** - * @param DataConverterInterface $dataConverter - */ public function __construct(DataConverterInterface $dataConverter) { $this->parser = new Decoder($dataConverter); $this->encoder = new Encoder($dataConverter); } - /** - * {@inheritDoc} - */ public function encode(iterable $commands): string { try { @@ -66,9 +53,6 @@ public function encode(iterable $commands): string } } - /** - * {@inheritDoc} - */ public function decode(string $batch, array $headers = []): iterable { static $tz = new \DateTimeZone('UTC'); diff --git a/src/Worker/Transport/Command/Client/Request.php b/src/Worker/Transport/Command/Client/Request.php index 44ac4083f..d39819961 100644 --- a/src/Worker/Transport/Command/Client/Request.php +++ b/src/Worker/Transport/Command/Client/Request.php @@ -40,7 +40,7 @@ class Request implements RequestInterface public function __construct( protected string $name, protected array $options = [], - ValuesInterface $payloads = null, + ?ValuesInterface $payloads = null, ?HeaderInterface $header = null, ) { $this->payloads = $payloads ?? EncodedValues::empty(); diff --git a/src/Worker/Transport/Command/Common/RequestTrait.php b/src/Worker/Transport/Command/Common/RequestTrait.php index 8a7752bcf..33815875c 100644 --- a/src/Worker/Transport/Command/Common/RequestTrait.php +++ b/src/Worker/Transport/Command/Common/RequestTrait.php @@ -25,9 +25,6 @@ public function getPayloads(): ValuesInterface return $this->payloads; } - /** - * @return Header - */ public function getHeader(): Header { return $this->header; diff --git a/src/Worker/Transport/Command/RequestInterface.php b/src/Worker/Transport/Command/RequestInterface.php index d7ef99601..d176a14a9 100644 --- a/src/Worker/Transport/Command/RequestInterface.php +++ b/src/Worker/Transport/Command/RequestInterface.php @@ -31,21 +31,14 @@ public function getName(): string; */ public function getOptions(): array; - /** - * @return ValuesInterface - */ public function getPayloads(): ValuesInterface; /** * Optional failure. * - * @return \Throwable|null */ public function getFailure(): ?\Throwable; - /** - * @return HeaderInterface - */ public function getHeader(): HeaderInterface; /** diff --git a/src/Worker/Transport/Command/SuccessResponseInterface.php b/src/Worker/Transport/Command/SuccessResponseInterface.php index 8bade9aa5..23197069a 100644 --- a/src/Worker/Transport/Command/SuccessResponseInterface.php +++ b/src/Worker/Transport/Command/SuccessResponseInterface.php @@ -15,8 +15,5 @@ interface SuccessResponseInterface extends CommandInterface { - /** - * @return ValuesInterface - */ public function getPayloads(): ValuesInterface; } diff --git a/src/Worker/Transport/CommandBatch.php b/src/Worker/Transport/CommandBatch.php index 0cf8e08e8..f2ca88561 100644 --- a/src/Worker/Transport/CommandBatch.php +++ b/src/Worker/Transport/CommandBatch.php @@ -19,10 +19,6 @@ final class CommandBatch public string $messages; public array $context; - /** - * @param string $messages - * @param array $context - */ public function __construct(string $messages, array $context) { $this->messages = $messages; diff --git a/src/Worker/Transport/Goridge.php b/src/Worker/Transport/Goridge.php index c188f298a..ce71ded71 100644 --- a/src/Worker/Transport/Goridge.php +++ b/src/Worker/Transport/Goridge.php @@ -24,19 +24,12 @@ final class Goridge implements RPCConnectionInterface { private RPCInterface $rpc; - /** - * @param RelayInterface $relay - */ public function __construct(RelayInterface $relay) { $this->rpc = new RPC($relay); } - /** - * @param EnvironmentInterface|null $env - * @return RPCConnectionInterface - */ - public static function create(EnvironmentInterface $env = null): RPCConnectionInterface + public static function create(?EnvironmentInterface $env = null): RPCConnectionInterface { $env ??= Environment::fromGlobals(); @@ -44,7 +37,6 @@ public static function create(EnvironmentInterface $env = null): RPCConnectionIn } /** - * @param string $method * @param mixed $payload * @return mixed * diff --git a/src/Worker/Transport/HostConnectionInterface.php b/src/Worker/Transport/HostConnectionInterface.php index 73b08e3df..afb58b889 100644 --- a/src/Worker/Transport/HostConnectionInterface.php +++ b/src/Worker/Transport/HostConnectionInterface.php @@ -19,19 +19,16 @@ interface HostConnectionInterface { /** - * @return CommandBatch|null * @throws TransportException */ public function waitBatch(): ?CommandBatch; /** - * @param string $frame * @throws TransportException */ public function send(string $frame): void; /** - * @param \Throwable $error * @throws TransportException */ public function error(\Throwable $error): void; diff --git a/src/Worker/Transport/RPCConnectionInterface.php b/src/Worker/Transport/RPCConnectionInterface.php index 59dfbdb4a..a5af6cba7 100644 --- a/src/Worker/Transport/RPCConnectionInterface.php +++ b/src/Worker/Transport/RPCConnectionInterface.php @@ -16,10 +16,8 @@ interface RPCConnectionInterface { /** - * @param string $method - * @param $payload + * @param mixed $payload * @return mixed - * * @throws TransportException */ public function call(string $method, $payload); diff --git a/src/Worker/Transport/RoadRunner.php b/src/Worker/Transport/RoadRunner.php index 8d57d8e28..955a214a3 100644 --- a/src/Worker/Transport/RoadRunner.php +++ b/src/Worker/Transport/RoadRunner.php @@ -39,22 +39,15 @@ final class RoadRunner implements HostConnectionInterface private RoadRunnerWorker $worker; private CodecInterface $codec; - /** - * @param RoadRunnerWorker $worker - */ public function __construct(RoadRunnerWorker $worker) { $this->worker = $worker; $this->codec = new JsonCodec(); } - /** - * @param EnvironmentInterface|null $env - * @return HostConnectionInterface - */ public static function create( - EnvironmentInterface $env = null, - RoadRunnerVersionChecker $versionChecker = null, + ?EnvironmentInterface $env = null, + ?RoadRunnerVersionChecker $versionChecker = null, ): HostConnectionInterface { $versionChecker ??= new RoadRunnerVersionChecker(); $versionChecker->check(); @@ -64,9 +57,6 @@ public static function create( return new self(new Worker(Relay::create($env->getRelayAddress()))); } - /** - * {@inheritDoc} - */ public function waitBatch(): ?CommandBatch { /** @var Payload $payload */ @@ -82,9 +72,6 @@ public function waitBatch(): ?CommandBatch ); } - /** - * {@inheritDoc} - */ public function send(string $frame, array $headers = []): void { $json = $this->encodeHeaders($headers); @@ -96,9 +83,6 @@ public function send(string $frame, array $headers = []): void } } - /** - * {@inheritDoc} - */ public function error(\Throwable $error): void { try { @@ -113,7 +97,7 @@ public function error(\Throwable $error): void * @return array * @throws ProtocolException */ - private function decodeHeaders(string $headers = null): array + private function decodeHeaders(?string $headers = null): array { if ($headers === null) { return []; diff --git a/src/Worker/Worker.php b/src/Worker/Worker.php index ea3697e03..956a9f67e 100644 --- a/src/Worker/Worker.php +++ b/src/Worker/Worker.php @@ -29,37 +29,12 @@ class Worker implements WorkerInterface, EventListenerInterface, DispatcherInter { use EventEmitterTrait; - /** - * @var string - */ private string $name; - - /** - * @var WorkerOptions - */ private WorkerOptions $options; - - /** - * @var RouterInterface - */ private RouterInterface $router; - - /** - * @var ServiceContainer - */ private ServiceContainer $services; - - /** - * @var RPCConnectionInterface - */ private RPCConnectionInterface $rpc; - /** - * @param string $taskQueue - * @param WorkerOptions $options - * @param ServiceContainer $serviceContainer - * @param RPCConnectionInterface $rpc - */ public function __construct( string $taskQueue, WorkerOptions $options, @@ -74,33 +49,21 @@ public function __construct( $this->router = $this->createRouter(); } - /** - * @return WorkerOptions - */ public function getOptions(): WorkerOptions { return $this->options; } - /** - * {@inheritDoc} - */ public function dispatch(ServerRequestInterface $request, array $headers): PromiseInterface { return $this->router->dispatch($request, $headers); } - /** - * {@inheritDoc} - */ public function getID(): string { return $this->name; } - /** - * {@inheritDoc} - */ public function registerWorkflowTypes(string ...$class): WorkerInterface { foreach ($class as $workflow) { @@ -111,17 +74,11 @@ public function registerWorkflowTypes(string ...$class): WorkerInterface return $this; } - /** - * {@inheritDoc} - */ public function getWorkflows(): RepositoryInterface { return $this->services->workflows; } - /** - * {@inheritDoc} - */ public function registerActivityImplementations(object ...$activity): WorkerInterface { foreach ($activity as $act) { @@ -131,7 +88,7 @@ public function registerActivityImplementations(object ...$activity): WorkerInte return $this; } - public function registerActivity(string $type, callable $factory = null): WorkerInterface + public function registerActivity(string $type, ?callable $factory = null): WorkerInterface { foreach ($this->services->activitiesReader->fromClass($type) as $proto) { if ($factory !== null) { @@ -150,17 +107,11 @@ public function registerActivityFinalizer(\Closure $finalizer): WorkerInterface return $this; } - /** - * {@inheritDoc} - */ public function getActivities(): RepositoryInterface { return $this->services->activities; } - /** - * @return RouterInterface - */ protected function createRouter(): RouterInterface { $router = new Router(); diff --git a/src/Worker/WorkerFactoryInterface.php b/src/Worker/WorkerFactoryInterface.php index 370fd48c4..c094d8cc5 100644 --- a/src/Worker/WorkerFactoryInterface.php +++ b/src/Worker/WorkerFactoryInterface.php @@ -33,13 +33,10 @@ interface WorkerFactoryInterface /** * Create a new Temporal Worker with the name of the task queue and register in worker. * - * @param string $taskQueue - * @param WorkerOptions|null $options - * @return WorkerInterface */ public function newWorker( string $taskQueue = self::DEFAULT_TASK_QUEUE, - WorkerOptions $options = null, + ?WorkerOptions $options = null, ): WorkerInterface; /** diff --git a/src/Worker/WorkerInterface.php b/src/Worker/WorkerInterface.php index 626be561c..90612ae55 100644 --- a/src/Worker/WorkerInterface.php +++ b/src/Worker/WorkerInterface.php @@ -24,7 +24,6 @@ interface WorkerInterface extends Identifiable /** * Returns processing options associated with specific worker task queue. * - * @return WorkerOptions */ public function getOptions(): WorkerOptions; @@ -57,7 +56,6 @@ public function getWorkflows(): iterable; * @see WorkerInterface::registerActivity * @deprecated use {@see registerActivity()} instead. * - * @param object ...$activity * @return $this */ public function registerActivityImplementations(object ...$activity): self; @@ -74,7 +72,7 @@ public function registerActivityImplementations(object ...$activity): self; * * $worker->registerActivity(MyActivity::class, fn(ReflectionClass $class) => $container->create($class->getName())); */ - public function registerActivity(string $type, callable $factory = null): self; + public function registerActivity(string $type, ?callable $factory = null): self; /** * Returns list of registered activities. diff --git a/src/Worker/WorkerOptions.php b/src/Worker/WorkerOptions.php index 7ce72b555..72cac3b84 100644 --- a/src/Worker/WorkerOptions.php +++ b/src/Worker/WorkerOptions.php @@ -623,7 +623,6 @@ public function withEnableSessionWorker(bool $enable = true): self * For now, if user doesn't specify one, a new uuid will be used as the * resourceID. * - * @param string|null $identifier */ #[Pure] public function withSessionResourceId(?string $identifier): self diff --git a/src/WorkerFactory.php b/src/WorkerFactory.php index e6550f88f..b2629dcde 100644 --- a/src/WorkerFactory.php +++ b/src/WorkerFactory.php @@ -42,6 +42,7 @@ use Temporal\Worker\Environment\Environment; use Temporal\Worker\Environment\EnvironmentInterface; use Temporal\Worker\LoopInterface; +use Temporal\Worker\ServiceCredentials; use Temporal\Worker\Transport\Codec\CodecInterface; use Temporal\Worker\Transport\Codec\JsonCodec; use Temporal\Worker\Transport\Codec\ProtoCodec; @@ -74,44 +75,14 @@ class WorkerFactory implements WorkerFactoryInterface, LoopInterface { use EventEmitterTrait; - /** - * @var string - */ private const ERROR_MESSAGE_TYPE = 'Received message type must be a string, but %s given'; - - /** - * @var string - */ private const ERROR_HEADERS_TYPE = 'Received headers type must be a string, but %s given'; - - /** - * @var string - */ private const ERROR_HEADER_NOT_STRING_TYPE = 'Header "%s" argument type must be a string, but %s given'; - - /** - * @var string - */ private const ERROR_QUEUE_NOT_FOUND = 'Cannot find a worker for task queue "%s"'; - - /** - * @var string - */ private const HEADER_TASK_QUEUE = 'taskQueue'; - /** - * @var DataConverterInterface - */ protected DataConverterInterface $converter; - - /** - * @var ReaderInterface - */ protected ReaderInterface $reader; - - /** - * @var RouterInterface - */ protected RouterInterface $router; /** @@ -119,79 +90,44 @@ class WorkerFactory implements WorkerFactoryInterface, LoopInterface */ protected RepositoryInterface $queues; - /** - * @var CodecInterface - */ protected CodecInterface $codec; - - /** - * @var ClientInterface - */ protected ClientInterface $client; - - /** - * @var ServerInterface - */ protected ServerInterface $server; - - /** - * @var QueueInterface - */ protected QueueInterface $responses; - /** - * @var RPCConnectionInterface - */ - protected RPCConnectionInterface $rpc; - /** * @var MarshallerInterface */ protected MarshallerInterface $marshaller; - /** - * @var EnvironmentInterface - */ protected EnvironmentInterface $env; - /** - * @param DataConverterInterface $dataConverter - * @param RPCConnectionInterface $rpc - */ public function __construct( DataConverterInterface $dataConverter, - RPCConnectionInterface $rpc, + protected RPCConnectionInterface $rpc, + ServiceCredentials $credentials, ) { $this->converter = $dataConverter; - $this->rpc = $rpc; - - $this->boot(); + $this->boot($credentials); } - /** - * @param DataConverterInterface|null $converter - * @param RPCConnectionInterface|null $rpc - * - * @return WorkerFactoryInterface - */ public static function create( - DataConverterInterface $converter = null, - RPCConnectionInterface $rpc = null, + ?DataConverterInterface $converter = null, + ?RPCConnectionInterface $rpc = null, + ?ServiceCredentials $credentials = null, ): WorkerFactoryInterface { return new static( $converter ?? DataConverter::createDefault(), $rpc ?? Goridge::create(), + $credentials ?? ServiceCredentials::create(), ); } - /** - * {@inheritDoc} - */ public function newWorker( string $taskQueue = self::DEFAULT_TASK_QUEUE, - WorkerOptions $options = null, - ExceptionInterceptorInterface $exceptionInterceptor = null, - PipelineProvider $interceptorProvider = null, + ?WorkerOptions $options = null, + ?ExceptionInterceptorInterface $exceptionInterceptor = null, + ?PipelineProvider $interceptorProvider = null, ): WorkerInterface { $worker = new Worker( $taskQueue, @@ -208,33 +144,21 @@ public function newWorker( return $worker; } - /** - * @return ReaderInterface - */ public function getReader(): ReaderInterface { return $this->reader; } - /** - * @return ClientInterface - */ public function getClient(): ClientInterface { return $this->client; } - /** - * @return QueueInterface - */ public function getQueue(): QueueInterface { return $this->responses; } - /** - * @return DataConverterInterface - */ public function getDataConverter(): DataConverterInterface { return $this->converter; @@ -248,18 +172,12 @@ public function getMarshaller(): MarshallerInterface return $this->marshaller; } - /** - * @return EnvironmentInterface - */ public function getEnvironment(): EnvironmentInterface { return $this->env; } - /** - * {@inheritDoc} - */ - public function run(HostConnectionInterface $host = null): int + public function run(?HostConnectionInterface $host = null): int { $host ??= RoadRunner::create(); $this->codec = $this->createCodec(); @@ -275,9 +193,6 @@ public function run(HostConnectionInterface $host = null): int return 0; } - /** - * @return void - */ public function tick(): void { $this->emit(LoopInterface::ON_SIGNAL); @@ -287,9 +202,6 @@ public function tick(): void $this->emit(LoopInterface::ON_FINALLY); } - /** - * @return ReaderInterface - */ protected function createReader(): ReaderInterface { if (\interface_exists(Reader::class)) { @@ -307,44 +219,31 @@ protected function createTaskQueue(): RepositoryInterface return new ArrayRepository(); } - /** - * @return RouterInterface - */ - protected function createRouter(): RouterInterface + protected function createRouter(ServiceCredentials $credentials): RouterInterface { $router = new Router(); - $router->add(new Router\GetWorkerInfo($this->queues, $this->marshaller)); + $router->add(new Router\GetWorkerInfo($this->queues, $this->marshaller, $credentials)); return $router; } - /** - * @return QueueInterface - */ protected function createQueue(): QueueInterface { return new ArrayQueue(); } - /** - * @return ClientInterface - */ #[Pure] protected function createClient(): ClientInterface { return new Client($this->responses); } - /** - * @return ServerInterface - */ protected function createServer(): ServerInterface { return new Server($this->responses, $this->onRequest(...)); } /** - * @param ReaderInterface $reader * @return MarshallerInterface */ protected function createMarshaller(ReaderInterface $reader): MarshallerInterface @@ -352,24 +251,18 @@ protected function createMarshaller(ReaderInterface $reader): MarshallerInterfac return new Marshaller(new AttributeMapperFactory($reader)); } - /** - * @return void - */ - private function boot(): void + private function boot(ServiceCredentials $credentials): void { $this->reader = $this->createReader(); $this->marshaller = $this->createMarshaller($this->reader); $this->queues = $this->createTaskQueue(); - $this->router = $this->createRouter(); + $this->router = $this->createRouter($credentials); $this->responses = $this->createQueue(); $this->client = $this->createClient(); $this->server = $this->createServer(); $this->env = new Environment(); } - /** - * @return CodecInterface - */ private function createCodec(): CodecInterface { switch ($_SERVER['RR_CODEC'] ?? null) { @@ -381,11 +274,6 @@ private function createCodec(): CodecInterface } } - /** - * @param string $messages - * @param array $headers - * @return string - */ private function dispatch(string $messages, array $headers): string { $commands = $this->codec->decode($messages, $headers); @@ -407,11 +295,6 @@ private function dispatch(string $messages, array $headers): string return $this->codec->encode($this->responses); } - /** - * @param ServerRequestInterface $request - * @param array $headers - * @return PromiseInterface - */ private function onRequest(ServerRequestInterface $request, array $headers): PromiseInterface { if (!isset($headers[self::HEADER_TASK_QUEUE])) { @@ -425,10 +308,6 @@ private function onRequest(ServerRequestInterface $request, array $headers): Pro return $queue->dispatch($request, $headers); } - /** - * @param string $taskQueueName - * @return WorkerInterface - */ private function findTaskQueueOrFail(string $taskQueueName): WorkerInterface { $queue = $this->queues->find($taskQueueName); @@ -440,10 +319,6 @@ private function findTaskQueueOrFail(string $taskQueueName): WorkerInterface return $queue; } - /** - * @param array $headers - * @return string - */ private function findTaskQueueNameOrFail(array $headers): string { $taskQueue = $headers[self::HEADER_TASK_QUEUE]; diff --git a/src/Workflow.php b/src/Workflow.php index 04ffec217..8f4172ee2 100644 --- a/src/Workflow.php +++ b/src/Workflow.php @@ -71,7 +71,6 @@ final class Workflow extends Facade * * And each other like this. * - * @return \DateTimeInterface * @throws OutOfContextException in the absence of the workflow execution context. */ public static function now(): \DateTimeInterface @@ -86,7 +85,6 @@ public static function now(): \DateTimeInterface * * In the case that the workflow is started for the first time, the **true** value will be returned. * - * @return bool * @throws OutOfContextException in the absence of the workflow execution context. */ public static function isReplaying(): bool @@ -97,7 +95,6 @@ public static function isReplaying(): bool /** * Returns information about current workflow execution. * - * @return WorkflowInfo * @throws OutOfContextException in the absence of the workflow execution context. */ public static function getInfo(): WorkflowInfo @@ -141,7 +138,6 @@ public static function getUpdateContext(): ?UpdateContext * $second = $arguments->getValue(1, Type::TYPE_STRING); * ``` * - * @return ValuesInterface * @throws OutOfContextException in the absence of the workflow execution context. */ public static function getInput(): ValuesInterface @@ -183,8 +179,6 @@ public static function getInput(): ValuesInterface * You can see more information about the capabilities of the child * asynchronous task in {@see CancellationScopeInterface} interface. * - * @param callable $task - * @return CancellationScopeInterface * @throws OutOfContextException in the absence of the workflow execution context. */ public static function async(callable $task): CancellationScopeInterface @@ -233,8 +227,6 @@ public static function async(callable $task): CancellationScopeInterface * * Use asyncDetached to handle cleanup and compensation logic. * - * @param callable $task - * @return CancellationScopeInterface * @throws OutOfContextException in the absence of the workflow execution context. */ public static function asyncDetached(callable $task): CancellationScopeInterface @@ -282,7 +274,6 @@ public static function asyncDetached(callable $task): CancellationScopeInterface * ``` * * @param callable|PromiseInterface|Mutex ...$conditions - * @return PromiseInterface */ public static function await(callable|Mutex|PromiseInterface ...$conditions): PromiseInterface { @@ -344,8 +335,6 @@ public static function getLastCompletionResult($type = null) * to call such query handlers as in the case of ordinary query methods. * * @param string|class-string $queryType - * @param callable $handler - * @return ScopedContextInterface * @throws OutOfContextException in the absence of the workflow execution context. */ public static function registerQuery(string $queryType, callable $handler): ScopedContextInterface @@ -366,8 +355,6 @@ public static function registerQuery(string $queryType, callable $handler): Scop * to call such signal handlers as in the case of ordinary signal methods. * * @param non-empty-string $queryType - * @param callable $handler - * @return ScopedContextInterface * @throws OutOfContextException in the absence of the workflow execution context. */ public static function registerSignal(string $queryType, callable $handler): ScopedContextInterface @@ -431,9 +418,6 @@ public static function registerUpdate( * } * ``` * - * @param string $changeId - * @param int $minSupported - * @param int $maxSupported * @return PromiseInterface * @throws OutOfContextException in the absence of the workflow execution context. */ @@ -519,16 +503,12 @@ public static function timer($interval): PromiseInterface * } * ``` * - * @param string $type - * @param array $args - * @param ContinueAsNewOptions|null $options - * @return PromiseInterface * @throws OutOfContextException in the absence of the workflow execution context. */ public static function continueAsNew( string $type, array $args = [], - ContinueAsNewOptions $options = null, + ?ContinueAsNewOptions $options = null, ): PromiseInterface { return self::getCurrentContext()->continueAsNew($type, $args, $options); } @@ -566,11 +546,10 @@ public static function continueAsNew( * @psalm-template T of object * * @param class-string $class - * @param ContinueAsNewOptions|null $options * @return T * @throws OutOfContextException in the absence of the workflow execution context. */ - public static function newContinueAsNewStub(string $class, ContinueAsNewOptions $options = null): object + public static function newContinueAsNewStub(string $class, ?ContinueAsNewOptions $options = null): object { return self::getCurrentContext()->newContinueAsNewStub($class, $options); } @@ -618,18 +597,14 @@ public static function newContinueAsNewStub(string $class, ContinueAsNewOptions * } * ``` * - * @param string $type - * @param array $args - * @param ChildWorkflowOptions|null $options * @param Type|string|\ReflectionType|\ReflectionClass|null $returnType * - * @return PromiseInterface * @throws OutOfContextException in the absence of the workflow execution context. */ public static function executeChildWorkflow( string $type, array $args = [], - ChildWorkflowOptions $options = null, + ?ChildWorkflowOptions $options = null, mixed $returnType = null, ): PromiseInterface { return self::getCurrentContext()->executeChildWorkflow($type, $args, $options, $returnType); @@ -671,14 +646,13 @@ public static function executeChildWorkflow( * @psalm-template T of object * * @param class-string $class - * @param ChildWorkflowOptions|null $options * * @return T * @throws OutOfContextException in the absence of the workflow execution context. */ public static function newChildWorkflowStub( string $class, - ChildWorkflowOptions $options = null, + ?ChildWorkflowOptions $options = null, ): object { return self::getCurrentContext()->newChildWorkflowStub($class, $options); } @@ -723,15 +697,11 @@ public static function newChildWorkflowStub( * } * ``` * - * @param string $name - * @param ChildWorkflowOptions|null $options - * - * @return ChildWorkflowStubInterface * @throws OutOfContextException in the absence of the workflow execution context. */ public static function newUntypedChildWorkflowStub( string $name, - ChildWorkflowOptions $options = null, + ?ChildWorkflowOptions $options = null, ): ChildWorkflowStubInterface { return self::getCurrentContext()->newUntypedChildWorkflowStub($name, $options); } @@ -756,7 +726,6 @@ public static function newUntypedChildWorkflowStub( * @psalm-template T of object * * @param class-string $class - * @param WorkflowExecution $execution * @return T * @throws OutOfContextException in the absence of the workflow execution context. */ @@ -785,8 +754,6 @@ public static function newExternalWorkflowStub(string $class, WorkflowExecution * } * ``` * - * @param WorkflowExecution $execution - * @return ExternalWorkflowStubInterface * @throws OutOfContextException in the absence of the workflow execution context. */ public static function newUntypedExternalWorkflowStub(WorkflowExecution $execution): ExternalWorkflowStubInterface @@ -824,18 +791,15 @@ public static function newUntypedExternalWorkflowStub(WorkflowExecution $executi * } * ``` * - * @param string $type - * @param array $args * @param ActivityOptions|null $options - * @param Type|string|null|\ReflectionClass|\ReflectionType $returnType * @return PromiseInterface * @throws OutOfContextException in the absence of the workflow execution context. */ public static function executeActivity( string $type, array $args = [], - ActivityOptionsInterface $options = null, - Type|string|\ReflectionClass|\ReflectionType $returnType = null, + ?ActivityOptionsInterface $options = null, + Type|string|\ReflectionClass|\ReflectionType|null $returnType = null, ): PromiseInterface { return self::getCurrentContext()->executeActivity($type, $args, $options, $returnType); } @@ -869,14 +833,13 @@ public static function executeActivity( * @psalm-template T of object * * @param class-string $class - * @param ActivityOptionsInterface|null $options * * @return T * @throws OutOfContextException in the absence of the workflow execution context. */ public static function newActivityStub( string $class, - ActivityOptionsInterface $options = null, + ?ActivityOptionsInterface $options = null, ): object { return self::getCurrentContext()->newActivityStub($class, $options); } @@ -900,13 +863,10 @@ public static function newActivityStub( * } * ``` * - * @param ActivityOptionsInterface|null $options - * - * @return ActivityStubInterface * @throws OutOfContextException in the absence of the workflow execution context. */ public static function newUntypedActivityStub( - ActivityOptionsInterface $options = null, + ?ActivityOptionsInterface $options = null, ): ActivityStubInterface { return self::getCurrentContext()->newUntypedActivityStub($options); } @@ -914,7 +874,6 @@ public static function newUntypedActivityStub( /** * Returns a complete trace of the last calls (for debugging). * - * @return string * @throws OutOfContextException in the absence of the workflow execution context. */ public static function getStackTrace(): string diff --git a/src/Workflow/ActivityStubInterface.php b/src/Workflow/ActivityStubInterface.php index 26ea7c2ae..bc4a9fab0 100644 --- a/src/Workflow/ActivityStubInterface.php +++ b/src/Workflow/ActivityStubInterface.php @@ -18,9 +18,6 @@ interface ActivityStubInterface { - /** - * @return ActivityOptionsInterface - */ public function getOptions(): ActivityOptionsInterface; /** @@ -28,14 +25,12 @@ public function getOptions(): ActivityOptionsInterface; * * @param string $name name of an activity type to execute. * @param array $args arguments of the activity. - * @param Type|string|null|\ReflectionClass|\ReflectionType $returnType - * @param bool $isLocalActivity * @return CompletableResultInterface Promise to the activity result. */ public function execute( string $name, array $args = [], - Type|string|\ReflectionClass|\ReflectionType $returnType = null, + Type|string|\ReflectionClass|\ReflectionType|null $returnType = null, bool $isLocalActivity = false, ): PromiseInterface; } diff --git a/src/Workflow/CancellationScopeInterface.php b/src/Workflow/CancellationScopeInterface.php index 7ec2da972..5fdd5908f 100644 --- a/src/Workflow/CancellationScopeInterface.php +++ b/src/Workflow/CancellationScopeInterface.php @@ -23,21 +23,18 @@ interface CancellationScopeInterface extends PromiseInterface /** * Detached scopes can continue working even if parent scope was cancelled. * - * @return bool */ public function isDetached(): bool; /** * Returns true if cancel request was sent to scope. * - * @return bool */ public function isCancelled(): bool; /** * Triggered when cancel request sent to scope. * - * @param callable $then * @return $this */ public function onCancel(callable $then): self; @@ -49,7 +46,6 @@ public function onCancel(callable $then): self; * Once a promise is settled (either fulfilled or rejected), calling `cancel()` on * a promise has no effect. * - * @return void */ public function cancel(): void; } diff --git a/src/Workflow/ChildWorkflowOptions.php b/src/Workflow/ChildWorkflowOptions.php index 50d27494e..679fd288d 100644 --- a/src/Workflow/ChildWorkflowOptions.php +++ b/src/Workflow/ChildWorkflowOptions.php @@ -179,8 +179,6 @@ public function __construct() } /** - * @param MethodRetry|null $retry - * @param CronSchedule|null $cron * @return $this */ public function mergeWith(?MethodRetry $retry = null, ?CronSchedule $cron = null): self @@ -201,7 +199,6 @@ public function mergeWith(?MethodRetry $retry = null, ?CronSchedule $cron = null /** * Specify namespace in which workflow should be started. * - * @param string $namespace * @return $this */ #[Pure] @@ -220,7 +217,6 @@ public function withNamespace(string $namespace): self * deduplication will happen based on the generated id. So prefer assigning * business meaningful ids if possible. * - * @param string $workflowId * @return $this */ #[Pure] @@ -237,7 +233,6 @@ public function withWorkflowId(string $workflowId): self * Task queue to use for workflow tasks. It should match a task queue * specified when creating a {@see Worker} that hosts the workflow code. * - * @param string $taskQueue * @return $this */ #[Pure] @@ -366,7 +361,6 @@ public function withWorkflowIdReusePolicy(IdReusePolicy|int $policy): self * RetryOptions that define how child workflow is retried in case of * failure. Default is null which is no reties. * - * @param RetryOptions|null $options * @return $this */ #[Pure] @@ -384,7 +378,6 @@ public function withRetryOptions(?RetryOptions $options): self * * @see CronSchedule::$interval for more info about cron format. * - * @param string|null $expression * @return $this */ #[Pure] @@ -400,7 +393,6 @@ public function withCronSchedule(?string $expression): self /** * Specifies additional non-indexed information in result of list workflow. * - * @param array|null $memo * @return $this */ public function withMemo(?array $memo): self @@ -415,7 +407,6 @@ public function withMemo(?array $memo): self /** * Specifies additional indexed information in result of list workflow. * - * @param array|null $searchAttributes * @return $this */ public function withSearchAttributes(?array $searchAttributes): self diff --git a/src/Workflow/ChildWorkflowStubInterface.php b/src/Workflow/ChildWorkflowStubInterface.php index 14186d9d4..e857cccc5 100644 --- a/src/Workflow/ChildWorkflowStubInterface.php +++ b/src/Workflow/ChildWorkflowStubInterface.php @@ -18,23 +18,15 @@ interface ChildWorkflowStubInterface { /** - * @return PromiseInterface * @throws \LogicException */ public function getExecution(): PromiseInterface; - /** - * @return string - */ public function getChildWorkflowType(): string; - /** - * @return ChildWorkflowOptions - */ public function getOptions(): ChildWorkflowOptions; /** - * @param array $args * @param Type|string|\ReflectionType|\ReflectionClass|null $returnType * * @return CompletableResultInterface @@ -52,7 +44,6 @@ public function getResult($returnType = null): PromiseInterface; /** * @param non-empty-string $name - * @param array $args * * @return CompletableResultInterface * @throws \LogicException diff --git a/src/Workflow/ContinueAsNewOptions.php b/src/Workflow/ContinueAsNewOptions.php index 159156723..3c2a9735d 100644 --- a/src/Workflow/ContinueAsNewOptions.php +++ b/src/Workflow/ContinueAsNewOptions.php @@ -79,7 +79,6 @@ public static function new(): self * * @psalm-suppress ImpureMethodCall * - * @param string $taskQueue * @return $this */ #[Pure] diff --git a/src/Workflow/ExternalWorkflowStubInterface.php b/src/Workflow/ExternalWorkflowStubInterface.php index ab22cd7c3..c8f69f9f3 100644 --- a/src/Workflow/ExternalWorkflowStubInterface.php +++ b/src/Workflow/ExternalWorkflowStubInterface.php @@ -15,22 +15,12 @@ interface ExternalWorkflowStubInterface { - /** - * @return WorkflowExecution - */ public function getExecution(): WorkflowExecution; /** - * @param string $name - * @param array $args - * - * @return PromiseInterface * @throws \LogicException */ public function signal(string $name, array $args = []): PromiseInterface; - /** - * @return PromiseInterface - */ public function cancel(): PromiseInterface; } diff --git a/src/Workflow/ProcessInterface.php b/src/Workflow/ProcessInterface.php index e35d2787b..0d6d1cba0 100644 --- a/src/Workflow/ProcessInterface.php +++ b/src/Workflow/ProcessInterface.php @@ -19,8 +19,5 @@ */ interface ProcessInterface extends CancellationScopeInterface, Identifiable { - /** - * @return WorkflowContextInterface - */ public function getContext(): WorkflowContextInterface; } diff --git a/src/Workflow/Saga.php b/src/Workflow/Saga.php index 736b4d1ac..6853e3ab4 100644 --- a/src/Workflow/Saga.php +++ b/src/Workflow/Saga.php @@ -26,7 +26,6 @@ final class Saga * false, then the compensation operations will be run the reverse order as they are added. * * @param bool $parallelCompensation default is false. - * @return self */ public function setParallelCompensation(bool $parallelCompensation): self { @@ -43,7 +42,6 @@ public function setParallelCompensation(bool $parallelCompensation): self * @param bool $continueWithError whether to proceed with the next compensation operation if the * previous throws exception. This only applies to sequential compensation. Default is * false. - * @return self */ public function setContinueWithError(bool $continueWithError): self { @@ -51,9 +49,6 @@ public function setContinueWithError(bool $continueWithError): self return $this; } - /** - * @param callable $handler - */ public function addCompensation(callable $handler): void { $this->compensate[] = $handler; diff --git a/src/Workflow/WorkflowContextInterface.php b/src/Workflow/WorkflowContextInterface.php index e5cd2ee8b..54a4ff82b 100644 --- a/src/Workflow/WorkflowContextInterface.php +++ b/src/Workflow/WorkflowContextInterface.php @@ -32,7 +32,6 @@ interface WorkflowContextInterface extends EnvironmentInterface * * @see Workflow::getInfo() * - * @return WorkflowInfo */ public function getInfo(): WorkflowInfo; @@ -41,7 +40,6 @@ public function getInfo(): WorkflowInfo; * * @see Workflow::getInput() * - * @return ValuesInterface */ public function getInput(): ValuesInterface; @@ -61,8 +59,6 @@ public function getLastCompletionResult($type = null); * * @see Workflow::registerQuery() * - * @param string $queryType - * @param callable $handler * @return $this */ public function registerQuery(string $queryType, callable $handler): self; @@ -72,8 +68,6 @@ public function registerQuery(string $queryType, callable $handler): self; * * @see Workflow::registerSignal() * - * @param string $queryType - * @param callable $handler * @return $this */ public function registerSignal(string $queryType, callable $handler): self; @@ -92,9 +86,6 @@ public function registerUpdate(string $name, callable $handler, ?callable $valid * * @internal This is an internal method * - * @param RequestInterface $request - * @param bool $cancellable - * @return PromiseInterface */ public function request(RequestInterface $request, bool $cancellable = true): PromiseInterface; @@ -103,10 +94,6 @@ public function request(RequestInterface $request, bool $cancellable = true): Pr * * @see Workflow::getVersion() * - * @param string $changeId - * @param int $minSupported - * @param int $maxSupported - * @return PromiseInterface */ public function getVersion(string $changeId, int $minSupported, int $maxSupported): PromiseInterface; @@ -124,19 +111,14 @@ public function sideEffect(callable $context): PromiseInterface; /** * @internal This is an internal method * - * @param array|null $result - * @param \Throwable|null $failure - * @return PromiseInterface */ - public function complete(array $result = null, \Throwable $failure = null): PromiseInterface; + public function complete(?array $result = null, ?\Throwable $failure = null): PromiseInterface; /** * @internal This is an internal method * - * @param \Throwable|null $failure - * @return PromiseInterface */ - public function panic(\Throwable $failure = null): PromiseInterface; + public function panic(?\Throwable $failure = null): PromiseInterface; /** * Stops workflow execution work for a specified period. @@ -144,7 +126,6 @@ public function panic(\Throwable $failure = null): PromiseInterface; * @see Workflow::timer() * * @param DateIntervalValue $interval - * @return PromiseInterface * @see DateInterval */ public function timer($interval): PromiseInterface; @@ -154,15 +135,11 @@ public function timer($interval): PromiseInterface; * * @see Workflow::continueAsNew() * - * @param string $type - * @param array $args - * @param ContinueAsNewOptions|null $options - * @return PromiseInterface */ public function continueAsNew( string $type, array $args = [], - ContinueAsNewOptions $options = null, + ?ContinueAsNewOptions $options = null, ): PromiseInterface; /** @@ -172,27 +149,22 @@ public function continueAsNew( * * @psalm-template T of object * @param class-string $class - * @param ContinueAsNewOptions|null $options * @return T */ - public function newContinueAsNewStub(string $class, ContinueAsNewOptions $options = null): object; + public function newContinueAsNewStub(string $class, ?ContinueAsNewOptions $options = null): object; /** * Calls an external workflow without stopping the current one. * * @see Workflow::executeChildWorkflow() * - * @param string $type - * @param array $args - * @param ChildWorkflowOptions|null $options * @param Type|string|\ReflectionType|\ReflectionClass|null $returnType * - * @return PromiseInterface */ public function executeChildWorkflow( string $type, array $args = [], - ChildWorkflowOptions $options = null, + ?ChildWorkflowOptions $options = null, $returnType = null, ): PromiseInterface; @@ -203,13 +175,12 @@ public function executeChildWorkflow( * * @psalm-template T of object * @param class-string $class - * @param ChildWorkflowOptions|null $options * * @return T */ public function newChildWorkflowStub( string $class, - ChildWorkflowOptions $options = null, + ?ChildWorkflowOptions $options = null, ): object; /** @@ -217,14 +188,11 @@ public function newChildWorkflowStub( * * @see Workflow::newUntypedChildWorkflowStub() * - * @param string $type - * @param ChildWorkflowOptions|null $options * - * @return ChildWorkflowStubInterface */ public function newUntypedChildWorkflowStub( string $type, - ChildWorkflowOptions $options = null, + ?ChildWorkflowOptions $options = null, ): ChildWorkflowStubInterface; /** @@ -235,7 +203,6 @@ public function newUntypedChildWorkflowStub( * * @psalm-template T of object * @param class-string $class - * @param WorkflowExecution $execution * @return T */ public function newExternalWorkflowStub(string $class, WorkflowExecution $execution): object; @@ -246,8 +213,6 @@ public function newExternalWorkflowStub(string $class, WorkflowExecution $execut * * @see Workflow::newUntypedExternalWorkflowStub() * - * @param WorkflowExecution $execution - * @return ExternalWorkflowStubInterface */ public function newUntypedExternalWorkflowStub(WorkflowExecution $execution): ExternalWorkflowStubInterface; @@ -256,18 +221,15 @@ public function newUntypedExternalWorkflowStub(WorkflowExecution $execution): Ex * * @see Workflow::executeActivity() * - * @param string $type - * @param array $args * @param ActivityOptions|null $options - * @param Type|string|null|\ReflectionClass|\ReflectionType $returnType * * @return PromiseInterface */ public function executeActivity( string $type, array $args = [], - ActivityOptionsInterface $options = null, - Type|string|\ReflectionClass|\ReflectionType $returnType = null, + ?ActivityOptionsInterface $options = null, + Type|string|\ReflectionClass|\ReflectionType|null $returnType = null, ): PromiseInterface; /** @@ -279,13 +241,12 @@ public function executeActivity( * * @psalm-template T of object * @param class-string $class - * @param ActivityOptionsInterface|null $options * * @return T */ public function newActivityStub( string $class, - ActivityOptionsInterface $options = null, + ?ActivityOptionsInterface $options = null, ): object; /** @@ -294,12 +255,10 @@ public function newActivityStub( * * @see Workflow::newUntypedActivityStub() * - * @param ActivityOptionsInterface|null $options * - * @return ActivityStubInterface */ public function newUntypedActivityStub( - ActivityOptionsInterface $options = null, + ?ActivityOptionsInterface $options = null, ): ActivityStubInterface; /** @@ -308,7 +267,6 @@ public function newUntypedActivityStub( * @see Workflow::await() * * @param callable|Mutex|PromiseInterface ...$conditions - * @return PromiseInterface */ public function await(callable|Mutex|PromiseInterface ...$conditions): PromiseInterface; @@ -331,7 +289,6 @@ public function awaitWithTimeout($interval, callable|Mutex|PromiseInterface ...$ * * @see Workflow::getStackTrace() * - * @return string */ public function getStackTrace(): string; diff --git a/src/Workflow/WorkflowExecution.php b/src/Workflow/WorkflowExecution.php index 6703c216e..4e5a88fa0 100644 --- a/src/Workflow/WorkflowExecution.php +++ b/src/Workflow/WorkflowExecution.php @@ -24,7 +24,6 @@ class WorkflowExecution /** * @psalm-readonly * @psalm-allow-private-mutation - * @var string */ #[Marshal(name: 'ID')] #[Marshal(name: 'workflow_id')] @@ -33,41 +32,27 @@ class WorkflowExecution /** * @psalm-readonly * @psalm-allow-private-mutation - * @var string|null */ #[Marshal(name: 'RunID')] #[Marshal(name: 'run_id')] private ?string $runId; - /** - * @param string|null $id - * @param string|null $runId - */ - public function __construct(string $id = null, ?string $runId = null) + public function __construct(?string $id = null, ?string $runId = null) { $this->id = $id ?? Uuid::nil(); $this->runId = $runId; } - /** - * @return string - */ public function getID(): string { return $this->id; } - /** - * @return string|null - */ public function getRunID(): ?string { return $this->runId; } - /** - * @return \Temporal\Api\Common\V1\WorkflowExecution - */ public function toProtoWorkflowExecution(): \Temporal\Api\Common\V1\WorkflowExecution { $e = new \Temporal\Api\Common\V1\WorkflowExecution(); diff --git a/src/Workflow/WorkflowInfo.php b/src/Workflow/WorkflowInfo.php index b7d77c051..202df533b 100644 --- a/src/Workflow/WorkflowInfo.php +++ b/src/Workflow/WorkflowInfo.php @@ -26,15 +26,9 @@ #[Immutable] final class WorkflowInfo { - /** - * @var WorkflowExecution - */ #[Marshal(name: 'WorkflowExecution', type: ObjectType::class, of: WorkflowExecution::class)] public WorkflowExecution $execution; - /** - * @var WorkflowType - */ #[Marshal(name: 'WorkflowType', type: ObjectType::class, of: WorkflowType::class)] public WorkflowType $type; @@ -44,27 +38,15 @@ final class WorkflowInfo #[Marshal(name: 'TaskQueueName')] public string $taskQueue = WorkerFactoryInterface::DEFAULT_TASK_QUEUE; - /** - * @var \DateInterval - */ #[Marshal(name: 'WorkflowExecutionTimeout', type: DateIntervalType::class)] public \DateInterval $executionTimeout; - /** - * @var \DateInterval - */ #[Marshal(name: 'WorkflowRunTimeout', type: DateIntervalType::class)] public \DateInterval $runTimeout; - /** - * @var \DateInterval - */ #[Marshal(name: 'WorkflowTaskTimeout', type: DateIntervalType::class)] public \DateInterval $taskTimeout; - /** - * @var string - */ #[Marshal(name: 'Namespace')] public string $namespace = ClientOptions::DEFAULT_NAMESPACE; @@ -112,44 +94,25 @@ final class WorkflowInfo /** * @see CronSchedule::$interval for more info about cron format. * - * @var string|null */ #[Marshal(name: 'CronSchedule', type: NullableType::class, of: CronType::class)] public ?string $cronSchedule = null; - /** - * @var string|null - */ #[Marshal(name: 'ContinuedExecutionRunID')] public ?string $continuedExecutionRunId = null; - /** - * @var string|null - */ #[Marshal(name: 'ParentWorkflowNamespace')] public ?string $parentNamespace = null; - /** - * @var WorkflowExecution|null - */ #[Marshal(name: 'ParentWorkflowExecution', type: NullableType::class, of: WorkflowExecution::class)] public ?WorkflowExecution $parentExecution = null; - /** - * @var array|null - */ #[Marshal(name: 'SearchAttributes', type: NullableType::class, of: ArrayType::class)] public ?array $searchAttributes = null; - /** - * @var array|null - */ #[Marshal(name: 'Memo', type: NullableType::class, of: ArrayType::class)] public ?array $memo = null; - /** - * @var string - */ #[Marshal(name: 'BinaryChecksum')] public string $binaryChecksum = ''; diff --git a/src/Workflow/WorkflowMethod.php b/src/Workflow/WorkflowMethod.php index 205cc787e..1951937aa 100644 --- a/src/Workflow/WorkflowMethod.php +++ b/src/Workflow/WorkflowMethod.php @@ -33,10 +33,7 @@ final class WorkflowMethod #[Immutable] public ?string $name = null; - /** - * @param string|null $name - */ - public function __construct(string $name = null) + public function __construct(?string $name = null) { $this->name = $name; } diff --git a/src/Workflow/WorkflowRunInterface.php b/src/Workflow/WorkflowRunInterface.php index 610f1becb..87003f8cd 100644 --- a/src/Workflow/WorkflowRunInterface.php +++ b/src/Workflow/WorkflowRunInterface.php @@ -23,7 +23,6 @@ interface WorkflowRunInterface /** * Returns attached workflow execution. * - * @return WorkflowExecution */ public function getExecution(): WorkflowExecution; @@ -42,12 +41,11 @@ public function getExecution(): WorkflowExecution; * * @param string|\ReflectionClass|\ReflectionType|Type|null $type * @param int|null $timeout Timeout in seconds. Infinite by the default. - * @return mixed * @throws WorkflowFailedException * * @see DateInterval */ - public function getResult($type = null, int $timeout = null): mixed; + public function getResult($type = null, ?int $timeout = null): mixed; public function describe(): WorkflowExecutionDescription; } diff --git a/src/Workflow/WorkflowStub.php b/src/Workflow/WorkflowStub.php index 588271210..7a9019cb4 100644 --- a/src/Workflow/WorkflowStub.php +++ b/src/Workflow/WorkflowStub.php @@ -23,9 +23,6 @@ class WorkflowStub /** * Get untyped workflow stub using provided workflow proxy or workflow stub instance. * - * @param object $workflow - * @return WorkflowStubInterface - * * @psalm-assert WorkflowStubInterface|WorkflowProxy $workflow */ public static function fromWorkflow(object $workflow): WorkflowStubInterface diff --git a/src/Workflow/WorkflowType.php b/src/Workflow/WorkflowType.php index 7ee751910..f19b9e921 100644 --- a/src/Workflow/WorkflowType.php +++ b/src/Workflow/WorkflowType.php @@ -21,7 +21,6 @@ class WorkflowType /** * @psalm-allow-private-mutation * @psalm-readonly - * @var string */ #[Marshal(name: 'Name')] #[Marshal(name: 'name')] diff --git a/testing/src/ActivityMocker.php b/testing/src/ActivityMocker.php index 30c1e0b7e..8ef6e52b7 100644 --- a/testing/src/ActivityMocker.php +++ b/testing/src/ActivityMocker.php @@ -11,7 +11,7 @@ final class ActivityMocker { private ActivityInvocationCacheInterface $cache; - public function __construct(ActivityInvocationCacheInterface $cache = null) + public function __construct(?ActivityInvocationCacheInterface $cache = null) { $this->cache = $cache ?? RoadRunnerActivityInvocationCache::create(); } diff --git a/testing/src/Environment.php b/testing/src/Environment.php index 2edfe4b53..8adccdabb 100644 --- a/testing/src/Environment.php +++ b/testing/src/Environment.php @@ -44,7 +44,7 @@ public static function create(): self /** * @param array $envs */ - public function start(string $rrCommand = null, int $commandTimeout = 10, array $envs = []): void + public function start(?string $rrCommand = null, int $commandTimeout = 10, array $envs = []): void { $this->startTemporalTestServer($commandTimeout); $this->startRoadRunner($rrCommand, $commandTimeout, $envs); @@ -65,6 +65,7 @@ public function startTemporalServer(int $commandTimeout = 10, array $parameters "--port", $temporalPort, '--dynamic-config-value', 'frontend.enableUpdateWorkflowExecution=true', '--dynamic-config-value', 'frontend.enableUpdateWorkflowExecutionAsyncAccepted=true', + '--dynamic-config-value', 'frontend.enableExecuteMultiOperation=true', '--dynamic-config-value', 'system.enableEagerWorkflowStart=true', '--search-attribute', 'foo=text', '--search-attribute', 'bar=int', @@ -114,7 +115,7 @@ public function startTemporalTestServer(int $commandTimeout = 10): void /** * @param array $envs */ - public function startRoadRunner(string $rrCommand = null, int $commandTimeout = 10, array $envs = []): void + public function startRoadRunner(?string $rrCommand = null, int $commandTimeout = 10, array $envs = []): void { $this->roadRunnerProcess = new Process( command: $rrCommand ? \explode(' ', $rrCommand) : [$this->systemInfo->rrExecutable, 'serve'], diff --git a/testing/src/WorkerFactory.php b/testing/src/WorkerFactory.php index 1b04eaa7c..bef263054 100644 --- a/testing/src/WorkerFactory.php +++ b/testing/src/WorkerFactory.php @@ -13,6 +13,7 @@ use Temporal\Internal\ServiceContainer; use Temporal\Worker\ActivityInvocationCache\ActivityInvocationCacheInterface; use Temporal\Worker\ActivityInvocationCache\RoadRunnerActivityInvocationCache; +use Temporal\Worker\ServiceCredentials; use Temporal\Worker\Transport\Goridge; use Temporal\Worker\Transport\RPCConnectionInterface; use Temporal\Worker\Worker; @@ -27,32 +28,32 @@ public function __construct( DataConverterInterface $dataConverter, RPCConnectionInterface $rpc, ActivityInvocationCacheInterface $activityCache, + ServiceCredentials $credentials, ) { $this->activityCache = $activityCache; - parent::__construct($dataConverter, $rpc); + parent::__construct($dataConverter, $rpc, $credentials); } public static function create( ?DataConverterInterface $converter = null, ?RPCConnectionInterface $rpc = null, + ?ServiceCredentials $credentials = null, ?ActivityInvocationCacheInterface $activityCache = null, ): static { return new static( $converter ?? DataConverter::createDefault(), $rpc ?? Goridge::create(), $activityCache ?? RoadRunnerActivityInvocationCache::create($converter), + $credentials ?? ServiceCredentials::create(), ); } - /** - * {@inheritDoc} - */ public function newWorker( string $taskQueue = self::DEFAULT_TASK_QUEUE, - WorkerOptions $options = null, - ExceptionInterceptorInterface $exceptionInterceptor = null, - PipelineProvider $interceptorProvider = null, + ?WorkerOptions $options = null, + ?ExceptionInterceptorInterface $exceptionInterceptor = null, + ?PipelineProvider $interceptorProvider = null, ): WorkerInterface { $worker = new WorkerMock( new Worker( diff --git a/testing/src/WorkerMock.php b/testing/src/WorkerMock.php index 6b88fbea2..a725dbfa9 100644 --- a/testing/src/WorkerMock.php +++ b/testing/src/WorkerMock.php @@ -63,7 +63,7 @@ public function registerActivityImplementations(object ...$activity): WorkerInte return $this->wrapped->registerActivityImplementations(...$activity); } - public function registerActivity(string $type, callable $factory = null): WorkerInterface + public function registerActivity(string $type, ?callable $factory = null): WorkerInterface { return $this->wrapped->registerActivity($type, $factory); } diff --git a/tests/Acceptance/App/Runtime/RRStarter.php b/tests/Acceptance/App/Runtime/RRStarter.php index 3809dcd1e..18e4e7575 100644 --- a/tests/Acceptance/App/Runtime/RRStarter.php +++ b/tests/Acceptance/App/Runtime/RRStarter.php @@ -5,6 +5,7 @@ namespace Temporal\Tests\Acceptance\App\Runtime; use Temporal\Testing\Environment; +use Temporal\Testing\SystemInfo; final class RRStarter { @@ -24,9 +25,11 @@ public function start(): void return; } + $sysInfo = SystemInfo::detect(); $run = $this->runtime->command; + $rrCommand = [ - $this->runtime->workDir . DIRECTORY_SEPARATOR . 'rr', + $this->runtime->workDir . DIRECTORY_SEPARATOR . $sysInfo->rrExecutable, 'serve', '-w', $this->runtime->rrConfigDir, diff --git a/tests/Acceptance/Extra/Schedule/ScheduleClientTest.php b/tests/Acceptance/Extra/Schedule/ScheduleClientTest.php new file mode 100644 index 000000000..a11cbdb5a --- /dev/null +++ b/tests/Acceptance/Extra/Schedule/ScheduleClientTest.php @@ -0,0 +1,60 @@ + $handle */ + $handle = []; + // Create a new schedules + for ($i = 0; $i < 12; $i++) { + $handle[] = $client->createSchedule( + Schedule::new() + ->withAction(StartWorkflowAction::new('TestWorkflow')) + ->withSpec(ScheduleSpec::new()->withStartTime('+1 hour')) + ->withState(ScheduleState::new()->withPaused(true)), + ScheduleOptions::new() + ->withSearchAttributes( + EncodedCollection::fromValues([ + 'bar' => $i % 2 === 0 ? 4242 : 24, + ]) + ) + ); + } + + try { + $paginator = $client->listSchedules( + pageSize: 5, + query: 'bar = 4242' + ); + + $this->assertCount(5, $paginator->getPageItems()); + + $next = $paginator->getNextPage(); + $this->assertNotNull($next); + $this->assertCount(1, $next->getPageItems()); + } finally { + foreach ($handle as $h) { + $h->delete(); + } + } + } +} diff --git a/tests/Acceptance/Extra/Schedule/ScheduleUpdateTest.php b/tests/Acceptance/Extra/Schedule/ScheduleUpdateTest.php index 33ee56fc6..118947516 100644 --- a/tests/Acceptance/Extra/Schedule/ScheduleUpdateTest.php +++ b/tests/Acceptance/Extra/Schedule/ScheduleUpdateTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Temporal\Tests\Acceptance\Extra\Update\DynamicUpdate; +namespace Temporal\Tests\Acceptance\Extra\Update\ScheduleUpdate; use PHPUnit\Framework\Attributes\Test; use Temporal\Client\Schedule\Action\StartWorkflowAction; diff --git a/tests/Acceptance/Extra/Update/UntypedStubTest.php b/tests/Acceptance/Extra/Update/UntypedStubTest.php index dcf204b21..f43e7c817 100644 --- a/tests/Acceptance/Extra/Update/UntypedStubTest.php +++ b/tests/Acceptance/Extra/Update/UntypedStubTest.php @@ -9,7 +9,7 @@ use Temporal\Client\WorkflowClientInterface; use Temporal\Client\WorkflowStubInterface; use Temporal\Exception\Client\TimeoutException; -use Temporal\Exception\Client\WorkflowUpdateException; +use Temporal\Exception\Client\UntypedStubException; use Temporal\Internal\Support\DateInterval; use Temporal\Tests\Acceptance\App\Attribute\Stub; use Temporal\Tests\Acceptance\App\TestCase; @@ -21,7 +21,7 @@ class UntypedStubTest extends TestCase { #[Test] public function fetchResolvedResultAfterWorkflowCompleted( - #[Stub('Extra_Update_WorkflowUpdate')] WorkflowStubInterface $stub, + #[Stub('Extra_Update_UntypedStub')] WorkflowStubInterface $stub, ): void { /** @see TestWorkflow::add */ @@ -45,7 +45,7 @@ public function fetchResolvedResultAfterWorkflowCompleted( #[Test] public function fetchResultWithTimeout( - #[Stub('Extra_Update_WorkflowUpdate')] WorkflowStubInterface $stub, + #[Stub('Extra_Update_UntypedStub')] WorkflowStubInterface $stub, ): void { /** @see TestWorkflow::add */ $handle = $stub->startUpdate('await', 'key'); @@ -70,12 +70,12 @@ public function fetchResultWithTimeout( #[Test] public function handleUnknownUpdate( - #[Stub('Extra_Update_WorkflowUpdate')] WorkflowStubInterface $stub, + #[Stub('Extra_Update_UntypedStub')] WorkflowStubInterface $stub, ): void { try { $stub->startUpdate('unknownUpdateMethod', '42'); $this->fail('Should throw exception'); - } catch (WorkflowUpdateException $e) { + } catch (UntypedStubException $e) { $this->assertStringContainsString( 'unknown update method unknownUpdateMethod', $e->getPrevious()->getMessage(), @@ -85,7 +85,7 @@ public function handleUnknownUpdate( #[Test] public function singleAwaitsWithoutTimeout( - #[Stub('Extra_Update_WorkflowUpdate')] WorkflowStubInterface $stub, + #[Stub('Extra_Update_UntypedStub')] WorkflowStubInterface $stub, ): void { /** @see TestWorkflow::add */ $handle = $stub->startUpdate('await', 'key'); @@ -110,7 +110,7 @@ public function singleAwaitsWithoutTimeout( #[Test] public function multipleAwaitsWithoutTimeout( - #[Stub('Extra_Update_WorkflowUpdate')] WorkflowStubInterface $stub, + #[Stub('Extra_Update_UntypedStub')] WorkflowStubInterface $stub, ): void { for ($i = 1; $i <= 5; $i++) { /** @see TestWorkflow::add */ @@ -145,7 +145,7 @@ public function multipleAwaitsWithoutTimeout( #[Test] public function multipleAwaitsWithTimeout( - #[Stub('Extra_Update_WorkflowUpdate')] WorkflowStubInterface $stub, + #[Stub('Extra_Update_UntypedStub')] WorkflowStubInterface $stub, ): void { for ($i = 1; $i <= 5; $i++) { /** @see TestWorkflow::addWithTimeout */ @@ -173,7 +173,7 @@ public function multipleAwaitsWithTimeout( #[Test] public function getUpdateHandler( - #[Stub('Extra_Update_WorkflowUpdate')] WorkflowStubInterface $stub, + #[Stub('Extra_Update_UntypedStub')] WorkflowStubInterface $stub, ): void { /** @see TestWorkflow::add */ $handle = $stub->startUpdate('await', 'key'); @@ -201,7 +201,7 @@ public function getUpdateHandler( #[Test] public function getUpdateHandlerFromNewRunningWorkflowStub( - #[Stub('Extra_Update_WorkflowUpdate')] WorkflowStubInterface $stub, + #[Stub('Extra_Update_UntypedStub')] WorkflowStubInterface $stub, WorkflowClientInterface $client, ): void { /** @see TestWorkflow::add */ @@ -243,7 +243,7 @@ class TestWorkflow private array $awaits = []; private bool $exit = false; - #[WorkflowMethod(name: "Extra_Update_WorkflowUpdate")] + #[WorkflowMethod(name: "Extra_Update_UntypedStub")] public function handle() { yield Workflow::await(fn() => $this->exit); diff --git a/tests/Acceptance/Extra/Update/UpdateWithStartTest.php b/tests/Acceptance/Extra/Update/UpdateWithStartTest.php new file mode 100644 index 000000000..cf95d8585 --- /dev/null +++ b/tests/Acceptance/Extra/Update/UpdateWithStartTest.php @@ -0,0 +1,136 @@ +newUntypedWorkflowStub( + 'Extra_Update_UpdateWithStart', + WorkflowOptions::new()->withTaskQueue($feature->taskQueue), + ); + + /** @see TestWorkflow::add */ + $handle = $client->updateWithStart($stub, 'await', ['key']); + + // Complete workflow + /** @see TestWorkflow::exit */ + $stub->signal('exit'); + $result = $stub->getResult(); + + $this->assertSame(['key' => null], (array)$result); + $this->assertFalse($handle->hasResult()); + } + + #[Test] + public function failWithBadUpdateName( + WorkflowClientInterface $client, + Feature $feature, + ): void { + $stub = $client->newUntypedWorkflowStub( + 'Extra_Update_UpdateWithStart', + WorkflowOptions::new()->withTaskQueue($feature->taskQueue), + ); + + try { + $client->updateWithStart($stub, 'await1234', ['key']); + $this->fail('Update must fail'); + } catch (WorkflowUpdateException $e) { + $this->assertStringContainsString('await1234', $e->getPrevious()->getMessage()); + } finally { + try { + $stub->getResult(timeout: 1); + $this->fail('Workflow must fail'); + } catch (WorkflowFailedException $e) { + $this->assertTrue(true); + } + } + } + + #[Test] + public function failOnReuseExistingWorkflowId( + WorkflowClientInterface $client, + Feature $feature, + ): void { + $id = Uuid::uuid7()->__toString(); + $stub1 = $client->newUntypedWorkflowStub( + 'Extra_Update_UpdateWithStart', + WorkflowOptions::new()->withTaskQueue($feature->taskQueue)->withWorkflowId($id), + ); + $stub2 = $client->newUntypedWorkflowStub( + 'Extra_Update_UpdateWithStart', + WorkflowOptions::new()->withTaskQueue($feature->taskQueue)->withWorkflowId($id), + ); + + // Run first + /** @see TestWorkflow::add */ + $client->updateWithStart($stub1, 'await', ['key']); + try { + $this->expectException(WorkflowExecutionAlreadyStartedException::class); + // Run second + $client->updateWithStart($stub2, 'await', ['key']); + } finally { + $stub1->signal('exit'); + } + } +} + +#[WorkflowInterface] +class TestWorkflow +{ + private array $awaits = []; + private bool $updateStarted = false; + private bool $exit = false; + + #[WorkflowMethod(name: "Extra_Update_UpdateWithStart")] + public function handle() + { + $this->updateStarted or throw new \RuntimeException('Not started with update'); + yield Workflow::await(fn() => $this->exit); + return $this->awaits; + } + + /** + * @param non-empty-string $name + * @return mixed + */ + #[Workflow\UpdateMethod(name: 'await')] + public function add(string $name): mixed + { + $this->updateStarted = true; + $this->awaits[$name] ??= null; + yield Workflow::await(fn() => $this->awaits[$name] !== null); + return $this->awaits[$name]; + } + + #[Workflow\UpdateValidatorMethod(forUpdate: 'await')] + public function validateAdd(string $name): void + { + empty($name) and throw new \InvalidArgumentException('Name must not be empty'); + } + + #[Workflow\SignalMethod] + public function exit(): void + { + $this->exit = true; + } +} diff --git a/tests/Acceptance/Harness/ChildWorkflow/ThrowOnExecuteTest.php b/tests/Acceptance/Harness/ChildWorkflow/ThrowOnExecuteTest.php index 3a8b77743..6c26c5528 100644 --- a/tests/Acceptance/Harness/ChildWorkflow/ThrowOnExecuteTest.php +++ b/tests/Acceptance/Harness/ChildWorkflow/ThrowOnExecuteTest.php @@ -51,8 +51,6 @@ public function run() { return yield Workflow::newChildWorkflowStub( ChildWorkflow::class, - // TODO: remove after https://github.com/temporalio/sdk-php/issues/451 is fixed - Workflow\ChildWorkflowOptions::new()->withTaskQueue(Workflow::getInfo()->taskQueue), )->run(); } } @@ -63,6 +61,7 @@ class ChildWorkflow #[WorkflowMethod('Harness_ChildWorkflow_ThrowsOnExecute_Child')] public function run() { + yield 1; throw new ApplicationFailure('Test message', 'TestError', true, EncodedValues::fromValues([['foo' => 'bar']])); } } diff --git a/tests/Acceptance/Harness/Update/DeduplicationTest.php b/tests/Acceptance/Harness/Update/DeduplicationTest.php index c4bccf64c..bc65d1746 100644 --- a/tests/Acceptance/Harness/Update/DeduplicationTest.php +++ b/tests/Acceptance/Harness/Update/DeduplicationTest.php @@ -9,6 +9,7 @@ use Temporal\Client\Update\UpdateOptions; use Temporal\Client\WorkflowClientInterface; use Temporal\Client\WorkflowStubInterface; +use Temporal\Exception\Client\WorkflowUpdateException; use Temporal\Tests\Acceptance\App\Attribute\Stub; use Temporal\Tests\Acceptance\App\TestCase; use Temporal\Workflow; @@ -39,8 +40,13 @@ public function check( self::assertSame(1, $handle1->getResult(1)); self::assertSame(1, $handle2->getResult(1)); - # This only needs to start to unblock the workflow - $stub->startUpdate('my_update'); + try { + # This only needs to start to unblock the workflow + $stub->startUpdate('my_update'); + } catch (WorkflowUpdateException) { + # Workflow Update failed because the Workflow completed before the Update completed + # It's OK in this case + } # There should be two accepted updates, and only one of them should be completed with the set id $totalUpdates = 0; diff --git a/tests/Arch/ArchTest.php b/tests/Arch/ArchTest.php new file mode 100644 index 000000000..112b3ba26 --- /dev/null +++ b/tests/Arch/ArchTest.php @@ -0,0 +1,40 @@ +layer(); + + foreach ($layer as $object) { + foreach ($object->uses as $use) { + foreach ($functions as $function) { + $function === $use and throw new \Exception( + \sprintf( + 'Function `%s()` is used in %s.', + $function, + $object->name, + ), + ); + } + } + } + + $this->assertTrue(true); + } +} diff --git a/tests/Fixtures/src/Workflow/GeneratorWorkflow.php b/tests/Fixtures/src/Workflow/GeneratorWorkflow.php index 7fbede754..7d228b829 100644 --- a/tests/Fixtures/src/Workflow/GeneratorWorkflow.php +++ b/tests/Fixtures/src/Workflow/GeneratorWorkflow.php @@ -12,6 +12,7 @@ namespace Temporal\Tests\Workflow; use Temporal\Activity\ActivityOptions; +use Temporal\Common\RetryOptions; use Temporal\Internal\Workflow\ActivityProxy; use Temporal\Tests\Activity\SimpleActivity; use Temporal\Workflow; @@ -27,7 +28,9 @@ public function handler( // typed stub $simple = Workflow::newActivityStub( SimpleActivity::class, - ActivityOptions::new()->withStartToCloseTimeout(5) + ActivityOptions::new()->withStartToCloseTimeout(5)->withRetryOptions( + RetryOptions::new()->withMaximumAttempts(1) + ) ); return [ @@ -38,11 +41,16 @@ public function handler( /** * @param ActivityProxy|SimpleActivity $simple - * @param string $input - * @return \Generator */ private function doSomething(ActivityProxy $simple, string $input): \Generator { + $input === 'error' and throw new \Exception('error from generator'); + + if ($input === 'failure') { + yield $simple->fail(); + throw new \Exception('Unreachable statement'); + } + $result = []; $result[] = yield $simple->echo($input); $result[] = yield $simple->echo($input); diff --git a/tests/Functional/Client/TypedStubTestCase.php b/tests/Functional/Client/TypedStubTestCase.php index 3ae0b0625..13e3052c5 100644 --- a/tests/Functional/Client/TypedStubTestCase.php +++ b/tests/Functional/Client/TypedStubTestCase.php @@ -11,7 +11,9 @@ namespace Temporal\Tests\Functional\Client; +use Temporal\Exception\Client\WorkflowFailedException; use Temporal\Exception\Client\WorkflowQueryException; +use Temporal\Exception\Failure\ActivityFailure; use Temporal\Exception\InvalidArgumentException; use Temporal\Tests\DTO\Message; use Temporal\Tests\DTO\User; @@ -151,6 +153,34 @@ public function testGeneratorCoroutines() ); } + public function testGeneratorErrorCoroutines() + { + $client = $this->createClient(); + $simple = $client->newWorkflowStub(GeneratorWorkflow::class); + + try { + $simple->handler('error'); + $this->fail('Expected exception to be thrown'); + } catch (WorkflowFailedException $e) { + $this->assertStringContainsString('error from generator', $e->getPrevious()->getMessage()); + } + } + + public function testGeneratorErrorInNestedActionCoroutines() + { + $client = $this->createClient(); + $simple = $client->newWorkflowStub(GeneratorWorkflow::class); + + try { + $simple->handler('failure'); + $this->fail('Expected exception to be thrown'); + } catch (WorkflowFailedException $e) { + $this->assertStringNotContainsString('Unreachable statement', $e->getPrevious()->getMessage()); + $this->assertInstanceOf(ActivityFailure::class, $e->getPrevious()); + $this->assertStringContainsString('failed activity', $e->getPrevious()->getPrevious()->getMessage()); + } + } + /** * @group skip-on-test-server */ diff --git a/tests/Functional/bootstrap.php b/tests/Functional/bootstrap.php index 1128b7843..df7b3642f 100644 --- a/tests/Functional/bootstrap.php +++ b/tests/Functional/bootstrap.php @@ -9,10 +9,14 @@ chdir(__DIR__ . '/../..'); require_once __DIR__ . '/../../vendor/autoload.php'; +$sysInfo = \Temporal\Testing\SystemInfo::detect(); + $environment = Environment::create(); $environment->startTemporalTestServer(); (new SearchAttributeTestInvoker)(); -$environment->startRoadRunner('./rr serve -c .rr.silent.yaml -w tests/Functional'); +$environment->startRoadRunner( + rrCommand: sprintf('%s serve -c .rr.silent.yaml -w tests/Functional', $sysInfo->rrExecutable), +); register_shutdown_function(fn() => $environment->stop()); // Default feature flags diff --git a/tests/Unit/Exception/FailureConverterTestCase.php b/tests/Unit/Exception/FailureConverterTestCase.php index ee32ee962..59db778ee 100644 --- a/tests/Unit/Exception/FailureConverterTestCase.php +++ b/tests/Unit/Exception/FailureConverterTestCase.php @@ -72,10 +72,17 @@ public function testStackTraceStringForAdditionalContextEvenWhenClassIsNotPresen $trace, ); - self::assertStringContainsString( - 'Temporal\Tests\Unit\Exception\FailureConverterTestCase->Temporal\Tests\Unit\Exception\{closure}()', - $trace, - ); + if (\PHP_VERSION_ID < 80400) { + self::assertStringContainsString( + 'Temporal\Tests\Unit\Exception\FailureConverterTestCase->Temporal\Tests\Unit\Exception\{closure}()', + $trace, + ); + } else { + self::assertStringContainsString( + 'Temporal\Tests\Unit\Exception\FailureConverterTestCase->{closure:Temporal\Tests\Unit\Exception\FailureConverterTestCase::testStackTraceStringForAdditionalContextEvenWhenClassIsNotPresented()', + $trace, + ); + } self::assertStringContainsString( 'call_user_func(Closure)', diff --git a/tests/Unit/Framework/WorkerFactoryMock.php b/tests/Unit/Framework/WorkerFactoryMock.php index 9b91b12a4..d181f2eb2 100644 --- a/tests/Unit/Framework/WorkerFactoryMock.php +++ b/tests/Unit/Framework/WorkerFactoryMock.php @@ -33,6 +33,7 @@ use Temporal\Worker\Environment\Environment; use Temporal\Worker\Environment\EnvironmentInterface; use Temporal\Worker\LoopInterface; +use Temporal\Worker\ServiceCredentials; use Temporal\Worker\Transport\Codec\CodecInterface; use Temporal\Worker\Transport\Command\ServerRequestInterface; use Temporal\Worker\Transport\Command\ServerResponseInterface; @@ -183,7 +184,7 @@ private function createReader(): ReaderInterface private function createRouter(): RouterInterface { $router = new Router(); - $router->add(new Router\GetWorkerInfo($this->queues, $this->marshaller)); + $router->add(new Router\GetWorkerInfo($this->queues, $this->marshaller, ServiceCredentials::create())); return $router; } diff --git a/tests/Unit/Router/InvokeActivityTestCase.php b/tests/Unit/Router/InvokeActivityTestCase.php index 8bd1b8c58..972c9f66f 100644 --- a/tests/Unit/Router/InvokeActivityTestCase.php +++ b/tests/Unit/Router/InvokeActivityTestCase.php @@ -32,6 +32,7 @@ final class InvokeActivityTestCase extends AbstractUnit { private ServiceContainer $services; private InvokeActivity $router; + private ActivityContext $activityContext; protected function setUp(): void { diff --git a/tests/Unit/Router/StartWorkflowTestCase.php b/tests/Unit/Router/StartWorkflowTestCase.php index df068592f..e5e47c93a 100644 --- a/tests/Unit/Router/StartWorkflowTestCase.php +++ b/tests/Unit/Router/StartWorkflowTestCase.php @@ -37,6 +37,8 @@ final class StartWorkflowTestCase extends AbstractUnit { private ServiceContainer $services; private StartWorkflow $router; + private WorkflowContext $workflowContext; + private MarshallerInterface $marshaller; protected function setUp(): void { diff --git a/tests/Unit/Worker/ServiceCredentialsTestCase.php b/tests/Unit/Worker/ServiceCredentialsTestCase.php new file mode 100644 index 000000000..d817354d3 --- /dev/null +++ b/tests/Unit/Worker/ServiceCredentialsTestCase.php @@ -0,0 +1,22 @@ +withApiKey('test'); + + $this->assertNotSame($dto, $new); + $this->assertSame('test', $new->apiKey); + $this->assertSame('', $dto->apiKey); + } +} diff --git a/tests/Unit/Workflow/DeferredGeneratorTestCase.php b/tests/Unit/Workflow/DeferredGeneratorTestCase.php new file mode 100644 index 000000000..691c9b375 --- /dev/null +++ b/tests/Unit/Workflow/DeferredGeneratorTestCase.php @@ -0,0 +1,271 @@ +compare( + fn() => (function () { + yield 1; + yield 42 => 2; + yield 3; + })(), + [ + 'current', 'key', 'current', 'key', + 'next', + 'current', 'key', 'current', 'key', 'valid', + 'next', + ['send', 'foo'], + 'current', 'key', 'current', 'key', 'valid', + ], + ); + } + + public function testCompareSendingValues(): void + { + $this->compare( + fn() => (function () { + $a = yield; + $b = yield $a; + $c = yield $b; + return [$a, $b, $c]; + })(), + [ + ['send', 'foo'], + ['send', 'bar'], + ['send', 'baz'], + 'current', 'key', 'current', 'key', 'valid', + ], + ); + } + + public function testCompareThrowingExceptions(): void + { + $this->compare( + fn() => (function () { + try { + yield; + throw new \Exception('foo'); + } catch (\Exception $e) { + yield $e->getMessage(); + } + })(), + [ + 'current', 'key', 'current', 'key', 'valid', + 'next', + 'current', 'key', 'current', 'key', 'valid', + 'next', + 'rewind', + ], + ); + } + + public function testCompareReturn(): void + { + $this->compare( + fn() => (function () { + yield 1; + return 2; + })(), + [ + 'current', 'key', 'current', 'key', 'valid', + 'next', + 'getReturn', + ], + ); + } + + public function testCompareEmpty(): void + { + $this->compare( + fn() => (function () { + yield from []; + })(), + [ + 'current', 'key', 'current', 'key', 'valid', + 'next', + 'rewind', + ], + ); + } + + public function testCompareEmptyReturn(): void + { + $this->compare( + fn() => (function () { + return; + yield; + })(), + [ + 'current', 'key', 'current', 'key', 'valid', + 'next', + 'getReturn', + ], + ); + } + + public function testCompareEmptyThrow(): void + { + $this->compare( + fn() => (function () { + throw new \Exception('foo'); + yield; + })(), + ['current', 'key', 'current', 'key', 'valid', 'getReturn', 'next', 'rewind'], + ); + } + + public function testCompareEmptyThrowValid(): void + { + $this->compare( + fn() => (function () { + throw new \Exception('foo'); + yield; + })(), + ['valid', 'valid'], + ); + } + + public function testCompareEmptyThrowGetReturn(): void + { + $this->compare( + fn() => (function () { + throw new \Exception('foo'); + yield; + })(), + ['getReturn', 'getReturn'], + ); + } + + public function testCompareEmptyThrowGetKey(): void + { + $this->compare( + fn() => (function () { + throw new \Exception('foo'); + yield; + })(), + ['key', 'key'], + ); + } + + public function testLazyNotGeneratorValidGetReturn(): void + { + $lazy = DeferredGenerator::fromHandler(fn() => 42, EncodedValues::empty()); + + $this->assertFalse($lazy->valid()); + $this->assertSame(42, $lazy->getReturn()); + } + + public function testLazyNotGeneratorCurrent(): void + { + $lazy = DeferredGenerator::fromHandler(fn() => 42, EncodedValues::empty()); + + $this->assertNull($lazy->current()); + } + + public function testLazyNotGeneratorWithException(): void + { + $lazy = DeferredGenerator::fromHandler(fn() => throw new \Exception('foo'), EncodedValues::empty()); + + $this->expectException(\Exception::class); + $this->expectExceptionMessage('foo'); + + $lazy->current(); + } + + + public function testLazyNotGeneratorWithException2(): void + { + $lazy = DeferredGenerator::fromHandler(fn() => throw new \Exception('foo'), EncodedValues::empty()); + + try { + $lazy->current(); + } catch (\Exception) { + // ignore + } + + $this->assertNull($lazy->current()); + } + + /** + * @param callable(): \Generator $generatorFactory + * @param iterable $actions + * @return void + */ + private function compare( + callable $generatorFactory, + iterable $actions, + ): void { + $c1 = $c2 = null; + $caught = false; + $gen = $generatorFactory(); + $def = DeferredGenerator::fromGenerator($generatorFactory()); + $def->catch(function (\Throwable $e) use (&$c1) { + $c1 = $e; + }); + $lazy = DeferredGenerator::fromHandler($generatorFactory, EncodedValues::empty()); + $lazy->catch(function (\Throwable $e) use (&$c2) { + $c2 = $e; + }); + + + $i = 0; + foreach ($actions as $tuple) { + ++$i; + $argLess = \is_string($tuple); + $method = $argLess ? $tuple : $tuple[0]; + $arg = $argLess ? null : $tuple[1]; + $c1 = $c2 = $e = $e2 = $e3 = $result = $result2 = $result3 = null; + + try { + $result = $argLess ? $gen->$method() : $gen->$method($arg); + } catch (\Throwable $e) { + # ignore + } + + try { + $result2 = $argLess ? $def->$method() : $def->$method($arg); + } catch (\Throwable $e2) { + # ignore + } + + try { + $result3 = $argLess ? $lazy->$method() : $lazy->$method($arg); + } catch (\Throwable $e3) { + # ignore + } + + $this->assertSame($result, $result2, "Generator and DeferredGenerator results differ [$i] `$method`"); + $this->assertSame($result, $result3, "Generator and DeferredGenerator results differ [$i] `$method`"); + if ($caught) { + $this->assertNull($c1, "Error was caught twice [$i] `$method`"); + $this->assertNull($c2, "Error was caught twice [$i] `$method`"); + } + if ($e !== null) { + $this->assertNotNull($e2, "Generator and DeferredGenerator exceptions differ [$i] `$method`"); + $this->assertNotNull($e3, "Generator and DeferredGenerator exceptions differ [$i] `$method`"); + if (!$caught && !\in_array($method, ['rewind'], true)) { + $this->assertNotNull($c1, "Error was not caught [$i] `$method`"); + $this->assertNotNull($c2, "Error was not caught [$i] `$method`"); + $caught = true; + } + } else { + $this->assertNull($e2, "Generator and DeferredGenerator exceptions differ [$i] `$method`"); + $this->assertNull($e3, "Generator and DeferredGenerator exceptions differ [$i] `$method`"); + $this->assertNull($c1, "There must be no error caught [$i] `$method`"); + $this->assertNull($c2, "There must be no error caught [$i] `$method`"); + } + } + } +}