Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,4 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<!-- #[\Override] is a PHP 8.3 attribute, the package still supports PHP 8.2 -->
<MissingOverrideAttribute errorLevel="suppress" />
<!-- int|float TTL multiplied by an int, the product is rounded and cast to int right away -->
<InvalidOperand>
<errorLevel type="suppress">
<file name="src/Lock.php" />
</errorLevel>
</InvalidOperand>
</issueHandlers>
</psalm>
10 changes: 8 additions & 2 deletions src/Lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
*
* @throws \InvalidArgumentException If ttl is negative.
*/
#[\Override]
public function lock(
string $resource,
?string $id = null,
Expand Down Expand Up @@ -78,6 +79,7 @@
*
* @throws \InvalidArgumentException If ttl is negative.
*/
#[\Override]
public function lockRead(
string $resource,
?string $id = null,
Expand Down Expand Up @@ -105,6 +107,7 @@
* @param non-empty-string $id Lock ID from lock or lockRead method.
* @return bool Returns true if the lock was released successfully, false otherwise.
*/
#[\Override]
public function release(string $resource, string $id): bool
{
$request = new Request();
Expand All @@ -126,6 +129,7 @@
* @param non-empty-string $resource The name of the resource to be unlocked
* @return bool Returns true if all locks were released successfully, false otherwise
*/
#[\Override]
public function forceRelease(string $resource): bool
{
$request = new Request();
Expand All @@ -145,6 +149,7 @@
* @param string|null $id Lock ID from lock or lockRead method.
* @return bool Returns true if the resource is locked, false otherwise.
*/
#[\Override]
public function exists(string $resource, ?string $id = null): bool
{
$request = new Request();
Expand All @@ -166,6 +171,7 @@
*
* @throws \InvalidArgumentException If ttl is negative.
*/
#[\Override]
public function updateTTL(string $resource, string $id, int|float|\DateInterval $ttl): bool
{
$request = new Request();
Expand All @@ -181,12 +187,12 @@
private function convertTimeToMicroseconds(int|float|\DateInterval $ttl): int
{
if ($ttl instanceof \DateInterval) {
return (int) \round((int) $ttl->format('%s') * 1_000_000);
return (int) $ttl->format('%s') * 1_000_000;

Check warning on line 190 in src/Lock.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "CastInt": @@ @@ private function convertTimeToMicroseconds(int|float|\DateInterval $ttl): int { if ($ttl instanceof \DateInterval) { - return (int) $ttl->format('%s') * 1_000_000; + return $ttl->format('%s') * 1_000_000; } \assert($ttl >= 0, 'TTL must be positive');
}

\assert($ttl >= 0, 'TTL must be positive');

return (int) \round($ttl * 1_000_000);
return (int) \round((float) $ttl * 1_000_000.0);

Check warning on line 195 in src/Lock.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "CastFloat": @@ @@ \assert($ttl >= 0, 'TTL must be positive'); - return (int) \round((float) $ttl * 1_000_000.0); + return (int) \round($ttl * 1_000_000.0); } /**
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/UuidLockIdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function __construct(
private readonly UuidFactoryInterface $factory = new UuidFactory(),
) {}

#[\Override]
public function generate(): string
{
return $this->factory->uuid4()->toString();
Expand Down
Loading