Skip to content

Commit

Permalink
Do not implicitly cast glob's return type
Browse files Browse the repository at this point in the history
The comment above mentions that on some platforms, it might return
false, and this is why there is a check in the first place. Let us do
exactly what is mentioned in the comment.
  • Loading branch information
greg0ire committed Feb 21, 2024
1 parent 380b5b6 commit adadf1f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Cache/Region/FileLockRegion.php
Original file line number Diff line number Diff line change
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 Down

0 comments on commit adadf1f

Please sign in to comment.