From 79d0b1babdaffe031674034b64e2278d45c6685b Mon Sep 17 00:00:00 2001 From: Faizan Akram Dar Date: Thu, 11 Dec 2025 12:24:32 +0100 Subject: [PATCH] fix: validate files in FilesSnapshot before processing Add check to ensure each file is valid before processing. Without this change filemtime throws an error if the file doesn't exist but is part of cache, which is very common in dev environment. For production it won't matter since is_file is cached, for some reason is_file is also faster than file_exists. Symfony codebase also prefers is_file over file_exists when checking existence of php file. --- src/Cache/FilesSnapshot.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Cache/FilesSnapshot.php b/src/Cache/FilesSnapshot.php index 7ac70861ac..f06ba22e35 100644 --- a/src/Cache/FilesSnapshot.php +++ b/src/Cache/FilesSnapshot.php @@ -7,6 +7,7 @@ use ReflectionClass; use function array_unique; +use function is_file; use function Safe\filemtime; class FilesSnapshot @@ -24,6 +25,10 @@ public static function for(array $files): self $dependencies = []; foreach (array_unique($files) as $file) { + if (!is_file($file)) { + continue; + } + $dependencies[$file] = filemtime($file); }