Repository navigation
Conversation
- The pipe is lowered to one virtual call analysed by the existing call analysers, so its type, argument checks, purity, unused-variable tracking and left-hand taint match the hand-desugared call - A partial application PHP compiles to a direct call gets the piped value in its placeholder; other partial applications stay mixed until closures for them are supported - The left-hand side is analysed once, before the right-hand side whenever the order can matter - Each call of a chain starts at its own callee, as calls are told apart by their start (issue dedupe, taint specialization) - `??` and psalter's unused-assignment removal treat a pipe as a call - The scanner and visitor guards against partial applications are the ones of vimeo#12915, so neither PR conflicts with the other
PHP passes the left-hand side of a pipe by value, so a by-reference parameter can't take it: `$a |> sort(...)` throws. Report InvalidPassByReference for it and leave the piped variable (type and taint) untouched. array_multisort() prefers a reference, so it sorts a copy, as for `array_multisort(f())`.
…array_splice vimeo#12966 Their dedicated handlers wrote the new elements into the first argument before the call was rejected, so `$a |> array_push(?, 4)` still changed `$a` and carried the taint of the pushed values into it. The piped value now takes the generic path, which rejects it.
A callee whose parameters aren't known was assumed to take the piped variable by reference: `$e = []; $e |> $closure` widened `$e` to `array<array-key, mixed>`, and a callable array of a contracted class was charged write-refs for it. PHP passes the piped value by value, whatever the callee.
…-pipe-operator # Conflicts: # src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php
… into alies-dev/pipe-byref
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.
PHP passes the left-hand side of a pipe by value and throws when the callee takes that parameter by reference, but Psalm accepted it.
Before
After
The piped variable keeps its type, also for
array_push,array_unshiftandarray_splice, and for callees whose parameters are unknown.Part of #12966