Documentation

Option
in package

AbstractYes
Tags
template

T

psalm-inheritors

Some|None

psalm-yield

T

Table of Contents

Methods

filter()  : Option<string|int, T>
flatMap()  : Option<string|int, O>
flatten()  : Option
getNullable()  : T|null
isNone()  : bool
isSome()  : bool
isSomeAnd()  : bool
map()  : Option<string|int, O>
mapOr()  : O
None()  : Option<string|int, mixed>
Some()  : Option<string|int, U>
try()  : Option<string|int, U>
unwrap()  : T
Get the value out of the Option if `Some` variant.
unwrapOr()  : T
Get the value out of the Option if `Some` variant.
unwrapOrElse()  : T
Get the value out of the Option if `Some` variant.
with()  : Option<string|int, O>
wrap()  : Option<string|int, U>
Wraps a value into an Option.
wrapProcedure()  : Option<string|int, U>
Wraps the return value of the given procedure into an Option.

Methods

filter()

public abstract filter(callable $predicate) : Option<string|int, T>
Parameters
$predicate : callable
Return values
Option<string|int, T>

flatMap()

public abstract flatMap(callable $f) : Option<string|int, O>
Parameters
$f : callable
Tags
template

O

Return values
Option<string|int, O>

flatten()

public abstract flatten() : Option
Tags
template

U

psalm-return

(T is Option<U> ? Option<U> : Option<T>)

Return values
Option

getNullable()

public abstract getNullable() : T|null
Return values
T|null

isNone()

public abstract isNone() : bool
Tags
psalm-assert-if-true

None $this

Return values
bool

isSome()

public abstract isSome() : bool
Tags
psalm-assert-if-true

Some<T> $this

Return values
bool

isSomeAnd()

public abstract isSomeAnd(callable $predicate) : bool
Parameters
$predicate : callable
Tags
psalm-assert-if-true

Some<T> $this

Return values
bool

map()

public abstract map(callable $f) : Option<string|int, O>
Parameters
$f : callable
Tags
template

O

Return values
Option<string|int, O>

mapOr()

public abstract mapOr(O $default, callable $f) : O
Parameters
$default : O
$f : callable
Tags
template

O

Return values
O

None()

public final static None() : Option<string|int, mixed>
Return values
Option<string|int, mixed>

Some()

public final static Some(U $value) : Option<string|int, U>
Parameters
$value : U
Tags
template

U

Return values
Option<string|int, U>

try()

public final static try(callable $procedure) : Option<string|int, U>
Parameters
$procedure : callable
Tags
template

U

Return values
Option<string|int, U>

unwrap()

Get the value out of the Option if `Some` variant.

public abstract unwrap() : T

Throws otherwise.

Tags
psalm-mutation-free
throws
RuntimeException

when variant is None

Return values
T

unwrapOr()

Get the value out of the Option if `Some` variant.

public abstract unwrapOr(T $default) : T

Returns the provided default value otherwise.

Parameters
$default : T
Tags
psalm-mutation-free
Return values
T

unwrapOrElse()

Get the value out of the Option if `Some` variant.

public abstract unwrapOrElse(callable $f) : T

Returns the result of the provided callable otherwise.

Parameters
$f : callable
Return values
T

with()

public final static with(callable $expr) : Option<string|int, O>
Parameters
$expr : callable
Tags
template

U

template

O

psalm-suppress

InvalidArgument

Return values
Option<string|int, O>

wrap()

Wraps a value into an Option.

public final static wrap(U $value[, mixed $nullValue = null ]) : Option<string|int, U>

If the value is equal to null (or to the specified $nullValue), it will return None variant.

Parameters
$value : U
$nullValue : mixed = null
Tags
template

U

Return values
Option<string|int, U>

wrapProcedure()

Wraps the return value of the given procedure into an Option.

public final static wrapProcedure(callable $procedure[, mixed $nullValue = null ]) : Option<string|int, U>

If the value is equal to null (or to the specified $nullValue), it will return None variant.

Parameters
$procedure : callable
$nullValue : mixed = null
Tags
template

U

Return values
Option<string|int, U>

        
On this page

Search results