in src/core/Node.hack [129:158]
final public function replaceChildren(\XHPChild ...$children): this {
if ($this->__isRendered) {
throw new UseAfterRenderException(
Str\format("Can't %s after render", __FUNCTION__),
);
}
// This function has been micro-optimized
$new_children = vec[];
foreach ($children as $xhp) {
if ($xhp is frag) {
foreach ($xhp->children as $child) {
$new_children[] = $child;
}
} else if (!($xhp is Traversable<_>)) {
$new_children[] = $xhp;
} else {
foreach ($xhp as $element) {
if ($element is frag) {
foreach ($element->children as $child) {
$new_children[] = $child;
}
} else if ($element !== null) {
$new_children[] = $element as \XHPChild;
}
}
}
}
$this->children = $new_children;
return $this;
}