Skip to content

Commit

Permalink
Fix psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Aug 19, 2024
1 parent c0e3e88 commit b9aa569
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
8 changes: 0 additions & 8 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1540,14 +1540,6 @@
<code><![CDATA[run]]></code>
</MissingReturnType>
</file>
<file src="src/Worker/WorkerOptions.php">
<LessSpecificReturnStatement>
<code><![CDATA[new self()]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[static]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/WorkerFactory.php">
<DeprecatedClass>
<code><![CDATA[new AnnotationReader()]]></code>
Expand Down
13 changes: 9 additions & 4 deletions src/Internal/Marshaller/Type/EnumValueType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ class EnumValueType extends Type implements RuleFactoryInterface
{
private const ERROR_MESSAGE = 'Invalid Enum value. Expected: int or string scalar value for BackedEnum. %s given.';

/** @var class-string<\UnitEnum> */
/** @var class-string<\BackedEnum> */
private string $classFQCN;

public function __construct(MarshallerInterface $marshaller, string $class = null)
/**
* @param class-string<\BackedEnum>|null $class
*/
public function __construct(MarshallerInterface $marshaller, ?string $class = null)
{
$this->classFQCN = $class ?? throw new \RuntimeException('Enum is required.');
\is_a($class, BackedEnum::class, true) ?: throw new \RuntimeException('Enum must be an instance of BackedEnum.');
\is_a($class, BackedEnum::class, true) ?: throw new \RuntimeException(
'Class for EnumValueType must be an instance of BackedEnum.',
);
parent::__construct($marshaller);
}

Expand Down Expand Up @@ -61,7 +66,7 @@ public function parse($value, $current)
return $value;
}

if (\is_scalar($value)) {
if (\is_int($value) || \is_string($value)) {
return $this->classFQCN::from($value);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Worker/WorkerOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ public function withEnableSessionWorker(bool $enable = true): self
* For now, if user doesn't specify one, a new uuid will be used as the
* resourceID.
*
* @param non-empty-string|null $identifier
* @param string|null $identifier
*/
#[Pure]
public function withSessionResourceId(?string $identifier): self
Expand Down

0 comments on commit b9aa569

Please sign in to comment.