refactor: Add array generics support to converters and address some bugs#30
Merged
Conversation
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.
This pull request enhances the handling of array types and promoted properties in docblock parsing and JSON Schema generation. It introduces support for extracting array element types from docblocks, improves the resolution of descriptions and default values for promoted properties, and adds an option to ignore unknown types. The changes also include utility improvements for schema type resolution and extend the test coverage to verify these behaviors.
Docblock Parsing and Array Type Extraction:
DocParserto extract element types from@varand@paramdocblock tags, including support for generic array types (e.g.,array<int>,list<string>), and propagate these types into the schema via a newitemTypesproperty onNodeData. [1] [2] [3]Promoted Property and Default Value Handling:
ClassConverterto resolve property descriptions and array element types for promoted properties using constructor@paramtags, and to correctly determine default values for promoted properties. [1] [2] [3] [4]Array Schema Generation:
InteractsWithTypesto apply docblock-derived item types to array schemas, including union types, and to build the appropriate schema representation for array elements.Type Resolution and Robustness:
SchemaType::tryFromScalarto safely resolve scalar types without throwing exceptions for unknown types, enabling more robust schema generation when encountering unrecognized types.API and Test Enhancements:
Schema::fromClassandSchema::frommethods to accept anignoreUnknownTypesflag, allowing callers to skip properties with unknown types. Expanded test coverage inClassConverterTestto verify new behaviors, including default value handling for promoted properties. [1] [2] [3]Other minor changes include dependency imports and the removal of the coverage report configuration from
phpunit.dist.xml.