From a5bceceb9f1b2c88ad34443721a9fbcde520fd07 Mon Sep 17 00:00:00 2001 From: Lexidor Digital <31805625+Lexidor@users.noreply.github.com> Date: Fri, 18 Dec 2020 15:18:52 +0100 Subject: [PATCH] Remove assert calls refine local instead of array index --- src/core/Node.hack | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/core/Node.hack b/src/core/Node.hack index 3c87e4fb..cbf35af8 100644 --- a/src/core/Node.hack +++ b/src/core/Node.hack @@ -115,8 +115,7 @@ abstract xhp class node implements \XHPChild { $this->children[] = $new_child; } } else if ($child !== null) { - assert($child is \XHPChild); - $this->children[] = $child; + $this->children[] = $child as \XHPChild; } return $this; } @@ -733,17 +732,16 @@ abstract xhp class node implements \XHPChild { return tuple(false, $index); case XHPChildrenConstraintType::CATEGORY: - if ( - !C\contains_key($this->children, $index) || - !($this->children[$index] is node) - ) { + 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($$, '_', '-'); - $child = $this->children[$index]; - assert($child is node); $categories = $child->__xhpCategoryDeclaration(); if (($categories[$category] ?? 0) === 0) { return tuple(false, $index);