Skip to content

Commit

Permalink
Fix psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Feb 4, 2025
1 parent b15a177 commit 505b187
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 79 deletions.
79 changes: 15 additions & 64 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<files psalm-version="6.2.0@814dfde37b43a1fe6d9b0996e08b19661af53bc5">
<file src="src/Activity.php">
<ImplicitToStringCast>
<code><![CDATA[$type]]></code>
Expand Down Expand Up @@ -40,6 +40,11 @@
<code><![CDATA[recordHeartbeatByToken]]></code>
</MissingReturnType>
</file>
<file src="src/Client/Common/Paginator.php">
<PossiblyNullPropertyAssignmentValue>
<code><![CDATA[$loader->current()]]></code>
</PossiblyNullPropertyAssignmentValue>
</file>
<file src="src/Client/GRPC/Context.php">
<ArgumentTypeCoercion>
<code><![CDATA[$format]]></code>
Expand Down Expand Up @@ -226,68 +231,10 @@
<code><![CDATA[valueUnset]]></code>
</ImpureMethodCall>
</file>
<file src="src/Common/SearchAttributes/SearchAttributeKey/BoolValue.php">
<LessSpecificReturnStatement>
<code><![CDATA[$this->prepareValueSet($value)]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[SearchAttributeUpdate]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Common/SearchAttributes/SearchAttributeKey/DatetimeValue.php">
<LessSpecificReturnStatement>
<code><![CDATA[$this->prepareValueSet(match (true) {
\is_string($value) => new \DateTimeImmutable($value),
$value instanceof \DateTimeImmutable => $value,
default => \DateTimeImmutable::createFromInterface($value),
})]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[SearchAttributeUpdate]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Common/SearchAttributes/SearchAttributeKey/FloatValue.php">
<LessSpecificReturnStatement>
<code><![CDATA[$this->prepareValueSet($value)]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[SearchAttributeUpdate]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Common/SearchAttributes/SearchAttributeKey/IntValue.php">
<LessSpecificReturnStatement>
<code><![CDATA[$this->prepareValueSet($value)]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[SearchAttributeUpdate]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Common/SearchAttributes/SearchAttributeKey/KeywordListValue.php">
<LessSpecificReturnStatement>
<code><![CDATA[$this->prepareValueSet($values)]]></code>
</LessSpecificReturnStatement>
<MismatchingDocblockParamType>
<code><![CDATA[iterable<string|\Stringable>]]></code>
</MismatchingDocblockParamType>
<MoreSpecificReturnType>
<code><![CDATA[SearchAttributeUpdate]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Common/SearchAttributes/SearchAttributeKey/KeywordValue.php">
<LessSpecificReturnStatement>
<code><![CDATA[$this->prepareValueSet((string) $value)]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[SearchAttributeUpdate]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Common/SearchAttributes/SearchAttributeKey/StringValue.php">
<LessSpecificReturnStatement>
<code><![CDATA[$this->prepareValueSet((string) $value)]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[SearchAttributeUpdate]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Common/TypedSearchAttributes.php">
<InvalidArgument>
Expand Down Expand Up @@ -517,6 +464,8 @@
</PossiblyNullArgument>
<PossiblyNullReference>
<code><![CDATA[getName]]></code>
<code><![CDATA[getStartWorkflow]]></code>
<code><![CDATA[getUpdateWorkflow]]></code>
</PossiblyNullReference>
<RedundantConditionGivenDocblockType>
<code><![CDATA[$delay !== null]]></code>
Expand Down Expand Up @@ -810,11 +759,6 @@
<MoreSpecificReturnType>
<code><![CDATA[null|\Closure(Message): mixed]]></code>
</MoreSpecificReturnType>
<PossiblyFalseArgument>
<code><![CDATA[$now->modify(
\sprintf('+%d seconds +%d microseconds', $input->getSeconds(), $input->getNanos() / 1000),
)]]></code>
</PossiblyFalseArgument>
</file>
<file src="src/Internal/Marshaller/Type/ArrayType.php">
<MoreSpecificImplementedParamType>
Expand Down Expand Up @@ -1175,6 +1119,9 @@
</ArgumentTypeCoercion>
</file>
<file src="src/Internal/Transport/Router/StartWorkflow.php">
<PossiblyFalseArgument>
<code><![CDATA[\json_encode($param)]]></code>
</PossiblyFalseArgument>
<UnnecessaryVarAnnotation>
<code><![CDATA[Input]]></code>
</UnnecessaryVarAnnotation>
Expand Down Expand Up @@ -1458,6 +1405,10 @@
</PossiblyNullReference>
</file>
<file src="src/Worker/Transport/Codec/ProtoCodec/Encoder.php">
<PossiblyFalseArgument>
<code><![CDATA[\json_encode($cmd->getOptions(), JSON_INVALID_UTF8_IGNORE | JSON_UNESCAPED_UNICODE)]]></code>
<code><![CDATA[\json_encode($options)]]></code>
</PossiblyFalseArgument>
<PossiblyNullArgument>
<code><![CDATA[$cmd->getFailure()]]></code>
</PossiblyNullArgument>
Expand Down
13 changes: 0 additions & 13 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,4 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<UndefinedDocblockClass>
<errorLevel type="suppress">
<referencedClass name="UnitEnum" />
</errorLevel>
</UndefinedDocblockClass>
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="BackedEnum" />
<referencedClass name="UnitEnum" />
</errorLevel>
</UndefinedClass>
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/Client/ClientOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ClientOptions
*/
public function __construct()
{
$this->identity = \sprintf('%d@%s', \getmypid(), \gethostname());
$this->identity = \sprintf('%d@%s', (string) \getmypid(), (string) \gethostname());
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Common/Uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ private static function bytes(): string
{
$bytes = \random_bytes(16);

/** @psalm-suppress PossiblyInvalidArrayAccess */
$timeHi = (int) \unpack('n*', \substr($bytes, 6, 2))[1];
$timeHiAndVersion = \pack('n*', self::version($timeHi, 4));

/** @psalm-suppress PossiblyInvalidArrayAccess */
$clockSeqHi = (int) \unpack('n*', \substr($bytes, 8, 2))[1];
$clockSeqHiAndReserved = \pack('n*', self::variant($clockSeqHi));

Expand Down
4 changes: 3 additions & 1 deletion src/Internal/Support/Inheritance.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public static function extends(string $haystack, string $class): bool
return true;
}

foreach (\class_parents($haystack) as $parent) {
$parents = \class_parents($haystack);
/** @var list<class-string> $parents */
foreach ($parents as $parent) {
if (self::extends($parent, $class)) {
return true;
}
Expand Down

0 comments on commit 505b187

Please sign in to comment.