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

Commit 0884408

Browse files
lexidorfredemmott
authored andcommitted
Repair xhp-lib@v3 on newer hhvm versions
- Remove private on final methods. - Add more fixme's for calling __toString() on StringishObject. - Wrap noreturn functions into void wrappers, because coeffect tracking does not work in unreachable code.
1 parent a26d867 commit 0884408

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

src/core/ComposableElement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ protected function validateChildren(): void {
614614
}
615615
}
616616

617-
final private function validateChildrenExpression(
617+
private function validateChildrenExpression(
618618
ReflectionXHPChildrenExpression $expr,
619619
int $index,
620620
): (bool, int) {
@@ -685,7 +685,7 @@ final private function validateChildrenExpression(
685685
}
686686
}
687687

688-
final private function validateChildrenRule(
688+
private function validateChildrenRule(
689689
ReflectionXHPChildrenExpression $expr,
690690
int $index,
691691
): (bool, int) {

src/core/Primitive.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final public function toString(): string {
2626
return $that->stringify();
2727
}
2828

29-
final private async function __flushElementChildren(): Awaitable<void> {
29+
private async function __flushElementChildren(): Awaitable<void> {
3030
$children = $this->getChildren();
3131
$awaitables = Map {};
3232
foreach ($children as $idx => $child) {

src/core/XHPAttributeCoercion.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ public static function CoerceToString(
7272
return (string)$val;
7373
}
7474
if ($val is Stringish) {
75-
return /* HH_FIXME[4128] */ $val->__toString();
75+
/* HH_FIXME[4053] HH_FIXME[4062] HH_FIXME[4128]
76+
We know that $val is (not string & Stringish).
77+
This implies StringishObject, so calling __toString() is safe.
78+
StringishObject was added in hhvm 4.118 and this branch targets 4.32+. */
79+
return $val->__toString();
7680
}
7781

7882
throw new XHPInvalidAttributeException($context, 'string', $attr, $val);

tests/AttributesTest.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ public function testValidTypes(): void {
9494
}
9595

9696
public function testShapeWithExtraKey(): void {
97-
self::markTestSkipped('Only enums are validated at runtime.');
97+
(): void ==> {
98+
self::markTestSkipped('Only enums are validated at runtime.');
99+
}();
98100
expect(() ==> {
99101

100102
$x =
@@ -107,7 +109,9 @@ public function testShapeWithExtraKey(): void {
107109
}
108110

109111
public function testShapeWithMissingOptionalKey(): void {
110-
self::markTestSkipped('Only enums are validated at runtime.');
112+
(): void ==> {
113+
self::markTestSkipped('Only enums are validated at runtime.');
114+
}();
111115
expect(() ==> {
112116

113117
/* HH_IGNORE_ERROR[4057] */
@@ -117,7 +121,9 @@ public function testShapeWithMissingOptionalKey(): void {
117121
}
118122

119123
public function testShapeWithMissingRequiredKey(): void {
120-
self::markTestSkipped('Only enums are validated at runtime.');
124+
(): void ==> {
125+
self::markTestSkipped('Only enums are validated at runtime.');
126+
}();
121127
expect(() ==> {
122128
/* HH_IGNORE_ERROR[4057] */
123129
$x = <test:attribute-types myshape={shape()} />;
@@ -132,7 +138,9 @@ public function testValidArrayKeys(): void {
132138
}
133139

134140
public function testInvalidArrayKeys(): void {
135-
self::markTestSkipped('Only enums are validated at runtime.');
141+
(): void ==> {
142+
self::markTestSkipped('Only enums are validated at runtime.');
143+
}();
136144
expect(() ==> {
137145
$x =
138146
<test:attribute-types
@@ -150,7 +158,9 @@ public function testValidNum(): void {
150158
}
151159

152160
public function testInvalidNum(): void {
153-
self::markTestSkipped('Only enums are validated at runtime.');
161+
(): void ==> {
162+
self::markTestSkipped('Only enums are validated at runtime.');
163+
}();
154164

155165
expect(() ==> {
156166
$x =
@@ -332,7 +342,9 @@ public function testNumericPrefixStringAsFloat(): void {
332342
}
333343

334344
public function testNotAContainerAsArray(): void {
335-
self::markTestSkipped('Only enums are validated at runtime.');
345+
(): void ==> {
346+
self::markTestSkipped('Only enums are validated at runtime.');
347+
}();
336348
expect(() ==> {
337349
$x =
338350
<test:attribute-types
@@ -344,7 +356,9 @@ public function testNotAContainerAsArray(): void {
344356
}
345357

346358
public function testHackContainerAsArray(): void {
347-
self::markTestSkipped('Only enums are validated at runtime.');
359+
(): void ==> {
360+
self::markTestSkipped('Only enums are validated at runtime.');
361+
}();
348362
expect(() ==> {
349363
$x =
350364
<test:attribute-types
@@ -354,7 +368,9 @@ public function testHackContainerAsArray(): void {
354368
}
355369

356370
public function testIncompatibleObjectAsObject(): void {
357-
self::markTestSkipped('Only enums are validated at runtime.');
371+
(): void ==> {
372+
self::markTestSkipped('Only enums are validated at runtime.');
373+
}();
358374
expect(() ==> {
359375
$x =
360376
<test:attribute-types
@@ -366,7 +382,9 @@ public function testIncompatibleObjectAsObject(): void {
366382
}
367383

368384
public function testPassingArrayAsVector(): void {
369-
self::markTestSkipped('Only enums are validated at runtime.');
385+
(): void ==> {
386+
self::markTestSkipped('Only enums are validated at runtime.');
387+
}();
370388
expect(() ==> {
371389
$x =
372390
<test:attribute-types
@@ -433,7 +451,9 @@ public function testSpecialAttributes(): void {
433451
}
434452

435453
public function testRenderCallableAttribute(): void {
436-
self::markTestSkipped('This type has been unsupported since 2.0');
454+
(): void ==> {
455+
self::markTestSkipped('This type has been unsupported since 2.0');
456+
}();
437457
expect(() ==> {
438458
$x =
439459
<test:callable-attribute

0 commit comments

Comments
 (0)