This commit is contained in:
2026-06-24 20:21:29 +08:00
parent c38fb6ac4c
commit b7712d3d9d
2 changed files with 10 additions and 12 deletions
+7 -8
View File
@@ -10,13 +10,12 @@ class HotReloadState
public function store(array $changedFiles): void
{
$normalizedFiles = array_map([$this, 'normalizePath'], array_filter($changedFiles));
$normalizedFiles = array_values(array_unique($normalizedFiles));
$payload = [
'timestamp' => time(),
'changed_files' => $changedFiles
|> array_filter(...)
|> (fn($x) => array_map([$this, 'normalizePath'], $x))
|> array_unique(...)
|> array_values(...),
'changed_files' => $normalizedFiles,
];
$directory = dirname($this->getFilePath());
@@ -50,9 +49,9 @@ class HotReloadState
}
$files = is_array($data['changed_files'] ?? null) ? $data['changed_files'] : [];
return array_map([$this, 'normalizePath'], $files)
|> array_unique(...)
|> array_values(...);
$files = array_map([$this, 'normalizePath'], $files);
$files = array_values(array_unique($files));
return $files;
}
private function getFilePath(): string
+3 -4
View File
@@ -85,10 +85,9 @@ class ScanManifest
return array_keys($this->entries);
}
return $this->entries
|> array_keys(...)
|> (fn($x) => array_filter($x, fn(string $path) => str_starts_with($path, $prefix)))
|> array_values(...);
$keys = array_keys($this->entries);
$filtered = array_filter($keys, fn(string $path) => str_starts_with($path, $prefix));
return array_values($filtered);
}