final class Expect

Schema generator.

Methods

static Type
__callStatic(string $name, array $args)

No description

static Type
type(string $type)

Creates a schema for a custom type expression (e.g., 'int|string', 'null|float').

static AnyOf
anyOf(mixed ...$set)

Creates a union schema that accepts any of the given values or sub-schemas.

static Structure
structure(array $shape)

Creates a structure schema with defined properties; output is stdClass.

static Structure
from(object|string $object, array $items = [])

Generates a structure schema from a class by reflecting its properties or constructor parameters.

static Type
array(array|null $shape = [])

Creates an array schema. When passed Schema elements, behaves like structure() but outputs an array.

static Type
arrayOf(Schema $valueType, Schema|null $keyType = null)

Creates an associative or indexed array schema where every value matches the given type.

static Type
listOf(Schema $type)

Creates a list schema (sequentially indexed from 0) where every element matches the given type.

static Type
scalar(mixed $default)

No description

static Type
string(mixed $default)

No description

static Type
int(mixed $default)

No description

static Type
float(mixed $default)

No description

static Type
bool(mixed $default)

No description

static Type
null()

No description

static Type
list(mixed $default)

No description

static Type
mixed(mixed $default)

No description

static Type
email(mixed $default)

No description

static Type
unicode(mixed $default)

No description

Details

at line 34
static Type __callStatic(string $name, array $args)

No description

Parameters

string $name
array $args

Return Value

Type

at line 48
static Type type(string $type)

Creates a schema for a custom type expression (e.g., 'int|string', 'null|float').

Parameters

string $type

Return Value

Type

at line 57
static AnyOf anyOf(mixed ...$set)

Creates a union schema that accepts any of the given values or sub-schemas.

Parameters

mixed ...$set

Return Value

AnyOf

at line 67
static Structure structure(array $shape)

Creates a structure schema with defined properties; output is stdClass.

Parameters

array $shape

Return Value

Structure

at line 78
static Structure from(object|string $object, array $items = [])

Generates a structure schema from a class by reflecting its properties or constructor parameters.

Parameters

object|string $object
array $items

Return Value

Structure

at line 125
static Type array(array|null $shape = [])

Creates an array schema. When passed Schema elements, behaves like structure() but outputs an array.

Without Schema elements, creates a plain array type with the given default value.

Parameters

array|null $shape

Return Value

Type

at line 137
static Type arrayOf(Schema $valueType, Schema|null $keyType = null)

Creates an associative or indexed array schema where every value matches the given type.

Parameters

Schema $valueType
Schema|null $keyType

Return Value

Type

at line 146
static Type listOf(Schema $type)

Creates a list schema (sequentially indexed from 0) where every element matches the given type.

Parameters

Schema $type

Return Value

Type

at line 31
static Type scalar(mixed $default)

No description

Parameters

mixed $default

Return Value

Type

at line 31
static Type string(mixed $default)

No description

Parameters

mixed $default

Return Value

Type

at line 31
static Type int(mixed $default)

No description

Parameters

mixed $default

Return Value

Type

at line 31
static Type float(mixed $default)

No description

Parameters

mixed $default

Return Value

Type

at line 31
static Type bool(mixed $default)

No description

Parameters

mixed $default

Return Value

Type

at line 31
static Type null()

No description

Return Value

Type

at line 31
static Type list(mixed $default)

No description

Parameters

mixed $default

Return Value

Type

at line 31
static Type mixed(mixed $default)

No description

Parameters

mixed $default

Return Value

Type

at line 31
static Type email(mixed $default)

No description

Parameters

mixed $default

Return Value

Type

at line 31
static Type unicode(mixed $default)

No description

Parameters

mixed $default

Return Value

Type