in src/core/Node.hack [705:758]
private function validateChildrenRule(
ReflectionXHPChildrenExpression $expr,
int $index,
): (bool, int) {
switch ($expr->getConstraintType()) {
case XHPChildrenConstraintType::ANY:
if (C\contains_key($this->children, $index)) {
return tuple(true, $index + 1);
}
return tuple(false, $index);
case XHPChildrenConstraintType::PCDATA:
if (
C\contains_key($this->children, $index) &&
!($this->children[$index] is node)
) {
return tuple(true, $index + 1);
}
return tuple(false, $index);
case XHPChildrenConstraintType::ELEMENT:
$class = $expr->getConstraintString();
if (
C\contains_key($this->children, $index) &&
\is_a($this->children[$index], $class, true)
) {
return tuple(true, $index + 1);
}
return tuple(false, $index);
case XHPChildrenConstraintType::CATEGORY:
if (!C\contains_key($this->children, $index)) {
return tuple(false, $index);
}
$child = $this->children[$index];
if (!$child is node) {
return tuple(false, $index);
}
$category = $expr->getConstraintString()
|> Str\replace($$, '__', ':')
|> Str\replace($$, '_', '-');
$categories = $child->__xhpCategoryDeclaration();
if (($categories[$category] ?? 0) === 0) {
return tuple(false, $index);
}
return tuple(true, $index + 1);
case XHPChildrenConstraintType::SUB_EXPR:
return $this->validateChildrenExpression(
$expr->getSubExpression(),
$index,
);
}
}