Repository navigation
Invalidate the transform cache when config or stub files change - #129
Merged
rcalicdan merged 1 commit intoNov 14, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
rcalicdan
approved these changes
Nov 11, 2026
Member
The cache key was built from the version prefix, the file path and its mtime only. The transformed source also depends on configuration (respect_ignore_tags, inline_vars, eliminate_statically_proven_checks, stubs, ...), so editing typephp.php or a stub file kept serving files transformed under the old settings until `cache:clear` was run. A file cached as ignored stayed unchecked after respect_ignore_tags was turned off for an audit run. Add a fingerprint of the configuration to the cache key, minus the keys that only steer runtime behaviour (on_violation, report_file, ...), plus the effective eliminate_statically_proven_checks value (it has an env override) and the path and mtime of every configured stub file. Stub mtimes follow cache_check_mtime, like source mtimes.
naxvog
force-pushed
the
fix/cache-key-config-fingerprint
branch
from
November 11, 2026 08:35
087ff34 to
ce97ef3
Compare
Member
|
@naxvog Thank you for this PR.. |
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.
Problem
The transform cache key is
VERSION_PREFIX + path + mtime. The transformed source also depends on configuration and stub files:respect_ignore_tags(StreamWrapper::transformSource(),ContractVisitor,PropertyHookInjector)inline_vars.properties(ContractVisitor)eliminate_statically_proven_checks, including itsTYPEPHP_ELIMINATE_STATICALLY_PROVEN_CHECKSenv overrideFunctionContractInjector,ContractVisitor)Editing
typephp.phpor a stub file therefore keeps serving files that were transformed under the old settings until someone runscache:clear. Example: a file cached whilerespect_ignore_tagswastruestays unchecked after the option is set tofalsefor an audit run, which is the use case the config comment describes.Fix
CacheManager::getCacheKey()now includes a fingerprint, computed once per process, of:on_violation,report_file,fail_on_report,fail_on_zero_files,redact_values,enabled,auto_boot,cache,cache_dir,cache_check_mtime). The list is an exclude list, so a new option invalidates the cache by default.eliminate_statically_proven_checksvalue.StubManager::getFilesFingerprint(), no parsing). Stub mtimes followcache_check_mtime, like source mtimes.Verification
tests/Internal/Io/CacheManagerTest.php: the key is stable across runtime-only changes, changes withrespect_ignore_tagsand the env override, and follows stub file mtimes only whilecache_check_mtimeis on.Notes
VERSION_PREFIXbump.