Repository navigation
Emit native array return type for properties-of types in psalter - #14930
Merged
orklah merged 2 commits intoNov 25, 2026
Merged
Conversation
When psalter (--alter) adds missing return types for functions returning properties-of types, it previously emitted the docblock type name (e.g. `properties-of<T>`) as the native PHP return type, producing a PHP syntax error. Both TPropertiesOf and TTemplatePropertiesOf cannot be fully expressed in PHP signatures and resolve to arrays at runtime, so their toPhpString() should return 'array'. Co-Authored-By: Gemini 3.8 Flash <[email protected]>
Contributor
✅ Performance: unchanged · Types: unchanged
How to read this table
head a4ba6d3 · base 3ab8bae (merge-base) · workflow run |
orklah
requested changes
Nov 25, 2026
orklah
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @lyn1dev! The fix is right: the new case fails on master and passes here, and nullable/union returns now get array|null / int|array too.
Self-analysis fails on the PR (Shepherd and macOS jobs):
src/Psalm/Type/Atomic/TPropertiesOf.php:101:21: MissingPureAnnotation: toPhpString could be marked @psalm-pure
src/Psalm/Type/Atomic/TTemplatePropertiesOf.php:57:21: MissingPureAnnotation: toPhpString could be marked @psalm-pure
Both methods now return a constant, so add the tag to their docblocks, as in TMixed::toPhpString():
/**
* @param array<lowercase-string, string> $aliased_classes
* @psalm-pure
*/Optional: a nullable case would cover the union path too (return $b ? p($o) : null; → : array|null).
orklah
added a commit
to orklah/psalm
that referenced
this pull request
Nov 25, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…le return Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
psalter (
--alter) writesproperties-of<T>as a native return type instead ofarray, producing invalid PHP syntax.Before
After
Fixes #14915
AI was used to write this code.