← All docs

serialize() — internals

Compiler internals for serialize(): lowering path, type checks, and runtime helpers.

serialize() — internals

Where it lives

Lowering notes

  • Lowers serialize($value) into the shared serialize runtime helper.
  • Scalar static types are formatted directly through __rt_serialize_value; a
  • Mixed/Union argument is unboxed and dispatched by __rt_serialize_mixed.
  • Non-scalar static types (arrays/objects) are not yet supported and are rejected.

Runtime helpers

The following runtime helpers are referenced:

  • __rt_serialize_begin
  • __rt_serialize_mixed
  • __rt_serialize_value

Signature summary

function serialize(mixed $value): string

What the type checker enforces

  • Arity: takes exactly 1 argument.

Eval interpreter (magician)

Not callable from eval’d code — the magician interpreter has no entry for this builtin.

Cross-references