Skip to main content

Module types

Module types 

Source
Expand description

The PHP value model: Value, Str, Array, ArrayKey.

One model for every crate that carries PHP values (request payloads, documents, cache entries, queue messages), with the engine’s semantics: byte strings, ordered arrays with integer and string keys, stdClass, integers distinct from floats. The codecs (crate::json, crate::serialize, crate::igbinary), type juggling and comparison (Value::loose_eq, Value::cmp_php) and sorting (crate::sort) work on it.

PHPRust
null, bool, int, floatValue::Null, Value::Bool, Value::Int, Value::Float
string (bytes)Value::Str / Str
arrayValue::Array / Array, keys ArrayKey
stdClassValue::Object (its property table, string keys as given)
other objects (Utopia\Database\Document, …)Value::Ext, an Extension
ZEND_HANDLE_NUMERIC_STRArrayKey::normalize, numeric_key
gettype, (bool), (string), (float)Value::type_name, Value::truthy, Value::to_php_string, Value::to_double
==, ===, <=> (zend_compare)Value::loose_eq, Value::strict_eq, Value::cmp_php, Value::compare
Utopia\Http\Request body decodingValue::from_json

Values have no identity: PHP references and shared instances are copies here. Two object values are never === (separately created PHP objects are distinct instances), which is the one place where identity shows.

Against the skeleton in rfc/rust-database.md: Array::iter yields borrowed KeyRefs (a packed array stores no keys), and the engine’s packed-array bookkeeping is part of Array because it decides the next free index (see its docs).

Structs§

Array
A PHP array: an ordered map from ArrayKey to Value.
ArrayFull
$a[] = $v failed: the next integer key would be past PHP_INT_MAX (“Cannot add element to the array as the next element is already occupied”).
EngineError
An engine error thrown while juggling a value: TypeError, ValueError, JsonException, or Error (an object that cannot become a string).
Str
A PHP string: bytes, not necessarily UTF-8.

Enums§

ArrayKey
A PHP array key: an integer or a byte string.
Iter
Entries of an Array in order.
KeyRef
A borrowed ArrayKey, used to look keys up and to iterate packed arrays (which store no keys).
Never
No extension: plain PHP values.
Value
A PHP value.

Traits§

Extension
Objects of classes other than stdClass that a crate carries in Value::Ext (for the database: Document and Operator).

Functions§

numeric_key
ZEND_HANDLE_NUMERIC_STR: the integer a string array key becomes, if any.