Skip to content

EntityRepositoryReturnTypeExtension: Handle non-constant strings (fixes #1040) - #1041

Merged
mglaman merged 2 commits into
mglaman:mainfrom
tkw1536:bugfix-issue-1040
Sep 9, 2026
Merged

EntityRepositoryReturnTypeExtension: Handle non-constant strings (fixes #1040)#1041
mglaman merged 2 commits into
mglaman:mainfrom
tkw1536:bugfix-issue-1040

Conversation

@tkw1536

@tkw1536 tkw1536 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

As noted in #1040, when EntityRepositoryInterface::getActive and friends were passed a non-constant string as the $entity_type_id parameter, 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.

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.
@tkw1536

tkw1536 commented Sep 3, 2026

Copy link
Copy Markdown
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>
@mglaman

mglaman commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Thank you!

@mglaman
mglaman merged commit 4655170 into mglaman:main Sep 9, 2026
19 of 20 checks passed
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.

EntityRepositoryInterface::getActive returns *NEVER* when the type argument is just string.

2 participants