Repository navigation
Adopt DataFlowNode::getForTaint() and require Psalm 7.0.0-beta21 - #1456
Conversation
Psalm 7.0.0-beta21 renamed `DataFlowNode::getForTaintSink()` to `getForTaint()` and dropped its fourth parameter: source and sink share one factory now, and the direction is decided by whether the node is handed to `TaintFlowGraph::addSource()` or `addSink()`. The location is always derived from `$code_location`, so `id -> location` stays a pure function (an independent specialization location let one node id resolve to different locations per forked worker, making taint findings shift between runs). `getForTaintSink()` only ever existed in beta20, so the floor moves to beta21 rather than widening the constraint: the class lives under `Psalm\Internal\`, outside the stable plugin API, and changes there ship without a deprecation cycle. The first three arguments are unchanged, so the call site is a rename.
…locks
laravel/framework v13.32.0 added a `@phpstan-this-out` whose type is a
conditional keyed on a parameter, on `Collection::prepend()`:
@phpstan-this-out ($key is null ? static<TKey|int, TValue> : $this)
Psalm 7 cannot parse that shape. It throws an uncaught
`TypeParseTreeException: Unrecognized template '$key'` from `TypeParser` during
the scan phase, before a single issue is reported, so every job that analyses a
project resolving laravel/framework >= 13.32 dies outright. `$key` is a declared
parameter of `prepend()`, and the same conditional in `@return` parses, so the
docblock is not at fault.
The crash reproduces on 7.0.0-beta20 as well, so it is neither a beta21
regression nor caused by this plugin: it is upstream, newly reachable because
Laravel shipped the first docblock of that shape.
Two places pin it:
- composer.json's require-dev constraint, which covers self-analysis and the
unit and type suites. require/ is untouched, so nothing is imposed on users.
- the fresh-app leg, via a new LARAVEL_FRAMEWORK_CONSTRAINT hook in
laravel-test.sh, applied only to the dev-master cells. The 12.12.2 cells keep
resolving exactly what laravel/laravel pins.
Both are temporary and carry the rationale inline; drop them once Psalm parses
the tag.
Keeps the pin confined to the fresh-app workflow cells. composer.json's require-dev is what contributors install locally, and holding the framework back there hides the crash from anyone developing the plugin rather than only from CI. The fresh-app hook in laravel-test.sh stays: that leg builds its own app and is not covered by this constraint either way.
The gate is temporary, so the thing a reader needs first is what has to happen upstream before it can go. Linked at the variable and at the gate itself, since either is a plausible entry point.
There was a problem hiding this comment.
🟡 Changes recommended
The Laravel version workaround must also cover the regular Psalm and type-test jobs to prevent CI crashes.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates the plugin for Psalm 7 beta21 and adds a temporary Laravel compatibility workaround.
Changes:
- Replaces
getForTaintSink()withgetForTaint(). - Raises the Psalm requirement to beta21 and updates documentation.
- Adds an optional Laravel framework constraint for fresh-app CI.
File summaries
| File | Summary |
|---|---|
tests/Application/laravel-test.sh |
Supports framework version constraints. |
src/Handlers/Rules/TimingUnsafeComparisonHandler.php |
Uses Psalm beta21’s taint factory. |
docs/upgrade-v4.md |
Documents the updated Psalm requirement. |
composer.json |
Raises the Psalm dependency floor. |
.github/workflows/test-laravel-app.yml |
Pins fresh-app dev-master cells below Laravel 13.32; other Psalm/type-test jobs remain unprotected. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
laravel/framework v13.32.0 added a `@phpstan-this-out` whose type is a conditional keyed on a parameter, on `Collection::prepend()`. Psalm cannot parse that shape and throws an uncaught TypeParseTreeException from TypeParser during the scan phase, before a single issue is reported, so every cell resolving 13.32 analyses nothing at all. Upstream: vimeo/psalm#11958. It reproduces on Psalm 6.17.2 too, so it is neither a beta21 regression nor plugin-caused. Held in the workflow rather than in composer.json, so that a contributor installing locally still meets the crash instead of having it papered over. Three cells needed it, each reaching 13.32 by a different route: - type tests, via the matrix constraint - unit tests, in the lockfile cells that install straight from composer.json - both laravel/ai legs, same plain install The cells pinned to an exact framework version already resolve below 13.32 and are untouched. The type-test job names now carry the bounded constraint instead of ^13.3. Restore the matrix to ^13.3 when the pin goes.
Missed in the previous commit. This job installs straight from composer.json, so it reaches v13.32.0 and crashes in Psalm's scan phase before analysing anything, same as the test cells. Upstream: vimeo/psalm#11958. Placed ahead of the cache restore deliberately: the cache key hashes composer.lock, which this step rewrites, so pinning afterwards would key the snapshot on a resolution that never ran. install-smoke.yml installs the same way and will hit the same crash, but it runs weekly rather than per pull request, so it is left for the upstream fix.
beta21 drops one of two taint flows that reach the same sink method from two different files in a co-analyzed batch. Eleven fixtures lose their finding that way, and TaintedShellWhereValueFlowPreserved reports its finding twice; with laravel/ai installed the batch shifts and two PromptInjection fixtures join them. Each still passes when analysed on its own. Upstream: vimeo/psalm#11959. Gated through a new PsalmVersion::skipOnRange(), not the existing LaravelVersion-style one-sided gate. Both bounds are required on purpose: the skip covers exactly 7.0.0-beta21, so the next Psalm release re-enables all thirteen and they go red again if the bug survived. A one-sided skipFrom would go stale silently and quietly cost the coverage for good. Every gate carries a @todo-by 2026-10-01 and the issue link. The PromptInjection pair keeps its existing laravel/ai guard first, now with an explicit return so only one skip reason is printed.
|
Follow-up: #1457 removes every temporary guard added here, as a draft to merge once vimeo/psalm#11958 and vimeo/psalm#11959 are both fixed and released. |
|
Correction to the follow-up note above: #1457 was split in two, so neither upstream fix waits on the other. #1458 removes the laravel/framework 13.32 pins (vimeo/psalm#11958); #1459 removes the taint fixture gates (vimeo/psalm#11959). Both are drafts. |
…locks (#1460) laravel/framework v13.32.0 added a @phpstan-this-out docblock on Collection::prepend() with a parameter conditional. Psalm cannot parse that shape and throws an uncaught TypeParseTreeException from TypeParser during the scan phase, before a single issue is reported, so every job resolving that release analyses nothing at all. Reproduces on Psalm 6.17.2, so it is not caused by this plugin. Held in the workflows and in the fresh-app leg's LARAVEL_FRAMEWORK_CONSTRAINT hook rather than in composer.json, so a contributor installing locally still meets the crash instead of having it papered over. Ports the CI-only portion of master's bfc5fbe (#1456) to the 3.x/Psalm 6 line. Upstream: vimeo/psalm#11958
Issue to Solve
Self-analysis and every taint run fail on Psalm
7.0.0-beta21:At runtime it is fatal, not just a reported issue, so the whole type suite aborts on the first
===/strcmp()comparison that reaches the handler:The accompanying
MixedAssignmentandMixedArgumentat the same call site are cascade from the unknown method'smixedreturn.Related
No tracking issue.
Solution Description
Upstream timeline (probed against release tags):
make()getForTaintSink()getForTaint()7.0.0-beta197.0.0-beta207.0.0-beta21beta21merged the source and sink factories into onegetForTaint(). Direction is now decided by whether the node goes toTaintFlowGraph::addSource()oraddSink(), and the location is always derived from$code_locationinstead of an independent fourth?CodeLocation $specialization_locationargument. Upstream's rationale: the independent location let one node id resolve to different locations per forked worker, so whichever worker registered the id first won the merge and taint findings shifted between runs.The first three parameters are unchanged (
string $taint_id,CodeLocation $code_location,int $taints), so the call site is a rename. The stale comment naming the old factory is updated with it.DataFlowNodelives underPsalm\Internal\, outside the stable plugin API surface, so it changes without a deprecation cycle. SincegetForTaintSink()existed only inbeta20, there is no constraint that spans both: the floor moves to^7.0.0-beta21incomposer.json, anddocs/upgrade-v4.mdfollows.Verified on
7.0.0-beta21:composer psalm(with--find-dead-code --find-unused-psalm-suppress): No errors found, 100% type coverage.composer test:unit: 1271 tests green.composer test:type: 758 tests, 11 failures, all pre-existing underbeta21and unrelated to this change (see below).Known issue:
beta21taint regressions, not introduced herePinning the same checkout back to
7.0.0-beta20(this commit reverted, since the rename requiresbeta21) gives a fully green type suite. Onbeta21the same suite fails 11 taint tests, deterministically:Safe*tests lose an expectedTaintedSSRFon aPendingRequest::get()sink (false negatives).TaintedShellWhereValueFlowPreservedreports itsTaintedShelltwice.Near-identical sibling tests still pass, and running Psalm directly on one failing fixture's source does report the
TaintedSSRF. The finding only disappears when the fixture is co-analyzed with the rest of its--ARGS--group, which points atbeta21's changed node id and specialization-key derivation altering cross-file node merging. That is the same upstream area this rename comes from.Filed upstream as vimeo/psalm#11959. This PR is the prerequisite either way, since without it no taint run on
beta21completes at all.Also here: holding laravel/framework below 13.32
laravel/frameworkv13.32.0 (Collection.php#L1061, added by laravel/framework#61571) ships the first docblock of this shape:Psalm 7 cannot parse a
this-outwhose type is a conditional keyed on a parameter. It throws an uncaughtTypeParseTreeException: Unrecognized template '$key'fromTypeParserduring the scan phase, before any issue is reported, so every job analysing a project that resolves laravel/framework >= 13.32 dies outright:$keyis a declared parameter ofprepend(), and the same conditional in@returnparses, so the docblock is valid. Reproduced on 6.17.2 and 7.0.0-beta20 as well, with a 20-line plugin-free fixture, so it is neither a beta21 regression nor plugin-caused. Filed upstream as vimeo/psalm#11958.composer.jsonis deliberately NOT pinned. Its require-dev is what contributors install locally, and holding the framework back there would hide the crash from anyone developing the plugin rather than only from CI. The hold lives in the workflows instead, temporary and commented inline with@see:tests.yml, three cells, each reaching 13.32 by a different route: the type-test matrix constraint, the unit-test lockfile cells installing straight from composer.json, and both laravel/ai legs. Cells pinned to an exact framework version already resolve below 13.32 and are untouched. Type-test job names now carry the bounded constraint instead of^13.3.LARAVEL_FRAMEWORK_CONSTRAINThook inlaravel-test.sh, applied only to the dev-master cells. The 12.12.2 cells keep resolving exactly what laravel/laravel pins.Taint fixtures gated on the broken Psalm release
With the crash held off, the remaining failures were vimeo/psalm#11959: 11 taint fixtures losing their finding in the co-analyzed batch (
TaintedShellWhereValueFlowPreservedreports its own twice), plus 2 PromptInjection fixtures that join them once laravel/ai shifts the batch. Each still passes when analysed on its own.They are gated through a new
PsalmVersion::skipOnRange('7.0.0-beta21', '7.0.0-beta22'), not the one-sidedLaravelVersion-style gate. Both bounds are required deliberately: the skip covers exactly beta21, so the next Psalm release re-enables all thirteen and they go red again if the bug survived. A one-sidedskipFromwould go stale silently and cost the coverage for good. Every gate carries@todo-by 2026-10-01and the issue link.Measured locally on beta21 + laravel v13.31.0: type suite 758 tests, 0 failures, 64 skipped (53 pre-existing + the 13 gated); unit suite 1271 green; self-analysis clean at 100% type coverage;
composer csandcomposer rectorno-ops.Measured, on this checkout: psalm beta21 + laravel v13.31.0 green at 100% type coverage; psalm beta21 + v13.32.0 crashes; psalm beta20 + v13.32.0 crashes identically.
Checklist
tests/Type/tests/TaintAnalysis/TimingUnsafe*.phpt, 11 tests, exercise the rewritten call site and pass)docs/upgrade-v4.mdPsalm floor)