fix: drop unmappable types in nested and union schemas#2028
Open
alleknalle wants to merge 1 commit into
Open
Conversation
swagger-php only dropped types with no OpenAPI representation (callable, resource, ...) at the top level, so nested and union positions emitted an invalid type (e.g. items: {type: callable}). Drop them in setSchemaType, leaving the schema open instead.
f3446e7 to
291f3cb
Compare
DerManoMann
reviewed
Jun 27, 2026
| } else { | ||
| if ($type instanceof BuiltinType) { | ||
| if (!$type->isIdentifiedBy(TypeIdentifier::MIXED)) { | ||
| // Only set a type that has an OpenAPI representation; mixed, callable, resource, iterable etc. stay open instead of emitting an invalid type. |
Collaborator
There was a problem hiding this comment.
could this comment be moved (and adjusted) to the method docblock in stead, please?
Checks that the given type ...
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.
swagger-php only dropped types with no OpenAPI representation (callable, resource, ...) at the top level, so nested and union positions emitted an invalid type (e.g. items: {type: callable}). Drop them in setSchemaType, leaving the schema open instead.
Summary
swagger-php only applies its "drop unmappable type" sanity check to the top-level schema, so nested and union positions leak the raw PHP type name and emit invalid output:
list<callable>items: {type: callable}items: {}array<string, callable>additionalProperties: {type: callable}additionalProperties: {}int|callabletype: [callable, integer]type: [integer]The fix drops these in
setSchemaType, where the type is known to be aBuiltinType(callable, resource, iterable, …) rather than a class — so object/class types still resolve to$refs as before.mapNativeTypeid: it must keep passing class-name strings through for later$refresolution.Out of scope: the rare non-all-builtin union where the builtin member itself is unmappable (e.g.
Foo|callable); happy to extend if wanted.Type of Change
Related Issues
None.
Test Plan
Resolver-level cases in
tests/Type/TypeResolverTest(list<callable>,array<string, callable>) and an end-to-end case in tests/Processors/AugmentPropertiesTest(via theAugmentPropertiesprocessor).composer test+composer analyse` green.Checklist