Simplify FileCacheStorage::save() with atomic dumpFile() - #8312
Open
TomasVotruba wants to merge 1 commit into
Open
Simplify FileCacheStorage::save() with atomic dumpFile()#8312TomasVotruba wants to merge 1 commit into
TomasVotruba wants to merge 1 commit into
Conversation
Replace the manual temp-file + copy + unlink handling with Symfony's Filesystem::dumpFile(), which already writes atomically via a temporary file and rename internally. Finishes the cleanup started in #498 that had since regressed. Drops the now-unused Nette\Utils\Random import. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ti6vHRo3xLSHw84rxUw6Lb
TomasVotruba
marked this pull request as ready for review
August 7, 2026 09:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Simplifies
FileCacheStorage::save()to write the cache file with a single atomicFilesystem::dumpFile()call, removing the manual temp-file handling.Why
This finishes the cleanup started in #498 ("Sync FileCacheStorage with changes from phpstan-src"), which had since regressed. The write path currently does its own atomic-write dance:
But the already-injected Symfony
Filesystem::dumpFile()already writes atomically via a temporary file + rename internally, so doing it again on the Rector side is redundant syscalls — the exact overhead #498 set out to remove (it was a notable bottleneck on Windows).How
Randomtemp path +FileSystem::write+@copy+@unlink+DIRECTORY_SEPARATORfallback with$this->filesystem->dumpFile($filePath, ...).var_exporterror guard (catches non-exportable data such as closures).Nette\Utils\Randomimport.Behaviour is unchanged; this is a smaller/faster write path.
Generated by Claude Code