EntityRepositoryReturnTypeExtension: Handle non-constant strings (fixes #1040) - #1041
Merged
Conversation
As noted in mglaman#1040, when EntityRepositoryInterface::getActive and friends were pass a non-constant string as the '$entity_type_id' parameter, the involved entity type was inferred as *NEVER*. This commit fixes the issue by introducing a new guard clause, explicitly checking for no guard clauses being involved, and falling back to a generic return type for the function. It also introduces additional tests, checking that the issue does not reoccur. Fixes mglaman#1040.
Contributor
Author
|
Not sure about the failing check, that seems to also be the case on the main branch. |
…xed unions by int|string A constant entity type ID with no known class pushed the method's whole array return type into the element union, so getActiveMultiple() with a typo'd ID inferred a nested array. Bail out to the declared return type instead, matching the getStorage() extension. Resolve the array key per entity type so a 'node'|'block' union is keyed int|string rather than int. Tighten the fixture: type the non-constant variable, use literal IDs, and use @var like the sibling fixtures. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Owner
|
Thank you! |
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.
As noted in #1040, when
EntityRepositoryInterface::getActiveand friends were passed a non-constant string as the$entity_type_idparameter, the involved entity type was inferred as NEVER.This PR fixes the issue by introducing a new guard clause, explicitly checking for no guard clauses being involved, and falling back to a generic return type for the function. It also introduces additional tests, checking that the issue does not reoccur.
Fixes #1040.