Skip to content

Add @psalm-flow for Cache::remember, sear, flexible#653

Draft
alies-dev wants to merge 1 commit intomasterfrom
worktree-588-cache-psalm-flow
Draft

Add @psalm-flow for Cache::remember, sear, flexible#653
alies-dev wants to merge 1 commit intomasterfrom
worktree-588-cache-psalm-flow

Conversation

@alies-dev
Copy link
Copy Markdown
Collaborator

Issue to Solve

Cache::remember(), rememberForever(), sear(), and flexible() 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) -> return annotations to Repository and Cache facade stubs for remember, rememberForever, sear, flexible.

Current status: template return types work correctly today (e.g., Cache::remember('k', 60, fn(): int => 42) infers int). Taint propagation is blocked by a Psalm limitation where @psalm-flow connects 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 @todo references to the upstream issue.

Checklist

  • Tests cover the change (type test in tests/Type/ and/or unit test in tests/Unit/)
  • Documentation is updated (if needed, otherwise remove this item)

@alies-dev alies-dev self-assigned this Apr 5, 2026
@alies-dev alies-dev marked this pull request as draft April 5, 2026 10:55
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
@alies-dev alies-dev force-pushed the worktree-588-cache-psalm-flow branch from c2c6e5b to 7340d26 Compare April 5, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

taint: add @psalm-flow for Cache::remember/sear/flexible (taint propagation through callbacks)

1 participant