44
55namespace Temporal \Support \Factory ;
66
7- use DateInterval ;
87use Temporal \Client \WorkflowClientInterface ;
98use Temporal \Client \WorkflowOptions ;
109use Temporal \Client \WorkflowStubInterface ;
1110use Temporal \Common \IdReusePolicy ;
11+ use Temporal \Common \Priority ;
12+ use Temporal \Common \TypedSearchAttributes ;
13+ use Temporal \Common \WorkflowIdConflictPolicy ;
1214use Temporal \Internal \Client \WorkflowProxy ;
1315use Temporal \Internal \Workflow \ChildWorkflowProxy ;
1416use Temporal \Support \Attribute \RetryPolicy ;
2123use Temporal \Workflow \ChildWorkflowCancellationType as ChildCancelType ;
2224use Temporal \Workflow \ChildWorkflowStubInterface ;
2325use Temporal \Workflow \ParentClosePolicy ;
24- use Throwable ;
2526
2627final class WorkflowStub
2728{
@@ -35,30 +36,30 @@ final class WorkflowStub
3536 * @param int<0, max>|null $retryAttempts Maximum number of attempts. When exceeded the retries stop even
3637 * if not expired yet. If not set or set to 0, it means unlimited, and rely on activity
3738 * {@see ActivityOptions::$scheduleToCloseTimeout} to stop.
38- * @param DateInterval|string|int|null $retryInitInterval Backoff interval for the first retry.
39+ * @param \ DateInterval|string|int|null $retryInitInterval Backoff interval for the first retry.
3940 * If $retryBackoff is 1.0 then it is used for all retries.
4041 * Int value in seconds.
41- * @param DateInterval|string|int|null $retryMaxInterval Maximum backoff interval between retries.
42+ * @param \ DateInterval|string|int|null $retryMaxInterval Maximum backoff interval between retries.
4243 * Exponential backoff leads to interval increase. This value is the cap of the interval.
4344 * Int value in seconds.
4445 * Default is 100x of $retryInitInterval.
4546 * @param float|null $retryBackoff Coefficient used to calculate the next retry backoff interval.
4647 * The next retry interval is previous interval multiplied by this coefficient.
4748 * Note: Must be greater than 1.0
48- * @param list<class-string<Throwable>> $nonRetryables Non-retriable errors. Temporal server will stop retry
49+ * @param list<class-string<\ Throwable>> $nonRetryables Non-retriable errors. Temporal server will stop retry
4950 * if error type matches this list.
50- * @param DateInterval|string|int $executionTimeout The maximum time that parent workflow is willing to wait
51+ * @param \ DateInterval|string|int $executionTimeout The maximum time that parent workflow is willing to wait
5152 * for a child execution (which includes retries and continue as new calls).
5253 * If exceeded the child is automatically terminated by the Temporal service.
5354 * Int value in seconds.
54- * @param DateInterval|string|int $runTimeout The time after which workflow run is automatically terminated by
55+ * @param \ DateInterval|string|int $runTimeout The time after which workflow run is automatically terminated by
5556 * the Temporal service.
5657 * Do not rely on the run timeout for business level timeouts.
5758 * It is preferred to use in workflow timers for this purpose.
5859 * Int value in seconds.
5960 * @param int<10, 60> $taskTimeout Maximum execution time of a single workflow task. Int value in seconds.
6061 * Default is 10 seconds. The maximum accepted value is 60 seconds.
61- * @param DateInterval|string|int $startDelay Time to wait before dispatching the first Workflow task.
62+ * @param \ DateInterval|string|int $startDelay Time to wait before dispatching the first Workflow task.
6263 * If the Workflow gets a Signal before the delay, a Workflow task will be dispatched and the rest
6364 * of the delay will be ignored. A Signal from {@see WorkflowClientInterface::startWithSignal()}
6465 * won't trigger a workflow task. Cannot be set the same time as a $cronSchedule.
@@ -98,6 +99,11 @@ public static function workflow(
9899 ?string $ cronSchedule = null ,
99100 array $ searchAttributes = [],
100101 array $ memo = [],
102+ ?TypedSearchAttributes $ typedSearchAttributes = null ,
103+ WorkflowIdConflictPolicy $ idConflictPolicy = WorkflowIdConflictPolicy::Unspecified,
104+ ?Priority $ priority = null ,
105+ string $ staticSummary = '' ,
106+ string $ staticDetails = '' ,
101107 ): object {
102108 $ isTyped = self ::isClassOrInterface ($ type );
103109 /** @psalm-suppress ArgumentTypeCoercion */
@@ -115,21 +121,32 @@ public static function workflow(
115121 attribute: $ attributes ->first (RetryPolicy::class),
116122 );
117123
118- $ options = WorkflowOptions::new ()->withRetryOptions ($ retryOptions );
124+ $ options = WorkflowOptions::new ()
125+ ->withRetryOptions ($ retryOptions )
126+ ->withStaticSummary ($ staticSummary )
127+ ->withStaticDetails ($ staticDetails );
128+ ;
119129 $ taskQueue ??= $ attributes ->first (TaskQueue::class)?->name;
120130 $ taskQueue === null or $ options = $ options ->withTaskQueue ($ taskQueue );
121131 // Start options
122132 $ startDelay === 0 or $ options = $ options ->withWorkflowStartDelay ($ startDelay );
123133 $ eagerStart and $ options = $ options ->withEagerStart (true );
124134 $ cronSchedule === null or $ options = $ options ->withCronSchedule ($ cronSchedule );
135+ $ priority === null or $ options = $ options ->withPriority ($ priority );
136+ $ typedSearchAttributes === null or $ options = $ options ->withTypedSearchAttributes ($ typedSearchAttributes );
137+
125138 // Timeouts
126139 $ executionTimeout === 0 or $ options = $ options ->withWorkflowExecutionTimeout ($ executionTimeout );
127140 $ runTimeout === 0 or $ options = $ options ->withWorkflowRunTimeout ($ executionTimeout );
128141 $ taskTimeout !== 10 and $ options = $ options ->withWorkflowTaskTimeout (\max (60 , $ taskTimeout ));
142+
129143 // Workflow ID
130- $ workflowId === null or $ options = $ options ->withWorkflowId ((string )$ workflowId );
144+ $ workflowId === null or $ options = $ options ->withWorkflowId ((string ) $ workflowId );
131145 $ workflowIdReusePolicy === IdReusePolicy::Unspecified or $ options = $ options
132146 ->withWorkflowIdReusePolicy ($ workflowIdReusePolicy );
147+ $ idConflictPolicy === WorkflowIdConflictPolicy::Unspecified or $ options = $ options
148+ ->withWorkflowIdConflictPolicy ($ idConflictPolicy );
149+
133150 // Metadata
134151 $ searchAttributes === [] or $ options = $ options ->withSearchAttributes ($ searchAttributes );
135152 $ memo === [] or $ options = $ options ->withMemo ($ memo );
@@ -152,23 +169,23 @@ public static function workflow(
152169 * @param int<0, max>|null $retryAttempts Maximum number of attempts. When exceeded the retries stop even
153170 * if not expired yet. If not set or set to 0, it means unlimited, and rely on activity
154171 * {@see ActivityOptions::$scheduleToCloseTimeout} to stop.
155- * @param DateInterval|string|int|null $retryInitInterval Backoff interval for the first retry.
172+ * @param \ DateInterval|string|int|null $retryInitInterval Backoff interval for the first retry.
156173 * If $retryBackoff is 1.0 then it is used for all retries.
157174 * Int value in seconds.
158- * @param DateInterval|string|int|null $retryMaxInterval Maximum backoff interval between retries.
175+ * @param \ DateInterval|string|int|null $retryMaxInterval Maximum backoff interval between retries.
159176 * Exponential backoff leads to interval increase. This value is the cap of the interval.
160177 * Int value in seconds.
161178 * Default is 100x of $retryInitInterval.
162179 * @param float|null $retryBackoff Coefficient used to calculate the next retry backoff interval.
163180 * The next retry interval is previous interval multiplied by this coefficient.
164181 * Note: Must be greater than 1.0
165- * @param list<class-string<Throwable>> $nonRetryables Non-retriable errors. Temporal server will stop retry
182+ * @param list<class-string<\ Throwable>> $nonRetryables Non-retriable errors. Temporal server will stop retry
166183 * if error type matches this list.
167- * @param DateInterval|string|int $executionTimeout The maximum time that parent workflow is willing to wait
184+ * @param \ DateInterval|string|int $executionTimeout The maximum time that parent workflow is willing to wait
168185 * for a child execution (which includes retries and continue as new calls).
169186 * If exceeded the child is automatically terminated by the Temporal service.
170187 * Int value in seconds.
171- * @param DateInterval|string|int $runTimeout The time after which workflow run is automatically terminated by
188+ * @param \ DateInterval|string|int $runTimeout The time after which workflow run is automatically terminated by
172189 * the Temporal service.
173190 * Do not rely on the run timeout for business level timeouts.
174191 * It is preferred to use in workflow timers for this purpose.
@@ -209,6 +226,9 @@ public static function childWorkflow(
209226 ?string $ cronSchedule = null ,
210227 array $ searchAttributes = [],
211228 array $ memo = [],
229+ ?Priority $ priority = null ,
230+ string $ staticSummary = '' ,
231+ string $ staticDetails = '' ,
212232 ): object {
213233 $ isTyped = self ::isClassOrInterface ($ type );
214234 /** @psalm-suppress ArgumentTypeCoercion */
@@ -226,7 +246,10 @@ public static function childWorkflow(
226246 attribute: $ attributes ->first (RetryPolicy::class),
227247 );
228248
229- $ options = Workflow \ChildWorkflowOptions::new ()->withRetryOptions ($ retryOptions );
249+ $ options = Workflow \ChildWorkflowOptions::new ()
250+ ->withRetryOptions ($ retryOptions )
251+ ->withStaticSummary ($ staticSummary )
252+ ->withStaticDetails ($ staticDetails );
230253
231254 $ taskQueue ??= $ attributes ->first (TaskQueue::class)?->name;
232255 $ taskQueue === null or $ options = $ options ->withTaskQueue ($ taskQueue );
@@ -237,15 +260,17 @@ public static function childWorkflow(
237260 ->withParentClosePolicy ($ parentClosePolicy );
238261 $ childCancellationType === ChildCancelType::TRY_CANCEL or $ options = $ options
239262 ->withChildWorkflowCancellationType ($ childCancellationType );
263+ $ priority === null or $ options = $ options ->withPriority ($ priority );
240264
241265 // Timeouts
242266 $ executionTimeout === 0 or $ options = $ options ->withWorkflowExecutionTimeout ($ executionTimeout );
243267 $ runTimeout === 0 or $ options = $ options ->withWorkflowRunTimeout ($ executionTimeout );
244268 $ taskTimeout !== 10 and $ options = $ options ->withWorkflowTaskTimeout (\max (60 , $ taskTimeout ));
245269 // Workflow ID
246- $ workflowId === null or $ options = $ options ->withWorkflowId ((string )$ workflowId );
270+ $ workflowId === null or $ options = $ options ->withWorkflowId ((string ) $ workflowId );
247271 $ workflowIdReusePolicy === IdReusePolicy::Unspecified or $ options = $ options
248272 ->withWorkflowIdReusePolicy ($ workflowIdReusePolicy );
273+
249274 // Metadata
250275 $ searchAttributes === [] or $ options = $ options ->withSearchAttributes ($ searchAttributes );
251276 $ memo === [] or $ options = $ options ->withMemo ($ memo );
0 commit comments