Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
update dependencies and fix xhpchild truthiness test for 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fredemmott committed Mar 26, 2019
1 parent ae5a5ac commit 40ef973
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 54 deletions.
36 changes: 18 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 47 additions & 36 deletions src/core/ComposableElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,24 @@ final public function replaceChildren(XHPChild ...$children): this {
$new_children = Vector {};
foreach ($children as $xhp) {
/* HH_FIXME[4273] bogus "XHPChild always truthy" - FB T41388073 */
if ($xhp) {
if ($xhp instanceof :x:frag) {
foreach ($xhp->children as $child) {
if ($xhp instanceof :x:frag) {
foreach ($xhp->children as $child) {
$new_children->add($child);
}
} else if (!($xhp instanceof Traversable)) {
$new_children->add($xhp);
} else {
foreach ($xhp as $element) {
if ($element instanceof :x:frag) {
foreach ($element->children as $child) {
$new_children->add($child);
}
} else if (!($xhp instanceof Traversable)) {
$new_children->add($xhp);
} else {
foreach ($xhp as $element) {
if ($element instanceof :x:frag) {
foreach ($element->children as $child) {
$new_children->add($child);
}
} else if ($element !== null) {
$new_children->add($element);
}
}
} else if ($element !== null) {
$new_children->add($element);
}
}
}
}
$this->children = $new_children;
return $this;
}
Expand Down Expand Up @@ -291,16 +289,18 @@ final public static function __xhpReflectionChildrenDeclaration(

final public static function __xhpReflectionCategoryDeclaration(
): Set<string> {
return
new Set(\array_keys(self::emptyInstance()->__xhpCategoryDeclaration()));
return new Set(
\array_keys(self::emptyInstance()->__xhpCategoryDeclaration()),
);
}

// Work-around to call methods that should be static without a real
// instance.
<<__MemoizeLSB>>
private static function emptyInstance(): this {
return
(new \ReflectionClass(static::class))->newInstanceWithoutConstructor();
return (
new \ReflectionClass(static::class)
)->newInstanceWithoutConstructor();
}

final public function getAttributes(): Map<string, mixed> {
Expand Down Expand Up @@ -592,8 +592,9 @@ final protected function validateAttributeValue<T>(
}
if (is_array($val)) {
try {
$type_structure =
(new ReflectionTypeAlias($class))->getResolvedTypeStructure();
$type_structure = (
new ReflectionTypeAlias($class)
)->getResolvedTypeStructure();
/* HH_FIXME[4110] $type_structure is an array, but should be a
* TypeStructure<T> */
TypeAssert\matches_type_structure($type_structure, $val);
Expand Down Expand Up @@ -645,12 +646,12 @@ final protected function validateChildren(): void {
return;
}
}
list($ret, $ii) =
$this->validateChildrenExpression($decl->getExpression(), 0);
list($ret, $ii) = $this->validateChildrenExpression(
$decl->getExpression(),
0,
);
if (!$ret || $ii < count($this->children)) {
if (
($this->children[$ii] ?? null) is XHPAlwaysValidChild
) {
if (($this->children[$ii] ?? null) is XHPAlwaysValidChild) {
return;
}
throw new XHPInvalidChildrenException($this, $ii);
Expand Down Expand Up @@ -692,11 +693,15 @@ final private function validateChildrenExpression(
// Specific order -- :fb-thing, :fb-other-thing
$oindex = $index;
list($sub_expr_1, $sub_expr_2) = $expr->getSubExpressions();
list($ret, $index) =
$this->validateChildrenExpression($sub_expr_1, $index);
list($ret, $index) = $this->validateChildrenExpression(
$sub_expr_1,
$index,
);
if ($ret) {
list($ret, $index) =
$this->validateChildrenExpression($sub_expr_2, $index);
list($ret, $index) = $this->validateChildrenExpression(
$sub_expr_2,
$index,
);
}
if ($ret) {
return tuple(true, $index);
Expand All @@ -707,11 +712,15 @@ final private function validateChildrenExpression(
// Either or -- :fb-thing | :fb-other-thing
$oindex = $index;
list($sub_expr_1, $sub_expr_2) = $expr->getSubExpressions();
list($ret, $index) =
$this->validateChildrenExpression($sub_expr_1, $index);
list($ret, $index) = $this->validateChildrenExpression(
$sub_expr_1,
$index,
);
if (!$ret) {
list($ret, $index) =
$this->validateChildrenExpression($sub_expr_2, $index);
list($ret, $index) = $this->validateChildrenExpression(
$sub_expr_2,
$index,
);
}
if ($ret) {
return tuple(true, $index);
Expand Down Expand Up @@ -767,8 +776,10 @@ final private function validateChildrenRule(
return tuple(true, $index + 1);

case XHPChildrenConstraintType::SUB_EXPR:
return
$this->validateChildrenExpression($expr->getSubExpression(), $index);
return $this->validateChildrenExpression(
$expr->getSubExpression(),
$index,
);
}
}

Expand Down

0 comments on commit 40ef973

Please sign in to comment.