Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Jul 25, 2023
1 parent 34d4814 commit 841734b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Counter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function hit(string $id): CounterState
do {
// Last increment time.
// In GCRA it's known as arrival time.
$lastIncrementTimeInMilliseconds = $this->timer->now()->format('U.u') * 1000;
$lastIncrementTimeInMilliseconds = round($this->timer->now()->format('U.u') * 1000);

Check failure on line 78 in src/Counter.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.0-ubuntu-latest

InvalidOperand

src/Counter.php:78:54: InvalidOperand: Cannot perform a numeric operation with a non-numeric type string (see https://psalm.dev/058)

Check failure on line 78 in src/Counter.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

InvalidOperand

src/Counter.php:78:54: InvalidOperand: Cannot perform a numeric operation with a non-numeric type non-empty-string (see https://psalm.dev/058)

Check failure on line 78 in src/Counter.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.0-ubuntu-latest

InvalidOperand

src/Counter.php:78:54: InvalidOperand: Cannot perform a numeric operation with a non-numeric type string (see https://psalm.dev/058)

Check failure on line 78 in src/Counter.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

InvalidOperand

src/Counter.php:78:54: InvalidOperand: Cannot perform a numeric operation with a non-numeric type non-empty-string (see https://psalm.dev/058)

Check failure on line 78 in src/Counter.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.2-ubuntu-latest

InvalidOperand

src/Counter.php:78:54: InvalidOperand: Cannot perform a numeric operation with a non-numeric type non-empty-string (see https://psalm.dev/058)

$lastStoredTheoreticalNextIncrementTime = $this->getLastStoredTheoreticalNextIncrementTime($id);

Expand Down
6 changes: 3 additions & 3 deletions tests/Storage/ApcuStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testSaveIfNotExistsWithExistsKey(): void
{
$storage = $this->getStorage();

$value = (new DateTimeImmutable())->format('U.u') * 1000;
$value = round((new DateTimeImmutable())->format('U.u') * 1000);
$storage->saveIfNotExists('exists_key', $value, self::DEFAULT_TTL);

$result = $storage->saveIfNotExists('exists_key', $value, self::DEFAULT_TTL);
Expand All @@ -47,7 +47,7 @@ public function testSaveCompareAndSwapWithNewKey(): void
{
$storage = $this->getStorage();

$newValue = (new DateTimeImmutable())->format('U.u') * 1000;
$newValue = round((new DateTimeImmutable())->format('U.u') * 1000);
$oldValue = (int) $storage->get('new_key');

$result = $storage->saveCompareAndSwap(
Expand All @@ -64,7 +64,7 @@ public function testSaveCompareAndSwapWithExistsKeyButOldValueDifferent(): void
{
$storage = $this->getStorage();

$oldValue = (new DateTimeImmutable())->format('U.u') * 1000;
$oldValue = round((new DateTimeImmutable())->format('U.u') * 1000);
$storage->saveIfNotExists('exists_key', $oldValue, self::DEFAULT_TTL);

$oldValue = $oldValue + 200;
Expand Down
8 changes: 4 additions & 4 deletions tests/Storage/StorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ public function testGetKeyWithExistsKey(): void
{
$storage = $this->getStorage();

$want = (new DateTimeImmutable())->format('U.u') * 1000;
$want = round((new DateTimeImmutable())->format('U.u') * 1000);

$storage->saveIfNotExists('exists_key', $want, self::DEFAULT_TTL);

$result = $storage->get('exists_key');

$this->assertEquals($result, $want);
$this->assertEquals($want, $result);
}

public function testSaveIfNotExistsWithNewKey(): void
{
$storage = $this->getStorage();

$value = (new DateTimeImmutable())->format('U.u') * 1000;
$value = round((new DateTimeImmutable())->format('U.u') * 1000);

$result = $storage->saveIfNotExists('new_key', $value, self::DEFAULT_TTL);

Expand All @@ -58,7 +58,7 @@ public function testSaveCompareAndSwapWithExistsKeyAndOldValueSame(): void
{
$storage = $this->getStorage();

$oldValue = (new DateTimeImmutable())->format('U.u') * 1000;
$oldValue = round((new DateTimeImmutable())->format('U.u') * 1000);
$storage->saveIfNotExists('exists_key', $oldValue, self::DEFAULT_TTL);

$newValue = $oldValue + 100;
Expand Down

0 comments on commit 841734b

Please sign in to comment.