Add NodeAwareInterface exposing getNode() on all parsed reflections - #200
Merged
Conversation
…ions Introduces Go\ParserReflection\NodeAwareInterface with a single getNode(): Node method and implements it on all 11 parsed reflection classes that wrap an AST node. Each class narrows the return type via covariance to its concrete node type (ClassLike, ClassMethod, Param, EnumCase, etc.), making direct AST access an official client API. Closes #195 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NDeyey11xvinYJshLsA4Tn
lisachenko
marked this pull request as ready for review
July 30, 2026 05:49
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.
Implements #195: introduces
Go\ParserReflection\NodeAwareInterfaceso clients have an official, discoverable API for accessing the underlying AST node of any parsed reflection.Changes
New
src/NodeAwareInterface.phpimplements NodeAwareInterfaceadded to all 11 node-wrapping reflection classesAll of these already had a
getNode()method with a narrowed return type, so this is a declaration-only change — no method bodies were touched. Each class narrows the return type via covariance:getNode()return typeReflectionClassClassLikeReflectionEnumEnum_ReflectionEnumUnitCase/ReflectionEnumBackedCaseEnumCaseReflectionMethodClassMethodReflectionFunctionFunction_ReflectionParameterParamReflectionPropertyPropertyItem|ParamReflectionClassConstantClassConst|EnumCaseReflectionAttributeNode\AttributeReflectionFileNamespaceNamespace_Deliberately not implemented on:
ReflectionFile— holds aNode[]list of top-level nodes, no single underlying node to return covariantlyReflectionType/ReflectionNamedType/ReflectionUnionType/ReflectionIntersectionType— built from already-resolved data byTypeExpressionResolver; they store no AST nodeNew
tests/NodeAwareInterfaceTest.php12 tests asserting each reflection kind implements the interface and returns its expected concrete node type, built from the existing stubs
FileWithClasses81.phpandFileWithFunction80.php.Verification
vendor/bin/phpunit: 13,685 tests, 14,785 assertions, 0 failuresvendor/bin/phpstan analyse src: 0 errorsCloses #195
🤖 Generated with Claude Code
https://claude.ai/code/session_01NDeyey11xvinYJshLsA4Tn
Generated by Claude Code