Skip to content

Commit

Permalink
I think memcache may be truncating floats to ints, so if it is not a …
Browse files Browse the repository at this point in the history
…float, cast it to and change the check to a simple is_numeric(..) one
  • Loading branch information
DavidGoodwin committed Oct 22, 2024
1 parent 667cf12 commit 50c8ece
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Adapter/Memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public function set(string $key, float $value, int $ttl): bool
public function get(string $key): float
{
$ret = $this->realGet($key);
if (is_float($ret)) {
return $ret;
if (is_numeric($ret)) {
return (float) $ret;

Check failure on line 26 in src/Adapter/Memcached.php

View workflow job for this annotation

GitHub Actions / sanity-check

RedundantCast

src/Adapter/Memcached.php:26:20: RedundantCast: Redundant cast to float (see https://psalm.dev/262)
}
throw new \InvalidArgumentException("Unexpected data type from memcache, expected float, got " . gettype($ret));
}
Expand Down

0 comments on commit 50c8ece

Please sign in to comment.