Deserializer
class Deserializer
Constants
| protected TYPE_SPECIFIC_KEYWORDS |
The type-specific keywords supported by concrete schema types. |
| protected UNSUPPORTED_ASSERTION_KEYWORDS |
The JSON Schema 2020-12 assertions this builder cannot represent. |
| protected MAX_NODES |
The maximum number of schema fragments that may be expanded. |
| protected MAX_REFERENCE_DEPTH |
The maximum number of distinct references on one active path. |
Properties
| protected int | $nodes | The number of schema fragments expanded so far. |
|
| protected array<string, array<string, mixed>> | $refCache | The cache of resolved local "$ref" targets, keyed by reference. |
Methods
Create a new deserializer instance.
Deserialize the supported JSON Schema subset into a type.
Prepare the branches of an anyOf or oneOf composition.
Build an anyOf composition unless it is the existing nullable single-schema form.
Build an object type from the given schema fragment.
Build an array type from the given schema fragment.
Build a string type from the given schema fragment.
Build an integer type from the given schema fragment.
Build a number type from the given schema fragment.
Apply the numeric bound keywords to the given integer or number type.
Apply integer-valued minimum and maximum keywords to an array or string type.
Apply the keywords shared by every type to the given instance.
Resolve the base type name and whether the schema is nullable.
Infer the type name when "type" is absent but the shape is unambiguous.
Infer the scalar type shared by a homogeneous enum of scalars.
Ensure a multi-type union carries no type-specific constraint keywords.
Ensure the schema carries no standard assertions this builder cannot represent.
Describe a composition branch.
Ensure the given schema fragment is an array.
Merge two schema fragments without weakening represented assertions.
Ensure a general anyOf composition carries no competing structural constraints.
Collapse "anyOf" / "oneOf" null branches into a single effective schema.
Determine if the given schema branch describes only the "null" type.
Determine if the schema branch may accept null.
Determine if the branch alone constrains an enum that excludes null.
Resolve a local "$ref" against the root schema, merging sibling keys.
Look up a local JSON pointer reference within the root schema.
Normalize the given value to an integer or float, or null when not numeric.
Normalize the given number to a PHP integer.
Count an expanded schema fragment.
Details
at line 68
protected
__construct(array $root)
Create a new deserializer instance.
at line 79
static Type
deserialize(array $schema)
Deserialize the supported JSON Schema subset into a type.
at line 92
protected Type
build(array $schema, array $refs = [])
Build a type from the given schema fragment.
at line 158
protected array|null
prepareComposition(array $schema, array $refs = [])
Prepare the branches of an anyOf or oneOf composition.
at line 212
protected AnyOfType|null
buildAnyOfComposition(array $schema, array $refs = [], array|null $composition = null)
Build an anyOf composition unless it is the existing nullable single-schema form.
at line 251
protected ObjectType
buildObject(array $schema, array $refs = [])
Build an object type from the given schema fragment.
at line 331
protected ArrayType
buildArray(array $schema, array $refs = [])
Build an array type from the given schema fragment.
at line 365
protected StringType
buildString(array $schema)
Build a string type from the given schema fragment.
at line 395
protected IntegerType
buildInteger(array $schema)
Build an integer type from the given schema fragment.
at line 405
protected NumberType
buildNumber(array $schema)
Build a number type from the given schema fragment.
at line 422
protected IntegerType|NumberType
applyNumericBounds(IntegerType|NumberType $type, array $schema, callable|null $cast = null)
Apply the numeric bound keywords to the given integer or number type.
at line 452
protected ArrayType|StringType
applyIntegerBounds(ArrayType|StringType $type, array $schema, string $minimumKeyword, string $maximumKeyword)
Apply integer-valued minimum and maximum keywords to an array or string type.
at line 476
protected void
applyCommon(Type $type, array $schema)
Apply the keywords shared by every type to the given instance.
at line 521
protected array
resolveType(array $schema)
Resolve the base type name and whether the schema is nullable.
at line 578
protected string|null
inferType(array $schema)
Infer the type name when "type" is absent but the shape is unambiguous.
at line 595
protected string|null
inferEnumType(array $enum)
Infer the scalar type shared by a homogeneous enum of scalars.
at line 638
protected void
ensureUnionConstraintsAreSupported(array $schema)
Ensure a multi-type union carries no type-specific constraint keywords.
at line 656
protected void
ensureAssertionsAreSupported(array $schema)
Ensure the schema carries no standard assertions this builder cannot represent.
at line 670
protected string
describeBranch(string $keyword)
Describe a composition branch.
at line 682
protected array
ensureSchemaFragmentIsArray(mixed $fragment, string $context)
Ensure the given schema fragment is an array.
at line 709
protected array
mergeSchemaFragments(array $base, array $overlay, string $context)
Merge two schema fragments without weakening represented assertions.
at line 743
protected void
ensureAnyOfConstraintsAreSupported(array $schema)
Ensure a general anyOf composition carries no competing structural constraints.
at line 769
protected array
normalizeUnions(array $schema, array $refs = [], array|null $composition = null)
Collapse "anyOf" / "oneOf" null branches into a single effective schema.
at line 839
protected bool
isNullBranch(array $branch)
Determine if the given schema branch describes only the "null" type.
at line 855
protected bool
mayAcceptNull(array $branch)
Determine if the schema branch may accept null.
at line 874
protected bool
hasBranchOnlyEnumExcludingNull(array $schema, array $branch)
Determine if the branch alone constrains an enum that excludes null.
at line 891
protected array
resolveRef(array $schema, array $refs = [])
Resolve a local "$ref" against the root schema, merging sibling keys.
at line 932
protected array
lookupRef(string $ref)
Look up a local JSON pointer reference within the root schema.
at line 968
protected int|float|null
toNumber(mixed $value)
Normalize the given value to an integer or float, or null when not numeric.
at line 986
protected int
toInteger(int|float $value)
Normalize the given number to a PHP integer.
at line 1004
protected void
countNode()
Count an expanded schema fragment.