PHP API: IR/Node
Classes in the IR/Node namespace.
ComponentNode
Source: ComponentNode.php
IR node for mounting a component template with props and slots.
The template node is reused as the component body, while props and slots are passed as runtime inputs for each component instance.
Group: IR/Node
Example
Methods
__construct
Build a component IR node.
Parameters
- Node $template Component template node.
- array<string, Expr> $props Component prop expressions.
- array<string, array<int, Node>> $slots Slot content keyed by slot name.
- Expr|null $key Optional stable key expression.
collectAtoms
Collect atom-related dependencies used by template, props, slots, and key.
Parameters
- callable $collect Collector callback that receives dependency nodes.
Returns: void
jsonSerialize
Encode this component node as runtime IR payload.
Returns: array<string, mixed>
withProp
Return a cloned component node with one prop updated.
Parameters
- string $name Prop name.
- Expr $expr Prop expression.
Returns: self
withSlots
Return a cloned component node with slot children replaced.
Returns: self
EffectNode
Source: EffectNode.php
IR node for declarative effects.
Binds one or more triggers to one or more runtime actions, optionally scoped to a specific effect target.
Group: IR/Node
Example
Methods
__construct
Build an effect IR node.
Parameters
- array<int, EffectTrigger> $triggers Effect trigger list.
- array<int, Action> $actions Effect action list.
- EffectTarget|null $target Optional effect target.
collectAtoms
Collect atom dependencies referenced by actions and watch triggers.
Parameters
- callable $collect Collector callback that receives dependency nodes.
Returns: void
jsonSerialize
Encode this effect node as runtime IR payload.
Returns: array<string, mixed>
ElNode
Source: ElNode.php
IR node for a standard HTML element.
Stores element tag, normalized props helpers, child nodes, and optional render target metadata.
Group: IR/Node
Example
Methods
__construct
Build an element IR node.
Parameters
- string $tag Element tag name.
- array<string, mixed> $props Props helper payload.
- array<int, Node> $children Child IR nodes.
- array<string, string>|null $render Optional render metadata.
collectAtoms
Collect atom-related dependencies referenced by this node.
Parameters
- callable $collect Collector callback that receives dependency nodes.
Returns: void
jsonSerialize
Encode this node as runtime IR payload.
Returns: array<string, mixed>
encodeProps
Normalize props into the runtime wire format.
Parameters
- array<string, mixed> $props
Returns: array<string, mixed>
FragmentNode
Source: FragmentNode.php
IR node for grouping children without creating a wrapper element.
Fragment nodes are transparent at the DOM level and only serve as a structural container in the IR tree.
Group: IR/Node
Example
Methods
__construct
Build a fragment IR node.
Parameters
- array<int, Node> $children Child nodes rendered in sequence.
collectAtoms
Collect atom dependencies from child nodes.
Parameters
- callable $collect Collector callback that receives dependency nodes.
Returns: void
jsonSerialize
Encode this fragment node as runtime IR payload.
Returns: array<string, mixed>
HtmlNode
Source: HtmlNode.php
IR node for trusted/raw HTML content.
Accepts either a static string or an expression resolved at runtime.
Group: IR/Node
Example
Methods
__construct
Build an HTML node.
Parameters
- Expr|string $value Raw HTML value or expression.
jsonSerialize
Encode this HTML node as runtime IR payload.
Returns: array<string, mixed>
LinkNode
Source: LinkNode.php
IR node for declarative navigation links.
Encodes destination expression, link props, and child nodes for runtime navigation handling.
Group: IR/Node
Example
Methods
__construct
Build a link IR node.
Parameters
- Expr $to Destination expression.
- array<int, mixed> $props Link props helper payload.
- array<int, Node> $children Child IR nodes.
jsonSerialize
Encode this link node as runtime IR payload.
Returns: array<string, mixed>
ListNode
Source: ListNode.php
IR node for list/repeat rendering.
Repeats a template node for each item in an items expression with a key expression used for stable identity.
Group: IR/Node
Example
Methods
__construct
Build a list/repeat IR node.
Parameters
- Expr $items Items expression.
- Expr $key Key expression for each item.
- Node $template Template node rendered per item.
collectAtoms
Collect atom dependencies used by items, key, and template.
Parameters
- callable $collect Collector callback that receives dependency nodes.
Returns: void
jsonSerialize
Encode this list node as runtime IR payload.
Returns: array<string, mixed>
Node
Source: Node.php
Base IR node type.
All IR node variants extend this class and must be JSON serializable so they can be encoded and sent to the runtime.
Group: IR/Node
Example
Methods
setRenderContext
Parameters
- array<string,mixed> $node @param array<string,mixed> $ctx @param array<int,mixed> $atoms
renderNodes
Parameters
- array<int, mixed> $nodes
normalizeProps
Returns: array{attrs:array<string,mixed>,cls:mixed,style:array<string,mixed>}
RouteNode
Source: RouteNode.php
IR node for route matching and view selection.
Compiles path patterns to regex once on the PHP side and serializes route table metadata for runtime navigation.
Group: IR/Node
Example
Methods
__construct
Parameters
- array<string, Node> $table Map of path patterns to view Nodes (author order = match priority).
- Node $fallback View to render when no pattern matches (404).
- string $base Optional base path (default '/'), stripped before matching.
compilePattern
Compile a route pattern (e.g., "/auction/:id") into a regex and ordered param keys.
Parameters
- string $pat
Returns: array{0:string,1:array<int,string>} Tuple [regex, keys].
jsonSerialize
k: 'route',
Returns: array{
ShowNode
Source: ShowNode.php
IR node for conditional rendering.
Renders a child node only when the condition evaluates to truthy.
Group: IR/Node
Example
Methods
__construct
Build a conditional IR node.
Parameters
- Expr|bool $cond Condition expression or literal.
- Node $child Node rendered when condition is true.
collectAtoms
Collect atom dependencies used by condition and child node.
Parameters
- callable $collect Collector callback that receives dependency nodes.
Returns: void
jsonSerialize
Encode this conditional node as runtime IR payload.
Returns: array<string, mixed>
SlotNode
Source: SlotNode.php
SlotNode represents a placeholder inside a component template
where children content will be injected at runtime. JSON shape: { "k": "slot", "name": "default" // optional; omitted for default slot }
Group: IR/Node
Example
Methods
__construct
Build a slot placeholder node.
Parameters
- string|null $name Slot name, or null for default slot.
withName
Return a slot node with normalized name.
Parameters
- string $name Slot name.
Returns: self
jsonSerialize
Encode this slot node as runtime IR payload.
Returns: array<string, string>
TextNode
Source: TextNode.php
IR node for text content.
Stores either a literal string or an expression resolved at runtime.
Group: IR/Node
Example
Methods
__construct
Build a text node.
Parameters
- Expr|string $value Text value or expression.
collectAtoms
Collect atom dependencies from text expression values.
Parameters
- callable $collect Collector callback that receives dependency nodes.
Returns: void
jsonSerialize
Encode this text node as runtime IR payload.
Returns: array<string, mixed>