Defer by-ref closure scope modifications after all args are processed by ondrejmirtes · Pull Request #4865 · phpstan/phpstan-src
processClosureNode returned a scope with by-ref captured variable modifications already applied. In processArgs, this polluted the scope used for evaluating subsequent arguments - but closures are not called during argument evaluation, so by-ref changes cannot have taken effect yet. The fix separates the by-ref data (closureResultScope, byRefUses) from the returned scope in ProcessClosureResult and lets callers decide when to apply it. The standalone closure call site applies immediately, while processArgs defers it until after all arguments are processed - same pattern as the existing deferral of processImmediatelyCalledCallable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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