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

Commit 0f5a32c

Browse files
committed
Make XHPAsync implement the XHPAwaitable trait
Slightly reduces boilerplate, and it's just a marker interface.
1 parent 83d3daf commit 0f5a32c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/core/XHPAsync.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
*
1010
*/
1111

12-
trait XHPAsync {
13-
12+
trait XHPAsync implements XHPAwaitable {
1413
require extends :x:element;
15-
require implements XHPAwaitable;
1614

1715
abstract protected function asyncRender(): Awaitable<XHPRoot>;
1816

tests/AsyncTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?hh
22

3-
class :async:test extends :x:element implements XHPAwaitable {
3+
class :async:test extends :x:element {
44
use XHPAsync;
55

66
protected async function asyncRender(): Awaitable<XHPRoot> {
@@ -39,4 +39,9 @@ public function testNestedWithNonAsyncChild() {
3939
$xhp = <async:test><b>BE BOLD</b></async:test>;
4040
$this->assertEquals('<div><b>BE BOLD</b></div>', $xhp->toString());
4141
}
42+
43+
public function testInstanceOfInterface() {
44+
$xhp = <async:test><b>BE BOLD</b></async:test>;
45+
$this->assertInstanceOf(XHPAwaitable::class, $xhp);
46+
}
4247
}

0 commit comments

Comments
 (0)