Skip to content

Commit

Permalink
Merge pull request #11276 from greg0ire/no-cast-filelock
Browse files Browse the repository at this point in the history
Remove implicit casts in FileLock.php
  • Loading branch information
greg0ire committed Feb 21, 2024
2 parents fcf1116 + adadf1f commit e4c2709
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/Cache/Region/FileLockRegion.php
Expand Up @@ -67,7 +67,7 @@ private function isLocked(CacheKey $key, Lock|null $lock = null): bool
$time = $this->getLockTime($filename);
$content = $this->getLockContent($filename);

if (! $content || ! $time) {
if ($content === false || $time === false) {
@unlink($filename);

return false;
Expand Down Expand Up @@ -156,12 +156,10 @@ public function evictAll(): bool
{
// The check below is necessary because on some platforms glob returns false
// when nothing matched (even though no errors occurred)
$filenames = glob(sprintf('%s/*.%s', $this->directory, self::LOCK_EXTENSION));
$filenames = glob(sprintf('%s/*.%s', $this->directory, self::LOCK_EXTENSION)) ?: [];

if ($filenames) {
foreach ($filenames as $filename) {
@unlink($filename);
}
foreach ($filenames as $filename) {
@unlink($filename);
}

return $this->region->evictAll();
Expand All @@ -176,7 +174,7 @@ public function lock(CacheKey $key): Lock|null
$lock = Lock::createLockRead();
$filename = $this->getLockFileName($key);

if (! @file_put_contents($filename, $lock->value, LOCK_EX)) {
if (@file_put_contents($filename, $lock->value, LOCK_EX) === false) {
return null;
}

Expand Down

0 comments on commit e4c2709

Please sign in to comment.