Add resolveExprPropertyFetch to support Enum::CASE->value expressions#176
Merged
Merged
Conversation
- Add resolveExprPropertyFetch method in NodeExpressionResolver to resolve property fetch on objects (e.g. BackedEnum::CASE->value) - Use native reflection for loaded enum classes in fetchReflectionClass so enum case constants resolve to actual enum instances - Reset isConstant/constantName in property fetch since PHP does not consider Enum::CASE->value a constant expression - Add ClassWithBackedEnumDefaultValue test stub - Add unit test for resolver and integration test for parameter defaults Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Member
|
resolves #155 |
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
lisachenko
approved these changes
Apr 27, 2026
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
Adds support for resolving property fetch expressions on objects in
NodeExpressionResolver, enabling expressions likeBackedEnum::CASE->valueto be resolved correctly as parameter default values.Changes
resolveExprPropertyFetchmethod inNodeExpressionResolver— resolves property access on objects (e.g.SomeEnum::CASE->value). ResetsisConstant/constantNamesince PHP does not treatEnum::CASE->valueas a constant.fetchReflectionClassfix — uses native reflection for loaded enum classes so thatgetConstant()returns actual enum case instances (the parser-reflectionReflectionClass::getConstant()returnsfalsefor enum cases).Test stub
ClassWithBackedEnumDefaultValueinFileWithClasses81.php— usesBackedPhp81EnumHTTPMethods::GET->valueas a parameter default.Unit test in
NodeExpressionResolverTest— verifies the resolver evaluatesBackedPhp81EnumHTTPMethods::GET->valueto'get'.Integration test in
ReflectionParameterTest— verifiesgetDefaultValue()returns'get'for the parameter with a backed enum property default.Review & Testing Checklist for Human
fetchReflectionClasschange to use native reflection for enums doesn't affect other enum constant resolution paths (e.g.SomeEnum::CASEwithout property fetch)vendor/bin/phpunit) — all 12,738 tests pass with 0 failuresvendor/bin/phpstan analyse src --no-progress) — 0 errorsNotes
The
fetchReflectionClasschange is necessary because the parser-reflection'sReflectionClass::getConstant()returnsfalsefor enum cases, while native PHP's\ReflectionClass::getConstant()correctly returns the enum instance. Using native reflection for loaded enums allows the property fetch chain to work correctly.Link to Devin session: https://app.devin.ai/sessions/33bcb37b7b784272ad76aa48fe6683c4
Requested by: @lisachenko