Repository navigation
Fix (templates): bind a composed @extends argument on inherited members - #14558
Merged
alies-dev merged 7 commits intoNov 21, 2026
Merged
Conversation
A member inherited from a parent extended with an argument that mentions templates of the child (`@extends Base<Box<TModel>>`, `@extends Base<list<U>>`) kept the template of the parent or of the class in between unbound: reading `Composed<User>->value` gave `Box<TModel:Composed as object>`, an invokable `Composed<User>` was `callable(T:Base as mixed)`, and with two `@extends` levels even methods returned `list<Box<TItem:Middle as object>>`. The property and the callable now bind such an argument like a method call does, and the templates of a class in between nested in an argument are replaced by what the child passes to it. Fixes vimeo#13143
Contributor
✅ Performance: unchanged · Types: unchanged
How to read this table
head 68f2283 · base 3130738 (merge-base) · workflow run |
…d-extends-argument # Conflicts: # src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php # tests/Template/ClassTemplateExtendsTest.php
…ertyType() Populator::extendType() now substitutes the templates of a class in between wherever they are nested in an @extends argument, so the class storage's template_extended_params already resolves `Grand` -> `@extends Two<string, W>` -> `@extends Base<array<K, V>>` to `array<string, W>`. The repeated replace() over the extended params is a no-op on that storage.
…Type() This reverts commit 609f6c6. Populator::extendType() resolves the templates of a class in between only where they are nested in a composed argument. A template passed on as another template (`HasMany<TRelated>` -> `@extends HasOneOrMany<TRelated, ...>` -> `@extends Relation<TRelated, ...>`) stays the in-between class's template in the storage, so an inherited property read from two levels up gave `TRelated:HasOneOrMany` instead of the object's argument.
…hrough classes in between
This was referenced Nov 21, 2026
This was referenced Nov 21, 2026
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.
Inherited invokable
When a parent is extended with an argument built from the child's templates (
@extends Base<Box<TModel>>), the callable of its__invokekeeps the parent's template unbound.Before
After
Two
@extendslevelsWhen a composed argument goes through a class in between, methods and the invokable keep that class's template.
Before
After
A child that isn't generic (
@extends Base<string>) passed as a callable still keeps the template unbound: #14567.Part of #13143