Skip to content

Commit 33d0ac2

Browse files
committed
chore: rename retryPolicy to retryOptions
1 parent 022e0d4 commit 33d0ac2

File tree

6 files changed

+21
-28
lines changed

6 files changed

+21
-28
lines changed

src/Internal/Marshaller/Type/ArrayType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public static function makeRule(\ReflectionProperty $property): ?MarshallingRule
6363
*/
6464
public function parse($value, $current): array
6565
{
66+
if ($value === null) {
67+
return [];
68+
}
69+
6670
if (!\is_array($value)) {
6771
throw new \InvalidArgumentException(\sprintf(self::ERROR_INVALID_TYPE, \get_debug_type($value)));
6872
}

src/Workflow/WorkflowInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ final class WorkflowInfo
148148
* @since SDK 2.16.0
149149
*/
150150
#[Marshal(name: 'RetryPolicy')]
151-
public ?RetryOptions $retryPolicy = null;
151+
public ?RetryOptions $retryOptions = null;
152152

153153
/**
154154
* WorkflowInfo constructor.

tests/Acceptance/Extra/Activity/ActivityInfoTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ActivityInfoTest extends TestCase
1919
{
2020
#[Test]
2121
public static function retryPolicy(
22-
#[Stub('Extra_Activity_ActivityInfo', args: [TestWorkflow::ARG_RETRY_POLICY])]
22+
#[Stub('Extra_Activity_ActivityInfo', args: [TestWorkflow::ARG_RETRY_OPTIONS])]
2323
WorkflowStubInterface $stub,
2424
): void {
2525
self::markTestSkipped('See https://github.com/temporalio/sdk-php/issues/602');
@@ -39,17 +39,17 @@ public static function retryPolicy(
3939
#[WorkflowInterface]
4040
class TestWorkflow
4141
{
42-
public const ARG_RETRY_POLICY = 'retryPolicy';
42+
public const ARG_RETRY_OPTIONS = 'retryPolicy';
4343

4444
#[WorkflowMethod(name: "Extra_Activity_ActivityInfo")]
4545
public function handle(string $arg)
4646
{
4747
return yield match ($arg) {
48-
self::ARG_RETRY_POLICY => $this->getRetryPolicy(),
48+
self::ARG_RETRY_OPTIONS => $this->getRetryOptions(),
4949
};
5050
}
5151

52-
private function getRetryPolicy(): PromiseInterface
52+
private function getRetryOptions(): PromiseInterface
5353
{
5454
return Workflow::newActivityStub(
5555
TestActivity::class,
@@ -63,16 +63,16 @@ private function getRetryPolicy(): PromiseInterface
6363
)
6464
->withScheduleToCloseTimeout(10),
6565
)
66-
->retryPolicy();
66+
->retryOptions();
6767
}
6868
}
6969

7070
#[Activity\ActivityInterface(prefix: 'Extra_Activity_ActivityInfo.')]
7171
class TestActivity
7272
{
7373
#[Activity\ActivityMethod]
74-
public function retryPolicy()
74+
public function retryOptions()
7575
{
76-
return Activity::getInfo()->retryPolicy;
76+
return Activity::getInfo()->retryOptions;
7777
}
7878
}

tests/Acceptance/Extra/Workflow/WorkflowInfoTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public static function rootWorkflowExecution(
2828
}
2929

3030
#[Test]
31-
public static function retryPolicy(
32-
#[Stub('Extra_Workflow_WorkflowInfo', args: [MainWorkflow::ARG_RETRY_POLICY], retryOptions: new RetryOptions(
31+
public static function retryOptions(
32+
#[Stub('Extra_Workflow_WorkflowInfo', args: [MainWorkflow::ARG_RETRY_OPTIONS], retryOptions: new RetryOptions(
3333
backoffCoefficient: 3.0,
3434
maximumInterval: '2 minutes',
3535
maximumAttempts: 10,
@@ -50,15 +50,15 @@ public static function retryPolicy(
5050
#[WorkflowInterface]
5151
class MainWorkflow
5252
{
53-
public const ARG_RETRY_POLICY = 'retryPolicy';
53+
public const ARG_RETRY_OPTIONS = 'retryPolicy';
5454
public const ARG_ROOT_EXECUTION = 'rootExecution';
5555

5656
#[WorkflowMethod('Extra_Workflow_WorkflowInfo')]
5757
public function run($arg)
5858
{
5959
return yield match ($arg) {
6060
self::ARG_ROOT_EXECUTION => Workflow::newChildWorkflowStub(ChildWorkflow::class)->run(),
61-
self::ARG_RETRY_POLICY => Workflow::getCurrentContext()->getInfo()->retryPolicy,
61+
self::ARG_RETRY_OPTIONS => Workflow::getCurrentContext()->getInfo()->retryOptions,
6262
};
6363
}
6464
}

tests/Unit/DTO/Type/ArrayType/ArrayTestCase.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,11 @@ public function testUnmarshalling(): void
7676

7777
public function testSetNullToNotNullable(): void
7878
{
79-
try {
80-
$this->unmarshal([
81-
'foo' => null,
82-
], new ArrayDto());
79+
$dto = $this->unmarshal([
80+
'foo' => null,
81+
], new ArrayDto());
8382

84-
$this->fail('Null value should not be allowed.');
85-
} catch (\Throwable $e) {
86-
$this->assertStringContainsString(
87-
'`foo`',
88-
$e->getMessage(),
89-
);
90-
$this->assertInstanceOf(\InvalidArgumentException::class, $e->getPrevious());
91-
$this->assertStringContainsString(
92-
'Passed value must be a type of array, but null given',
93-
$e->getPrevious()->getMessage(),
94-
);
95-
}
83+
self::assertSame([], $dto->foo);
9684
}
9785

9886
protected function getTypeMatchers(): array

tests/Unit/DTO/WorkflowInfoTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function testMarshalling(): void
5151
'Priority' => [
5252
'priority_key' => 0,
5353
],
54+
'RetryPolicy' => null,
5455
];
5556

5657
$this->assertSame($expected, $this->marshal($dto));

0 commit comments

Comments
 (0)