CRUDUI PHP API

Text
in package

FinalYes

Input text checks (docs/spec/input-text.md). Every string and object member name of a specification, a composition file and caller data is valid UTF-8, the PHP form of a sequence of Unicode scalar values. Invalid text is rejected before any other check of an operation; it is never replaced and never passed on.

Table of Contents

Constants

LIMIT_MESSAGE  : mixed = 'Recursive or excessively nested value'
Message of every value beyond the limits of a value.
MESSAGE  : mixed = 'Text must be Unicode scalar values'
Message of every input text failure.
NESTING_LIMIT  : mixed = 512
Levels of arrays and objects a value may nest, the value itself included.
NODE_LIMIT  : mixed = 1000000
Nodes a value may hold: every array, object, string, number, boolean and null, itself included.

Methods

failure()  : array<int, string>|false|null
The first failure in a value, walked as the tree it denotes: the path of its first invalid text, false when the value is beyond its limits there, or null when there is no failure.
inputFailure()  : string|null
The failure message of the first invalid text among named caller values, which names the value and its path, or of the first value beyond its limits, which names the value; null when every value passes.
isScalar()  : bool
Whether a string is valid UTF-8 without encoded surrogates.
options()  : array<int, array{0: string, 1: mixed}>
The present options named in $names, given in code point order, as named inputs.
size()  : array{int, int}
The levels of arrays and objects that a value nests, the value itself the first, and the nodes it holds, counted as the limits count them.
specificationFailure()  : string|null
Check a specification and then the composition files an operation reads. Invalid text is the INVALID_TEXT load failure located at its specification path, or at the file name followed by its path in the file; an invalid file name is located at the empty path. A value beyond its limits is an input failure, whose message naming spec or files is returned; null when both pass.
admit()  : bool
Count a node at $depth; false when it takes the value beyond its limits.
first()  : array<int, string>|false|null
holds()  : bool
Whether a value holds a failure; a quick walk in member order before the ordered one.
measure()  : void
Count a checked value depth-first without retaining all siblings in a pending list.

Constants

LIMIT_MESSAGE

Message of every value beyond the limits of a value.

public mixed LIMIT_MESSAGE = 'Recursive or excessively nested value'

MESSAGE

Message of every input text failure.

public mixed MESSAGE = 'Text must be Unicode scalar values'

NESTING_LIMIT

Levels of arrays and objects a value may nest, the value itself included.

public mixed NESTING_LIMIT = 512

NODE_LIMIT

Nodes a value may hold: every array, object, string, number, boolean and null, itself included.

public mixed NODE_LIMIT = 1000000

Methods

failure()

The first failure in a value, walked as the tree it denotes: the path of its first invalid text, false when the value is beyond its limits there, or null when there is no failure.

public static failure(mixed $value) : array<int, string>|false|null

Invalid text is located at the path of its string, or of the object whose member name is invalid. Members are visited in code point order of their names, which is the byte order of UTF-8, and list items in index order. A value that nests more than NESTING_LIMIT levels or holds more than NODE_LIMIT nodes is beyond its limits. A shared array or object is walked at each place, so the limits bound every walk, including one around a reference or an object that contains itself.

Parameters
$value : mixed
Return values
array<int, string>|false|null

inputFailure()

The failure message of the first invalid text among named caller values, which names the value and its path, or of the first value beyond its limits, which names the value; null when every value passes.

public static inputFailure(array<int, array{0: string, 1: mixed}> $inputs) : string|null
Parameters
$inputs : array<int, array{0: string, 1: mixed}>
Return values
string|null

isScalar()

Whether a string is valid UTF-8 without encoded surrogates.

public static isScalar(string $text) : bool
Parameters
$text : string
Return values
bool

options()

The present options named in $names, given in code point order, as named inputs.

public static options(array<string|int, mixed> $options, array<int, string> $names) : array<int, array{0: string, 1: mixed}>
Parameters
$options : array<string|int, mixed>
$names : array<int, string>
Return values
array<int, array{0: string, 1: mixed}>

size()

The levels of arrays and objects that a value nests, the value itself the first, and the nodes it holds, counted as the limits count them.

public static size(mixed $value) : array{int, int}
Parameters
$value : mixed
Return values
array{int, int}

specificationFailure()

Check a specification and then the composition files an operation reads. Invalid text is the INVALID_TEXT load failure located at its specification path, or at the file name followed by its path in the file; an invalid file name is located at the empty path. A value beyond its limits is an input failure, whose message naming spec or files is returned; null when both pass.

public static specificationFailure(mixed $spec, mixed $files) : string|null
Parameters
$spec : mixed
$files : mixed
Return values
string|null

admit()

Count a node at $depth; false when it takes the value beyond its limits.

private static admit(mixed $value, int $depth, int &$nodes) : bool
Parameters
$value : mixed
$depth : int
$nodes : int
Return values
bool

first()

private static first(mixed $value, array<int, string> $path, int $depth, int &$nodes) : array<int, string>|false|null
Parameters
$value : mixed
$path : array<int, string>
$depth : int
$nodes : int
Return values
array<int, string>|false|null

holds()

Whether a value holds a failure; a quick walk in member order before the ordered one.

private static holds(mixed $value, int $depth, int &$nodes) : bool
Parameters
$value : mixed
$depth : int
$nodes : int
Return values
bool

measure()

Count a checked value depth-first without retaining all siblings in a pending list.

private static measure(mixed $value, int $level, int &$levels, int &$nodes) : void
Parameters
$value : mixed
$level : int
$levels : int
$nodes : int
On this page

Search results