diff --git a/src/Interceptor/Trait/WorkflowOutboundCallsInterceptorTrait.php b/src/Interceptor/Trait/WorkflowOutboundCallsInterceptorTrait.php index 686123b21..1fdeb8a0d 100644 --- a/src/Interceptor/Trait/WorkflowOutboundCallsInterceptorTrait.php +++ b/src/Interceptor/Trait/WorkflowOutboundCallsInterceptorTrait.php @@ -25,6 +25,7 @@ use Temporal\Interceptor\WorkflowOutboundCalls\SideEffectInput; use Temporal\Interceptor\WorkflowOutboundCalls\SignalExternalWorkflowInput; use Temporal\Interceptor\WorkflowOutboundCalls\TimerInput; +use Temporal\Interceptor\WorkflowOutboundCalls\UpsertMemoInput; use Temporal\Interceptor\WorkflowOutboundCalls\UpsertSearchAttributesInput; use Temporal\Interceptor\WorkflowOutboundCalls\UpsertTypedSearchAttributesInput; use Temporal\Interceptor\WorkflowOutboundCallsInterceptor; @@ -148,6 +149,16 @@ public function getVersion(GetVersionInput $input, callable $next): PromiseInter return $next($input); } + /** + * Default implementation of the `upsertMemo` method. + * + * @see WorkflowOutboundCallsInterceptor::upsertMemo() + */ + public function upsertMemo(UpsertMemoInput $input, callable $next): PromiseInterface + { + return $next($input); + } + /** * Default implementation of the `upsertSearchAttributes` method. * diff --git a/src/Workflow.php b/src/Workflow.php index d24edc323..52885f5c7 100644 --- a/src/Workflow.php +++ b/src/Workflow.php @@ -912,34 +912,35 @@ public static function allHandlersFinished(): bool * For example: * * ```php - * Workflow::upsertMemo([ - * 'key1' => 'value', - * 'key3' => ['subkey1' => 'value'] - * 'key4' => 'value', - * }); - * - * Workflow::upsertMemo([ - * 'key2' => 'value', - * 'key3' => ['subkey2' => 'value'] - * 'key4' => null, - * ]); + * Workflow::upsertMemo([ + * 'key1' => 'value', + * 'key3' => ['subkey1' => 'value'] + * 'key4' => 'value', + * }); + * + * Workflow::upsertMemo([ + * 'key2' => 'value', + * 'key3' => ['subkey2' => 'value'] + * 'key4' => null, + * ]); * ``` * * would result in the Workflow having these Memo: * * ```php - * [ - * 'key1' => 'value', - * 'key2' => 'value', - * 'key3' => ['subkey2' => 'value'], // Note this object was completely replaced - * // Note that 'key4' was completely removed - * ] + * [ + * 'key1' => 'value', + * 'key2' => 'value', + * 'key3' => ['subkey2' => 'value'], // Note this object was completely replaced + * // Note that 'key4' was completely removed + * ] * ``` * * @param array $values * * @since SDK 2.13.0 * @since RoadRunner 2024.3.3 + * @link https://docs.temporal.io/glossary#memo */ public static function upsertMemo(array $values): void { diff --git a/tests/Acceptance/App/Runtime/RRStarter.php b/tests/Acceptance/App/Runtime/RRStarter.php index 18e4e7575..43e8b4db6 100644 --- a/tests/Acceptance/App/Runtime/RRStarter.php +++ b/tests/Acceptance/App/Runtime/RRStarter.php @@ -63,4 +63,9 @@ public function stop(): void $this->environment->stop(); $this->started = false; } + + public function __destruct() + { + $this->stop(); + } } diff --git a/tests/Acceptance/Extra/Workflow/MemoTest.php b/tests/Acceptance/Extra/Workflow/MemoTest.php index 811aef09b..0a5b041b8 100644 --- a/tests/Acceptance/Extra/Workflow/MemoTest.php +++ b/tests/Acceptance/Extra/Workflow/MemoTest.php @@ -109,8 +109,6 @@ public function handle() fn(): bool => $this->exit, ); - tr(Workflow::getInfo()->memo); - return Workflow::getInfo()->memo; } diff --git a/tests/Unit/Interceptor/TraitsTestCase.php b/tests/Unit/Interceptor/TraitsTestCase.php new file mode 100644 index 000000000..4895b1941 --- /dev/null +++ b/tests/Unit/Interceptor/TraitsTestCase.php @@ -0,0 +1,82 @@ +