-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfuture.stub.php
More file actions
186 lines (158 loc) · 4.69 KB
/
future.stub.php
File metadata and controls
186 lines (158 loc) · 4.69 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
/** @generate-class-entries */
namespace Async;
/**
* A back-end class for the Future class.
* The owner of this object can resolve the state of the Future. The class is a descendant of Notifier and can
* participate in the EventLoop.
*
* @strict-properties
* @not-serializable
* @template T
*/
final class FutureState
{
public function __construct() {}
/**
* Completes the operation with a result value.
*
* @param T $result Result of the operation.
*/
public function complete(mixed $result): void {}
/**
* Marks the operation as failed.
*
* @param \Throwable $throwable Throwable to indicate the error.
*/
public function error(\Throwable $throwable): void {}
/**
* @return bool True if the operation has completed.
*/
public function isCompleted(): bool {}
/**
* Suppress the exception thrown to the loop error handler if and operation error is not handled by a callback.
*/
public function ignore(): void {}
/**
* Return awaiting debug information.
*/
public function getAwaitingInfo(): array {}
/**
* Return the file and line number where the FutureState was created.
*/
public function getCreatedFileAndLine(): array {}
/**
* Return the location where the FutureState was created as string.
*/
public function getCreatedLocation(): string {}
/**
* Return the file and line number where the FutureState was completed.
*/
public function getCompletedFileAndLine(): array {}
/**
* Return the location where the FutureState was completed as string.
*/
public function getCompletedLocation(): string {}
}
/**
* @template-covariant T
*/
final class Future implements Completable
{
/**
* @template Tv
*
* @param Tv $value
*
* @return Future<Tv>
*/
public static function completed(mixed $value = null): Future {}
/**
* @return Future<never>
*/
public static function failed(\Throwable $throwable): Future {}
/**
* param FutureState<T> $state
*/
public function __construct(FutureState $state) {}
/**
* @return bool True if the operation has completed.
*/
public function isCompleted(): bool {}
/**
* Return true if the future is cancelled.
*/
public function isCancelled(): bool {}
/**
* Cancel the future.
*/
public function cancel(?AsyncCancellation $cancellation = null): void {}
/**
* Do not forward unhandled errors to the event loop handler.
*
* @return Future<T>
*/
public function ignore(): Future {}
/**
* Attaches a callback that is invoked if this future completes. The returned future is completed with the return
* value of the callback, or errors with an exception thrown from the callback.
*
* @psalm-suppress InvalidTemplateParam
*
* @template Tr
*
* @param callable(T):Tr $map
*
* @return Future<Tr>
*/
public function map(callable $map): Future {}
/**
* Attaches a callback that is invoked if this future errors. The returned future is completed with the return
* value of the callback, or errors with an exception thrown from the callback.
*
* @template Tr
*
* @param callable(\Throwable):Tr $catch
*
* @return Future<Tr>
*/
public function catch(callable $catch): Future {}
/**
* Attaches a callback that is always invoked when the future is completed. The returned future resolves with the
* same value as this future once the callback has finished execution. If the callback throws, the returned future
* will error with the thrown exception.
*
* @param \Closure():void $finally
*
* @return Future<T>
*/
public function finally(callable $finally): Future {}
/**
* Awaits the operation to complete.
*
* Throws an exception if the operation fails.
*
* @return T
*/
public function await(?Completable $cancellation = null): mixed {}
/**
* Return awaiting debug information.
*/
public function getAwaitingInfo(): array {}
/**
* Return the file and line number where the Future was created.
*/
public function getCreatedFileAndLine(): array {}
/**
* Return the location where the Future was created as string.
*/
public function getCreatedLocation(): string {}
/**
* Return the file and line number where the Future was completed.
*/
public function getCompletedFileAndLine(): array {}
/**
* Return the location where the Future was completed as string.
*/
public function getCompletedLocation(): string {}
}