Add @psalm-flow for Cache::remember, sear, flexible#653
Draft
Add @psalm-flow for Cache::remember, sear, flexible#653
@psalm-flow for Cache::remember, sear, flexible#653Conversation
Add flow annotations to propagate taint through callback return values for Cache::remember(), rememberForever(), sear(), and flexible(). Stubs added for both Repository and Cache facade with template return types and @psalm-flow ($callback) -> return annotations. Note: taint propagation through Closure params is blocked by a Psalm limitation (vimeo/psalm#11786). The @psalm-flow annotations are semantically correct and will activate once upstream is fixed. Taint tests are included but disabled with @todo references. Closes #588
c2c6e5b to
7340d26
Compare
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.
Issue to Solve
Cache::remember(),rememberForever(),sear(), andflexible()accept a callback whose return value becomes the cached (and returned) value. Without@psalm-flow, taint is lost when user input flows through the callback.Related
Closes #588
Blocked by vimeo/psalm#11786
Solution Description
Add
@psalm-flow ($callback) -> returnannotations toRepositoryandCachefacade stubs forremember,rememberForever,sear,flexible.Current status: template return types work correctly today (e.g.,
Cache::remember('k', 60, fn(): int => 42)infersint). Taint propagation is blocked by a Psalm limitation where@psalm-flowconnects the Closure object's taint node instead of its return value's taint node. Filed upstream: vimeo/psalm#11786.Taint tests are included but disabled with
@todoreferences to the upstream issue.Checklist
tests/Type/and/or unit test intests/Unit/)