← All docs

count() — internals

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

count() — internals

Where it lives

Lowering notes

  • Lowers count(array) for concrete array values by reading the runtime length header.
  • Called from crate::builtins::array::count (the registry home) via a thin wrapper.
  • Handles Array/AssocArray (reads length directly from the runtime header), Mixed/Union
  • (delegates to __rt_mixed_count), and Countable Object (calls the object’s count
  • method via intrinsic or dynamic dispatch).

Runtime helpers

The following runtime helpers are referenced:

  • __rt_mixed_count

Signature summary

function count(array $value, int $mode = 0): int

What the type checker enforces

  • Arity: takes 1–2 arguments (1 optional).

Eval interpreter (magician)

Cross-references