Deserializer
class Deserializer (View source)
Constants
| protected MAX_NODES |
The maximum number of schema fragments that may be expanded. |
Properties
| protected array<string,mixed> | $root | The root schema being deserialized (used to resolve local $refs). |
|
| protected | $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 Laravel-supported JSON Schema subset into a type.
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 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.
Collapse "anyOf" / "oneOf" null branches into a single effective schema.
Determine if the given schema branch describes only the "null" type.
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.
Cast the given number to an integer, rejecting non-integer values.
Details
protected
__construct(array $root)
Create a new deserializer instance.
static Type
deserialize(array $schema)
Deserialize the Laravel-supported JSON Schema subset into a type.
protected Type
build(array $schema, array $refs = [])
Build a type from the given schema fragment.
protected AnyOfType|null
buildAnyOfComposition(array $schema, array $refs = [])
Build an anyOf composition unless it is the existing nullable single-schema form.
protected ObjectType
buildObject(array $schema, array $refs = [])
Build an object type from the given schema fragment.
protected ArrayType
buildArray(array $schema, array $refs = [])
Build an array type from the given schema fragment.
protected StringType
buildString(array $schema)
Build a string type from the given schema fragment.
protected IntegerType
buildInteger(array $schema)
Build an integer type from the given schema fragment.
protected NumberType
buildNumber(array $schema)
Build a number type from the given schema fragment.
protected TType
applyNumericBounds(NumberType $type, array $schema, callable|null $cast = null)
Apply the numeric bound keywords to the given integer or number type.
protected void
applyCommon(Type $type, array $schema)
Apply the keywords shared by every type to the given instance.
protected array
resolveType(array $schema)
Resolve the base type name and whether the schema is nullable.
protected string|null
inferType(array $schema)
Infer the type name when "type" is absent but the shape is unambiguous.
protected string|null
inferEnumType(array $enum)
Infer the scalar type shared by a homogeneous enum of scalars.
protected void
ensureUnionConstraintsAreSupported(array $schema)
Ensure a multi-type union carries no type-specific constraint keywords.
protected array
normalizeUnions(array $schema, array $refs = [])
Collapse "anyOf" / "oneOf" null branches into a single effective schema.
protected bool
isNullBranch(array $branch)
Determine if the given schema branch describes only the "null" type.
protected array
resolveRef(array $schema, array $refs = [])
Resolve a local "$ref" against the root schema, merging sibling keys.
protected array
lookupRef(string $ref)
Look up a local JSON pointer reference within the root schema.
protected int|float|null
toNumber(mixed $value)
Normalize the given value to an integer or float, or null when not numeric.
protected int
toInteger(int|float $value)
Cast the given number to an integer, rejecting non-integer values.