Skip to content

Support template types as object shape keys - #6905

Merged
ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
canvural:generic-array-key
Nov 2, 2026
Merged

ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
canvural:generic-array-key

Conversation

@canvural

@canvural canvural commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

This PR adds support for using template type as a key in object shapes, the same way array shapes already can. For example, object{TAccessor: TPivotModel} resolves to object{pivot: Pivot} once TAccessor is known.

No turbo mirror for the new LateResolvableObjectShapeType. It's only created when a PHPDoc object shape uses a template name as a key, which is rare.

Closes phpstan/phpstan#12756

@ondrejmirtes
ondrejmirtes merged commit 9aaeccb into phpstan:2.3.x Nov 2, 2026
1035 of 1036 checks passed
@ondrejmirtes

Copy link
Copy Markdown
Member

Thank you!

@canvural
canvural deleted the generic-array-key branch November 2, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to specify template as array/object key

2 participants