This repository was archived by the owner on Mar 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathPromiseObject.php
91 lines (80 loc) · 2.16 KB
/
PromiseObject.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php declare(strict_types=1);
/**
* This file is part of the phpv8/php-v8 PHP extension.
*
* Copyright (c) 2015-2018 Bogdan Padalko <thepinepain@gmail.com>
*
* Licensed under the MIT license: http://opensource.org/licenses/MIT
*
* For the full copyright and license information, please view the
* LICENSE file that was distributed with this source or visit
* http://opensource.org/licenses/MIT
*/
namespace V8;
class PromiseObject extends ObjectValue
{
const STATE_PENDING = 0;
const STATE_FULFILLED = 1;
const STATE_REJECTED = 2;
/**
* @param Context $context
*/
public function __construct(Context $context)
{
}
/**
* Register a resolution/rejection handler with the promise.
*
* The handler is given the respective rejection value as
* an argument. If the promise is already rejected, the handler is
* invoked at the end of turn.
*
* @param Context $context
* @param FunctionObject $handler
*
* @return PromiseObject
*/
public function catch(Context $context, FunctionObject $handler): PromiseObject
{
}
/**
* Register a resolution/rejection handler with the promise.
*
* The handler is given the respective resolution value as
* an argument. If the promise is already resolved, the handler is
* invoked at the end of turn.
*
* @param Context $context
* @param FunctionObject $handler
*
* @return PromiseObject
*/
public function then(Context $context, FunctionObject $handler): PromiseObject
{
}
/**
* Returns true if the promise has at least one derived promise, and
* therefore resolve/reject handlers (including default handler).
*
* @return bool
*/
public function hasHandler(): bool
{
}
/**
* Returns the content of the promise result (resolve or reject value). The Promise must not be pending.
*
* @return Value|PrimitiveValue|ObjectValue
*/
public function result(): Value
{
}
/**
* Returns the promise state value.
*
* @return int
*/
public function state(): int
{
}
}