Skip to content

Commit 53f94ac

Browse files
authored
Fix Implicit conversion loses precision (#42)
1 parent e7727f2 commit 53f94ac

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/FileLockResolver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ public function fnv(string $str): float
225225

226226
for ($i = 0; $i < strlen($str); $i++) {
227227
$hash ^= ord($str[$i]);
228-
$hash *= 16777619;
228+
$hash *= 0x01000193;
229+
$hash &= 0xFFFFFFFF;
229230
}
230231

231232
return $hash;

tests/FileLockResolverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ public function test_update_contents_with_content()
216216
public function test_fnv()
217217
{
218218
$resolver = new FileLockResolver;
219-
$a = $resolver->fnv('1');
220-
$b = $resolver->fnv(1);
219+
$a = $resolver->fnv('1674128900558');
220+
$b = $resolver->fnv(1674128900558);
221221

222222
$this->assertEquals($a, $b);
223223
}

0 commit comments

Comments
 (0)