Skip to content

Commit

Permalink
Fix psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Sep 24, 2024
1 parent 613a0c2 commit b47c8a4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
6 changes: 0 additions & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,8 @@
<PossiblyNullReference>
<code><![CDATA[getName]]></code>
<code><![CDATA[getName]]></code>
<code><![CDATA[getNonRetryable]]></code>
<code><![CDATA[getScheduledEventId]]></code>
<code><![CDATA[getStackTrace]]></code>
<code><![CDATA[getWorkflowExecution]]></code>
<code><![CDATA[getWorkflowId]]></code>
<code><![CDATA[hasDetails]]></code>
<code><![CDATA[hasDetails]]></code>
<code><![CDATA[hasLastHeartbeatDetails]]></code>
<code><![CDATA[hasLastHeartbeatDetails]]></code>
<code><![CDATA[setStackTrace]]></code>
</PossiblyNullReference>
Expand Down
6 changes: 4 additions & 2 deletions src/Exception/Failure/FailureConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ public static function mapExceptionToFailure(\Throwable $e, DataConverterInterfa
$info->setType($e->getType());
$info->setNonRetryable($e->isNonRetryable());

// Set Next Retry Delay
$nextRetry = DateInterval::toDuration($e->getNextRetryDelay());
$nextRetry === null or $info->setNextRetryDelay($nextRetry);

if (!$e->getDetails()->isEmpty()) {
$info->setDetails($e->getDetails()->toPayloads());
}

$failure->setApplicationFailureInfo($info);
$info->setNextRetryDelay(DateInterval::toDuration($e->getNextRetryDelay()));
break;

case $e instanceof TimeoutFailure:
Expand Down Expand Up @@ -270,7 +273,6 @@ private static function createFailureException(Failure $failure, DataConverterIn
case $failure->hasChildWorkflowExecutionFailureInfo():
$info = $failure->getChildWorkflowExecutionFailureInfo();
$execution = $info->getWorkflowExecution();
\assert($info instanceof ChildWorkflowExecutionFailureInfo);
\assert($execution instanceof WorkflowExecution);

return new ChildWorkflowFailure(
Expand Down
19 changes: 18 additions & 1 deletion tests/Unit/Exception/FailureConverterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function testMapFailureToException(): void
$this->assertSame("test stack trace:\n#1\n#2\n#3", $exception->getOriginalStackTrace());
}

public function testMapExceptionToFailure(): void
public function testMapExceptionToFailureWithNextRetryDelay(): void
{
$converter = DataConverter::createDefault();
$exception = new ApplicationFailure(
Expand All @@ -155,4 +155,21 @@ public function testMapExceptionToFailure(): void
$this->assertSame(5 * 60 + 13, $failure->getApplicationFailureInfo()->getNextRetryDelay()->getSeconds());
$this->assertSame(15_000, $failure->getApplicationFailureInfo()->getNextRetryDelay()->getNanos());
}

public function testMapExceptionToFailure(): void
{
$converter = DataConverter::createDefault();
$exception = new ApplicationFailure(
'message',
'type',
true,
);

$failure = FailureConverter::mapExceptionToFailure($exception, $converter);

$this->assertSame('type', $failure->getApplicationFailureInfo()->getType());
$this->assertTrue($failure->getApplicationFailureInfo()->getNonRetryable());
$this->assertEmpty($failure->getApplicationFailureInfo()->getDetails());
$this->assertNull($failure->getApplicationFailureInfo()->getNextRetryDelay());
}
}

0 comments on commit b47c8a4

Please sign in to comment.