We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 746ade2 commit 724cd19Copy full SHA for 724cd19
packages/support/src/Filesystem/functions.php
@@ -120,7 +120,15 @@ function read_file(string $filename): string
120
throw Exceptions\PathWasNotReadable::forFile($filename);
121
}
122
123
- [$result, $message] = box(static fn (): false|string => file_get_contents($filename));
+ [$result, $message] = box(static function () use ($filename): false|string {
124
+ $file_pointer = fopen($filename, 'rb');
125
+ flock($file_pointer, LOCK_SH);
126
+ $contents = file_get_contents($filename);
127
+ flock($file_pointer, LOCK_UN);
128
+ fclose($file_pointer);
129
+
130
+ return $contents;
131
+ });
132
133
if (false === $result) {
134
throw new Exceptions\RuntimeException(sprintf(
0 commit comments