Skip to content

Commit f5561d7

Browse files
committed
Don't set empty metadata dto in proto.
1 parent 662fe2a commit f5561d7

5 files changed

Lines changed: 70 additions & 18 deletions

File tree

psalm-baseline.xml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="6.8.9@e856423a5dc38d65e56b5792750c557277afe393">
2+
<files psalm-version="6.9.1@81c8a77c0793d450fee40265cfe68891df11d505">
33
<file src="src/Activity.php">
44
<ImplicitToStringCast>
55
<code><![CDATA[$type]]></code>
@@ -45,12 +45,23 @@
4545
<code><![CDATA[$loader->current()]]></code>
4646
</PossiblyNullPropertyAssignmentValue>
4747
</file>
48+
<file src="src/Client/Common/RpcRetryOptions.php">
49+
<TypeDoesNotContainType>
50+
<code><![CDATA[withInitialInterval]]></code>
51+
<code><![CDATA[withMaximumInterval]]></code>
52+
</TypeDoesNotContainType>
53+
</file>
4854
<file src="src/Client/GRPC/Context.php">
4955
<ArgumentTypeCoercion>
5056
<code><![CDATA[$format]]></code>
5157
</ArgumentTypeCoercion>
5258
</file>
5359
<file src="src/Client/Schedule/Action/StartWorkflowAction.php">
60+
<DocblockTypeContradiction>
61+
<code><![CDATA[parse]]></code>
62+
<code><![CDATA[parse]]></code>
63+
<code><![CDATA[parse]]></code>
64+
</DocblockTypeContradiction>
5465
<InaccessibleProperty>
5566
<code><![CDATA[$workflowType->name]]></code>
5667
</InaccessibleProperty>
@@ -114,6 +125,9 @@
114125
<code><![CDATA[$this->excludeCalendarList]]></code>
115126
<code><![CDATA[$this->excludeCalendarList]]></code>
116127
</DeprecatedProperty>
128+
<DocblockTypeContradiction>
129+
<code><![CDATA[parse]]></code>
130+
</DocblockTypeContradiction>
117131
</file>
118132
<file src="src/Client/ScheduleClient.php">
119133
<DeprecatedProperty>
@@ -662,12 +676,34 @@
662676
<code><![CDATA[setDataConverter]]></code>
663677
</UndefinedInterfaceMethod>
664678
</file>
679+
<file src="src/Internal/Mapper/WorkflowExecutionConfigMapper.php">
680+
<DocblockTypeContradiction>
681+
<code><![CDATA[parse]]></code>
682+
<code><![CDATA[parse]]></code>
683+
<code><![CDATA[parse]]></code>
684+
<code><![CDATA[parse]]></code>
685+
<code><![CDATA[parse]]></code>
686+
</DocblockTypeContradiction>
687+
<RedundantConditionGivenDocblockType>
688+
<code><![CDATA[parse]]></code>
689+
</RedundantConditionGivenDocblockType>
690+
</file>
665691
<file src="src/Internal/Mapper/WorkflowExecutionInfoMapper.php">
666692
<ArgumentTypeCoercion>
667693
<code><![CDATA[$message->getTaskQueue()]]></code>
668694
<code><![CDATA[(int) $message->getHistorySizeBytes()]]></code>
669695
<code><![CDATA[(int) $message->getStateTransitionCount()]]></code>
670696
</ArgumentTypeCoercion>
697+
<DocblockTypeContradiction>
698+
<code><![CDATA[parse]]></code>
699+
<code><![CDATA[parse]]></code>
700+
<code><![CDATA[parse]]></code>
701+
<code><![CDATA[parse]]></code>
702+
<code><![CDATA[parse]]></code>
703+
</DocblockTypeContradiction>
704+
<RedundantConditionGivenDocblockType>
705+
<code><![CDATA[parse]]></code>
706+
</RedundantConditionGivenDocblockType>
671707
</file>
672708
<file src="src/Internal/Marshaller/Mapper/AttributeMapper.php">
673709
<MissingClosureParamType>
@@ -872,7 +908,17 @@
872908
</DeprecatedConstant>
873909
<RedundantCondition>
874910
<code><![CDATA[$nullEmpty && $seconds === 0 && $micros === 0]]></code>
911+
<code><![CDATA[parse]]></code>
875912
</RedundantCondition>
913+
<TypeDoesNotContainNull>
914+
<code><![CDATA[parse]]></code>
915+
</TypeDoesNotContainNull>
916+
<TypeDoesNotContainType>
917+
<code><![CDATA[parse]]></code>
918+
<code><![CDATA[parse]]></code>
919+
<code><![CDATA[parse]]></code>
920+
<code><![CDATA[parse]]></code>
921+
</TypeDoesNotContainType>
876922
</file>
877923
<file src="src/Internal/Support/DateTime.php">
878924
<InvalidReturnStatement>

