[6.x] Add TKeyedArray::make() factory to 6.x for cross-version plugin compatibility#11810
Open
[6.x] Add TKeyedArray::make() factory to 6.x for cross-version plugin compatibility#11810
TKeyedArray::make() factory to 6.x for cross-version plugin compatibility#11810Conversation
…ompatibility Backports the static make() factory method from master so plugin authors can use TKeyedArray::make(\$properties) on both 6.x and master without version-checking. The constructor stays public for backward compatibility. Uses new self() (not new static()) to avoid argument-count mismatch when called through TCallableKeyedArray, which has a 4-param constructor.
TKeyedArray::make() factory to 6.x for cross-version plugin compatibility
TKeyedArray::make() factory to 6.x for cross-version plugin compatibilityTKeyedArray::make() factory to 6.x for cross-version plugin compatibility
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.
Summary
Backports the
TKeyedArray::make()static factory method from master to 6.x, so plugin authors can use the same API (TKeyedArray::make($properties)) on both Psalm 6.x and master without version-checking.Motivation
Currently, plugin code that constructs a
TKeyedArraymust branch on Psalm version:new TKeyedArray($properties)works (public constructor), butmake()doesn't exist.TKeyedArray::make($properties)is the only way (private constructor).With this change,
TKeyedArray::make($properties)works consistently on both branches.Design decisions
new self()notnew static()— avoids a silent argument-count mismatch when the method is inherited byTCallableKeyedArray, which has a 4-parameter constructor (no$is_list). Usingstaticwould mis-bind the 4th arg ($is_list) into$from_docblock.self— master'smake()can returnTArrayfor the never-type edge case; this 6.x shim delegates to the constructor which always returnsstatic. Returningselfis correct and honest.@psalm-apion class — matching master; prevents Psalm dead-code detection from flaggingmake()as unused if no internal call sites exist.new TKeyedArray()callers.Note
Low Risk
Additive API-only change: introduces a static factory and
@psalm-apiannotation without altering existing constructor behavior. Low risk aside from potential downstream reliance on the new method signature.Overview
Adds a new
TKeyedArray::make()static factory (marked@psalm-pure) that forwards to the existing constructor, enabling a consistent construction API for plugins across Psalm versions.Marks
TKeyedArrayas@psalm-apito formalize the public surface and avoid it being treated as internal/unused.Reviewed by Cursor Bugbot for commit e2a839f. Bugbot is set up for automated code reviews on this repo. Configure here.