A comprehensive overhaul of Eloquent query-scope analysis: instance scope calls on the base Builder, self/static scope parameters, direct-vs-forwarded dispatch, and variadic / name-collision handling.
Features
- Resolve instance scope calls on the base
BuildertoBuilder<Model>instead ofmixed, type-checking arguments against the scope's declared params (#1032) - Resolve
self/staticscope parameters to the model on custom builders, removing falseInvalidArgumentandModel&staticover-narrowing (#1033) - Classify scope calls by PHP dispatch semantics rather than argument shape, so nullable
?Builder, variadic, and non-variable first arguments resolve correctly (#1041) - Harden the scope-params hand-off (consume-once) and fix return types when a scope name collides with a real
Eloquent\Buildermethod such asfind()(#1042)
Fixes
- Fix direct scope calls that pass
$queryexplicitly to keep the real method signature, with no left-shifted arguments (#1035) - Fix direct scope calls passing
$queryto use the real return type instead of a fabricatedBuilder<Model>(#1036) - Fix trait-hosted scope
selfparameters to resolve to the composing class, so a sibling subclass is accepted instead of rejected with a falseInvalidArgument(#1043)
Behavior change
- For a trait composed on an abstract parent, the
InvalidArgumentmessage for a bad scope argument now names the composing parent (e.g.AbstractDocument) instead of the queried child (e.g.Contract) (#1031, #1043). No migration needed; the diagnostic is simply more accurate.
Full Changelog: v3.12.3...v3.13.0