Repository navigation
Conversation
- Arguments of `@return static<...>` belong to the declaring class's templates. Map them onto the templates of the class an instance method is called on (using the receiver's arguments for unmapped ones) and of an override's inherited declared return, through `template_extended_params`, instead of applying them by position.
…tly vimeo#13988 - Project from the trait that declares the return type (its templates are the ones the `static<...>` arguments refer to, via the `@use` entries in template_extended_params), not from the class using it; also used for the overridden method in Methods. - Follow an `@extends` mapping only through bare template arguments, so `Y&I` is not Y.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 8c16876. Configure here.
| $projected[] = count($sources[$template_name] ?? []) === 1 | ||
| ? $sources[$template_name][0] | ||
| : $this->called_params[count($projected)] | ||
| ?? new Union([new TTemplateParam($template_name, reset($type_map), $this->called_storage->name)]); |
There was a problem hiding this comment.
Null called_params index access
Medium Severity
When project() cannot map a called-class template from a single @extends source, it indexes $this->called_params before the null coalescing fallback. Methods.php invokes projectType() without called_params, so PHP raises a TypeError during override return-type comparison for subclasses that declare extra templates.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 8c16876. Configure here.
✅ Performance: unchanged · Types: unchanged
How to read this table
head 73e0b4b · base f836e87 (merge-base) · workflow run |
orklah
left a comment
There was a problem hiding this comment.
Checked on b708973: the 10 cases asserting the fix fail on the base and pass here, the 3 guards pass on both, CI is green and the perf report shows no issue change.
Scratch probes beyond the tests also give the right types here and wrong ones on the base:
- an implemented interface (
@implements I<TY, TX>) and an interface extending an interface; - a multi-level abstract chain with a binding (
Leaf2<int>); - a flipped
static<TB, TA>; - an override in a three-level chain;
$thisinside the subclass.
@extends Base<T, T> falls back to the receiver's argument, which is fine.
Bugbot's "TypeError on null called_params" is a false positive: null[$i] ?? ... doesn't throw.
One gap remains, out of this PR's scope (cluster of #14043): a first-class callable $x->m(...) still gives SameSw<mixed, mixed>, on the base as well.


Arguments of
@return static<...>are applied by position to the called subclass instead of being mapped through its@extends.Before
After
Fixes #13988