Repository navigation
Avoid overwriting predefined method definitions in ClassDefinition - #1330
Open
pardeepsinghverma wants to merge 1 commit into
Open
pardeepsinghverma wants to merge 1 commit into
pardeepsinghverma wants to merge 1 commit into
Conversation
When a class definition has method definitions attached via extensions (such as AfterLengthAwarePaginatorDefinitionCreatedExtension), lazily loading methods should not overwrite them with an unanalyzed FunctionLikeDefinition if the method was already defined for this class and fully analyzed. This prevents raw paginator endpoints from corrupting the pagination schema of subsequent endpoints.
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.
Fixes #1325
Description
When an endpoint returns a raw LengthAwarePaginator, Infer::analyzeClass re-analyzes the paginator class definition. While AfterLengthAwarePaginatorDefinitionCreatedExtension registers the refined OpenAPI schema on LengthAwarePaginator::methods['toArray'], subsequent lazy loading in ClassDefinition::lazilyLoadMethodDefinition() was unconditionally overwriting ->methods[] with a blank FunctionLikeDefinition for methods declared on the reflection class. This caused oArray to be re-analyzed from vendor source AST and discarded Scramble's paginator schema for any endpoints documented afterwards.
This change checks whether ->methods[] was already defined for the current class and marked as fully analyzed before creating a fresh unanalyzed definition, preserving extension-defined schemas while continuing to analyze overridden methods on child classes as expected.
Changes