From 40ef97361a75967fed75c1126ce3306a2ff9a285 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Tue, 26 Mar 2019 10:15:31 -0700 Subject: [PATCH] update dependencies and fix xhpchild truthiness test for 4.1 --- composer.lock | 36 +++++++-------- src/core/ComposableElement.php | 83 +++++++++++++++++++--------------- 2 files changed, 65 insertions(+), 54 deletions(-) diff --git a/composer.lock b/composer.lock index 81bb05ea..02949ae7 100644 --- a/composer.lock +++ b/composer.lock @@ -43,16 +43,16 @@ }, { "name": "hhvm/type-assert", - "version": "v3.3.1", + "version": "v3.3.2", "source": { "type": "git", "url": "https://github.com/hhvm/type-assert.git", - "reference": "f207250e2f9d4602b28c25c8a83a34bc42811243" + "reference": "92f95a5726d705d219e703ab0baa3910d7565fe9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hhvm/type-assert/zipball/f207250e2f9d4602b28c25c8a83a34bc42811243", - "reference": "f207250e2f9d4602b28c25c8a83a34bc42811243", + "url": "https://api.github.com/repos/hhvm/type-assert/zipball/92f95a5726d705d219e703ab0baa3910d7565fe9", + "reference": "92f95a5726d705d219e703ab0baa3910d7565fe9", "shasum": "" }, "require": { @@ -80,7 +80,7 @@ "TypeAssert", "hack" ], - "time": "2019-02-08T23:10:16+00:00" + "time": "2019-03-22T20:19:06+00:00" } ], "packages-dev": [ @@ -121,26 +121,26 @@ }, { "name": "facebook/fbexpect", - "version": "v2.5.2", + "version": "v2.5.6", "source": { "type": "git", "url": "https://github.com/hhvm/fbexpect.git", - "reference": "01d6ec1259d9488cf2998505e2e4746262d471d2" + "reference": "56c0b9a3473933af2056c795e4c2378f5af95529" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hhvm/fbexpect/zipball/01d6ec1259d9488cf2998505e2e4746262d471d2", - "reference": "01d6ec1259d9488cf2998505e2e4746262d471d2", + "url": "https://api.github.com/repos/hhvm/fbexpect/zipball/56c0b9a3473933af2056c795e4c2378f5af95529", + "reference": "56c0b9a3473933af2056c795e4c2378f5af95529", "shasum": "" }, "require": { "facebook/difflib": "^1.0.0", - "hhvm": "^3.28|^4.0", + "hhvm": "^4.0", "hhvm/hacktest": "^1.0", - "hhvm/hsl": "^3.26|^4.0" + "hhvm/hsl": "^4.0" }, "require-dev": { - "hhvm/hhast": "^4.0", + "hhvm/hhast": "^4.1", "hhvm/hhvm-autoload": "^2.0" }, "type": "library", @@ -149,7 +149,7 @@ "MIT" ], "description": "Unit test helpers for Facebook projects", - "time": "2019-02-27T20:52:35+00:00" + "time": "2019-03-22T20:12:49+00:00" }, { "name": "facebook/hh-clilib", @@ -230,16 +230,16 @@ }, { "name": "hhvm/hhvm-autoload", - "version": "v2.0.4", + "version": "v2.0.5", "source": { "type": "git", "url": "https://github.com/hhvm/hhvm-autoload.git", - "reference": "19b2188ddcffd197a37e787b5d413ada98c5266b" + "reference": "dbd50d7fb1856d1f6757e10bc30eb2bf5d17b3f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hhvm/hhvm-autoload/zipball/19b2188ddcffd197a37e787b5d413ada98c5266b", - "reference": "19b2188ddcffd197a37e787b5d413ada98c5266b", + "url": "https://api.github.com/repos/hhvm/hhvm-autoload/zipball/dbd50d7fb1856d1f6757e10bc30eb2bf5d17b3f1", + "reference": "dbd50d7fb1856d1f6757e10bc30eb2bf5d17b3f1", "shasum": "" }, "require": { @@ -273,7 +273,7 @@ ] }, "notification-url": "https://packagist.org/downloads/", - "time": "2019-03-06T17:53:08+00:00" + "time": "2019-03-22T21:27:20+00:00" }, { "name": "hhvm/hsl-experimental", diff --git a/src/core/ComposableElement.php b/src/core/ComposableElement.php index f4eb5ad1..3cdcb08c 100644 --- a/src/core/ComposableElement.php +++ b/src/core/ComposableElement.php @@ -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; } @@ -291,16 +289,18 @@ final public static function __xhpReflectionChildrenDeclaration( final public static function __xhpReflectionCategoryDeclaration( ): Set { - 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 { @@ -592,8 +592,9 @@ final protected function validateAttributeValue( } 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 */ TypeAssert\matches_type_structure($type_structure, $val); @@ -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); @@ -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); @@ -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); @@ -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, + ); } }