Repository navigation
Conversation
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.
Slice S4 of the type/arity reproduction run (#1051). Part of #938: arity is now judged for closures, arrow functions, first-class callables and string callees, wherever the callee is proven.
What changed
steins-syntax:CallExpr::dynamic_callee: Option<ArgValue>holds an in-place closure, arrow fn,f(...)or string literal when the call isCallee::Dynamic. The receiver staysDynamic, so every opaque-callee reader still treats the call as opaque. This is the only IR change.arity.rs: a rule table with one row per callee shape, pluscheck_closure_scope_arityandstring_callee_ref. A string callee resolves as fully qualified, never through the calling namespace, as PHP does.descent.rs/stmt_calls.rs:handle_var_callruns arity in the plain pass for a closure scope, an FCC target, and a string whose Known stratum is Verified.check_dynamic_callee_aritycovers theCallee::Dynamicarm, which is IIFE andf(...)(1).Rule table (all rows run on PHP 8.5.11)
'add'(1))call.too-few-arguments, as for a direct call__invokeobject, OneOf of closures, a by-ref captured closure that is rewritten,Closure::fromCallable,Closure::bind, builtin and'K::m'strings, a reassigned variable'add'insidenamespace AppError(undefined function), not ArgumentCountErrorToo-many is never judged: PHP runs a user callable with extra arguments cleanly, so D4 is unchanged.
Tests
dynamic_callee_arity.rshas 16 tests, one per table row.arity::silent_closure_var_call, which pinned$fn = 'f'; $fn(1)as silent, now expects the finding. It is a true positive.Measurement (ten public packages)
--no-php: all 30 outputs are byte-identical.Not measured
Review outcome
Adversarial review: approve. No false positive, no lost check, no perf change.
goto,match, by-ref,extract,$$n,global,static,use (&$f),list,$GLOBALS,includeand by-ref arguments;static::,parent::or trait methods;use function, and the dam;bind/bindTo/call.