Documentation

Future
in package
uses ForbidCloning, ForbidSerialization

FinalYes
Tags
template-covariant

Table of Contents

Properties

$state  : FutureState<string|int, T>

Methods

__serialize()  : never
__unserialize()  : never
await()  : T
Awaits the operation to complete.
catch()  : Future<string|int, Tr>
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.
complete()  : Future<string|int, Tv>
error()  : Future<string|int, never>
finally()  : Future<string|int, T>
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.
ignore()  : Future<string|int, T>
Do not forward unhandled errors to the event loop handler.
isComplete()  : bool
iterate()  : iterable<Tk, Future<string|int, Tv>>
Iterate over the given futures in completion order.
map()  : Future<string|int, Tr>
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.
__clone()  : mixed

Properties

$state read-only

private FutureState<string|int, T> $state

Methods

__unserialize()

public final __unserialize(array<string|int, mixed> $data) : never
Parameters
$data : array<string|int, mixed>
Return values
never

await()

Awaits the operation to complete.

public await([Cancellation|null $cancellation = null ]) : T

Throws an exception if the operation fails.

Parameters
$cancellation : Cancellation|null = null
Return values
T

catch()

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.

public catch(callable(Throwable): Tr $catch) : Future<string|int, Tr>
Parameters
$catch : callable(Throwable): Tr
Tags
template
Return values
Future<string|int, Tr>

complete()

public static complete([Tv $value = null ]) : Future<string|int, Tv>
Parameters
$value : Tv = null
Tags
template
Return values
Future<string|int, Tv>

error()

public static error(Throwable $throwable) : Future<string|int, never>
Parameters
$throwable : Throwable
Return values
Future<string|int, never>

finally()

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.

public finally(callable(): void $finally) : Future<string|int, T>
Parameters
$finally : callable(): void
Return values
Future<string|int, T>

ignore()

Do not forward unhandled errors to the event loop handler.

public ignore() : Future<string|int, T>
Return values
Future<string|int, T>

isComplete()

public isComplete() : bool
Return values
bool

True if the operation has completed.

iterate()

Iterate over the given futures in completion order.

public static iterate(iterable<Tk, Future<string|int, Tv>> $futures[, Cancellation|null $cancellation = null ]) : iterable<Tk, Future<string|int, Tv>>
Parameters
$futures : iterable<Tk, Future<string|int, Tv>>
$cancellation : Cancellation|null = null

Optional cancellation.

Tags
template
template
Return values
iterable<Tk, Future<string|int, Tv>>

map()

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.

public map(callable(T): Tr $map) : Future<string|int, Tr>
Parameters
$map : callable(T): Tr
Tags
psalm-suppress

InvalidTemplateParam

template
Return values
Future<string|int, Tr>

        
On this page

Search results