Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove implicit casts in FileLock.php #11276

Merged
merged 4 commits into from
Feb 21, 2024
Merged
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
12 changes: 5 additions & 7 deletions src/Cache/Region/FileLockRegion.php
Original file line number Diff line number Diff line change
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
Loading