src/Client/Common/RpcRetryOptions.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ public static function fromRetryOptions(RetryOptions $options): self
4848
* Interval of the first retry, on congestion related failures (i.e. RESOURCE_EXHAUSTED errors).
4949
* If coefficient is 1.0 then it is used for all retries. Defaults to 1000ms.
5050
*
51-
* @param DateIntervalValue|null $interval Interval to wait on first retry, on congestion failures.
51+
* @param mixed $interval Interval to wait on first retry, on congestion failures.
5252
* Defaults to 1000ms, which is used if set to {@see null}.
53+
* Can be parseable string, int|float in seconds, {@see \DateInterval}, or {@see Duration}
54+
* @return static
5355
*
56+
* @psalm-assert DateIntervalValue|null $interval
5457
* @psalm-suppress ImpureMethodCall
5558
*/
5659
#[Pure]
57-
public function withCongestionInitialInterval($interval): self
60+
public function withCongestionInitialInterval(mixed $interval): self
5861
{
5962
$interval === null || DateInterval::assert($interval) or throw new \InvalidArgumentException(
6063
'Invalid interval value.',

src/Common/RetryOptions.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Temporal\Common;
1313

14+
use Google\Protobuf\Duration;
1415
use JetBrains\PhpStorm\Pure;
1516
use Temporal\Activity\ActivityOptions;
1617
use Temporal\Api\Common\V1\RetryPolicy;
@@ -122,11 +123,12 @@ public function mergeWith(?MethodRetry $retry = null): self
122123
/**
123124
* @psalm-suppress ImpureMethodCall
124125
*
125-
* @param DateIntervalValue|null $interval
126+
* @param mixed $interval parseable string, null, int|float in seconds, {@see \DateInterval}, or {@see Duration}
126127
* @return static
128+
* @psalm-assert DateIntervalValue|null $interval
127129
*/
128130
#[Pure]
129-
public function withInitialInterval($interval): self
131+
public function withInitialInterval(mixed $interval): self
130132
{
131133
\assert(DateInterval::assert($interval) || $interval === null);
132134

@@ -153,11 +155,12 @@ public function withBackoffCoefficient(float $coefficient): self
153155
/**
154156
* @psalm-suppress ImpureMethodCall
155157
*
156-
* @param DateIntervalValue|null $interval
158+
* @param mixed $interval parseable string, null, int|float in seconds, {@see \DateInterval}, or {@see Duration}
157159
* @return static
160+
* @psalm-assert DateIntervalValue|null $interval
158161
*/
159162
#[Pure]
160-
public function withMaximumInterval($interval): self
163+
public function withMaximumInterval(mixed $interval): self
161164
{
162165
\assert(DateInterval::assert($interval) || $interval === null);
163166

src/Internal/Support/DateInterval.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ final class DateInterval
5151
];
5252

5353
/**
54-
* @param DateIntervalValue $interval
5554
* @param DateIntervalFormat $format
55+
*
56+
* @psalm-assert DateIntervalValue|null $interval
5657
* @psalm-suppress InvalidOperand
5758
*/
58-
public static function parse($interval, string $format = self::FORMAT_MILLISECONDS): CarbonInterval
59+
public static function parse(mixed $interval, string $format = self::FORMAT_MILLISECONDS): CarbonInterval
5960
{
6061
switch (true) {
6162
case \is_string($interval):
@@ -126,10 +127,11 @@ public static function parse($interval, string $format = self::FORMAT_MILLISECON
126127
}
127128

128129
/**
129-
* @param DateIntervalValue|null $interval
130130
* @param DateIntervalFormat $format
131+
*
132+
* @psalm-assert DateIntervalValue|null $interval
131133
*/
132-
public static function parseOrNull($interval, string $format = self::FORMAT_MILLISECONDS): ?CarbonInterval
134+
public static function parseOrNull(mixed $interval, string $format = self::FORMAT_MILLISECONDS): ?CarbonInterval
133135
{
134136
if ($interval === null) {
135137
return null;
@@ -139,9 +141,9 @@ public static function parseOrNull($interval, string $format = self::FORMAT_MILL
139141
}
140142

141143
/**
142-
* @param DateIntervalValue $interval
144+
* @return ($interval is DateIntervalValue ? true : false)
143145
*/
144-
public static function assert($interval): bool
146+
public static function assert(mixed $interval): bool
145147
{
146148
$isParsable = \is_string($interval) || \is_int($interval) || \is_float($interval);
147149

tests/Unit/DTO/WorkflowOptionsTestCase.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Temporal\Tests\Unit\DTO;
1313

1414
use Carbon\CarbonInterval;
15-
use Temporal\Api\Common\V1\Memo;
1615
use Temporal\Api\Common\V1\SearchAttributes;
1716
use Temporal\Client\WorkflowOptions;
1817
use Temporal\Common\IdReusePolicy;
@@ -182,13 +181,12 @@ public function testEmptyMemoCasting(): void
182181
$this->assertNull($dto->toMemo(DataConverter::createDefault()));
183182
}
184183

185-
public function testNonEmptyMemoCasting(): void
184+
public function testDoNotSetEmptyMemo(): void
186185
{
187186
$dto = WorkflowOptions::new()
188-
->withMemo([])
189-
;
187+
->withMemo([]);
190188

191-
$this->assertInstanceOf(Memo::class, $dto->toMemo(DataConverter::createDefault()));
189+
$this->assertNull($dto->toMemo(DataConverter::createDefault()));
192190
}
193191

194192
public function testCantSetTypedSAIfUntypedExist(): void

0 commit comments

Comments
 (0)