Wire ReflectionEnum into existing infrastructure#192
Merged
lisachenko merged 2 commits intomasterfrom Apr 28, 2026
Merged
Conversation
- Fix ReflectionEngine::parseClassConstant() to handle EnumCase nodes - Fix ReflectionClassConstant::getDeclaringClass() to return ReflectionEnum for enum cases - Add ReflectionClassConstant::toEnumCase() for converting to ReflectionEnumUnitCase/ReflectionEnumBackedCase - Add tests for all new functionality Agent-Logs-Url: https://github.com/goaop/parser-reflection/sessions/95741007-a246-4a8c-821f-7a733a378e44 Co-authored-by: lisachenko <640114+lisachenko@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Wire ReflectionEnum into existing infrastructure
Wire ReflectionEnum into existing infrastructure
Apr 28, 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.
ReflectionClassConstanthad no integration with theReflectionEnumstack: enum case constants couldn't be looked up by name via the engine,getDeclaringClass()returned a plainReflectionClassinstead ofReflectionEnum, and there was no way to obtain a properly-typedReflectionEnumUnitCase/ReflectionEnumBackedCasefrom a constant.Changes
ReflectionEngine::parseClassConstant()— now searchesEnumCasenodes in addition toClassConstnodes, sonew ReflectionClassConstant('MyEnum', 'CaseName')no longer throwsInvalidArgumentException.ReflectionClassConstant::getDeclaringClass()— returnsReflectionEnumwhenisEnumCase()is true, matching native PHP where\ReflectionClassConstant::getDeclaringClass()returns\ReflectionEnumfor enum case constants.ReflectionClassConstant::toEnumCase()— new method converting an enum-case constant toReflectionEnumUnitCaseorReflectionEnumBackedCase(delegates toReflectionEnum::getCase()); throwsReflectionExceptionif called on a non-enum-case constant.