class Context extends Facade

Constants

protected STATE_CONTEXT_KEY

The context key for the coroutine-local facade roots.

Properties

static protected Container|null $app

The application instance being facaded.

from  Facade
static protected array $resolvedInstance

The resolved object instances.

from  Facade
static protected array<string, true> $scopedAccessors

Accessors whose resolved objects belong to a coroutine scope.

from  Facade
static protected array<string, int> $coroutineAccessors

Accessors with coroutine-local roots, and their current generation.

from  Facade
static protected bool $cached

Indicates if the resolved instance should be cached.

from  Facade

Methods

static void
resolved(Closure $callback)

Run a Closure when the facade has been resolved.

from  Facade
static MockInterface|null
spy()

Convert the facade into a Mockery spy.

from  Facade
static MockInterface
partialMock()

Initiate a partial mock on the facade.

from  Facade
static CompositeExpectation|Expectation|HigherOrderMessage
shouldReceive()

Initiate a mock expectation on the facade.

from  Facade
static CompositeExpectation|Expectation|ExpectsHigherOrderMessage
expects()

Initiate a mock expectation on the facade.

from  Facade
static MockInterface
createFreshMockInstance()

Create a fresh mock instance for the given class.

from  Facade
static MockInterface
createMock()

Create a fresh mock instance for the given class.

from  Facade
static bool
isMock()

Determines whether a mock is set as the instance of the facade.

from  Facade
static string|null
getMockableClass()

Get the mockable class for the bound instance.

from  Facade
static void
swap(mixed $instance)

Hotswap the underlying instance behind the facade.

from  Facade
static bool
isFake()

Determines whether a "fake" has been set as the facade instance.

from  Facade
static mixed
getFacadeRoot()

Get the root object behind the facade.

from  Facade
static string
getFacadeAccessor()

Get the registered name of the component.

static mixed
resolveFacadeInstance(string $name)

Resolve the facade root instance from the coroutine context.

static void
clearResolvedInstance(string|null $name = null)

Clear a resolved facade instance.

from  Facade
static void
clearResolvedInstances()

Clear all of the resolved instances.

from  Facade
static Collection
defaultAliases()

Get the application default aliases.

from  Facade
static Container|null
getFacadeApplication()

Get the application instance behind the facade.

from  Facade
static void
setFacadeApplication(Container|null $app)

Set the application instance.

from  Facade
static mixed
__callStatic(string $method, array $args)

Handle dynamic, static calls to the object.

from  Facade
static Repository
add(array<string $, mixed>|string $key, mixed $value = 'null')

No description

static Repository
addHidden(array<string $, mixed>|string $key, mixed $value = 'null')

No description

static Repository
addHiddenIf(string $key, mixed $value)

No description

static Repository
addIf(string $key, mixed $value)

No description

static void
array()

<string, mixed> onlyHidden(array<int, string> $keys)

static Repository
decrement(string $key, int $amount = '1')

No description

static Repository
dehydrating(callable $callback)

No description

static Repository
flush()

No description

static void
flushMacros()

No description

static void
flushState()

No description

static Repository
forget(array<int $, string>|string $key)

No description

static Repository
forgetHidden(array<int $, string>|string $key)

No description

static mixed
get(string $key, mixed $default = 'null')

No description

static mixed
getHidden(string $key, mixed $default = 'null')

No description

static Repository
getInstance()

No description

static Repository
handleUnserializeExceptionsUsing(callable|null $callback)

No description

static bool
has(string $key)

No description

static bool
hasHidden(string $key)

No description

static bool
hasInstance()

No description

static bool
hasMacro(string $name)

No description

static bool
hiddenStackContains(string $key, mixed $value, bool $strict = 'false')

No description

static Repository
hydrated(callable $callback)

No description

static Repository
increment(string $key, int $amount = '1')

No description

static bool
isEmpty()

No description

static void
macro(string $name, callable|object $macro)

No description

static bool
missing(string $key)

No description

static bool
missingHidden(string $key)

No description

static void
mixin(object $mixin, bool $replace = 'true')

No description

static mixed
pop(string $key)

No description

static mixed
popHidden(string $key)

No description

static mixed
pull(string $key, mixed $default = 'null')

No description

static mixed
pullHidden(string $key, mixed $default = 'null')

No description

static Repository
push(string $key, mixed ...$values)

No description

static Repository
pushHidden(string $key, mixed ...$values)

No description

static mixed
remember(string $key, mixed $value)

No description

static mixed
rememberHidden(string $key, mixed $value)

No description

static Repository
replicate()

No description

static Model
restoreModel(ModelIdentifier $value)

No description

static mixed
scope(callable $callback, array<string $, mixed> $data = '[]', mixed> $hidden = '[]')

No description

static bool
stackContains(string $key, mixed $value, bool $strict = 'false')

No description

static mixed
unless(mixed $value = 'null', null|callable $callback = 'null', null|callable $default = 'null')

No description

static mixed
when(mixed $value = 'null', null|callable $callback = 'null', null|callable $default = 'null')

No description

Details

in Facade at line 85
static void resolved(Closure $callback)

Run a Closure when the facade has been resolved.

The callback is registered on the worker-global container and runs for every subsequent resolution of the facade accessor.

Parameters

Closure $callback

Return Value

void

in Facade at line 106
static MockInterface|null spy()

Convert the facade into a Mockery spy.

Swaps the resolved facade instance for the worker lifetime.

Return Value

MockInterface|null

in Facade at line 125
static MockInterface partialMock()

Initiate a partial mock on the facade.

Swaps the resolved facade instance for the worker lifetime.

Return Value

MockInterface

in Facade at line 142
static CompositeExpectation|Expectation|HigherOrderMessage shouldReceive()

Initiate a mock expectation on the facade.

Swaps the resolved facade instance for the worker lifetime.

Return Value

CompositeExpectation|Expectation|HigherOrderMessage

in Facade at line 159
static CompositeExpectation|Expectation|ExpectsHigherOrderMessage expects()

Initiate a mock expectation on the facade.

Swaps the resolved facade instance for the worker lifetime.

Return Value

CompositeExpectation|Expectation|ExpectsHigherOrderMessage

in Facade at line 176
static protected MockInterface createFreshMockInstance()

Create a fresh mock instance for the given class.

Swaps the resolved facade instance for the worker lifetime.

Return Value

MockInterface

in Facade at line 189
static protected MockInterface createMock()

Create a fresh mock instance for the given class.

Return Value

MockInterface

in Facade at line 199
static protected bool isMock()

Determines whether a mock is set as the instance of the facade.

Return Value

bool

in Facade at line 210
static protected string|null getMockableClass()

Get the mockable class for the bound instance.

Return Value

string|null

in Facade at line 226
static void swap(mixed $instance)

Hotswap the underlying instance behind the facade.

Replaces the worker-wide resolved facade instance and container binding; runtime use races across coroutines and changes every subsequent facade call.

Parameters

mixed $instance

Return Value

void

in Facade at line 239
static bool isFake()

Determines whether a "fake" has been set as the facade instance.

Return Value

bool

in Facade at line 250
static mixed getFacadeRoot()

Get the root object behind the facade.

Return Value

mixed

at line 65
static protected string getFacadeAccessor()

Get the registered name of the component.

Return Value

string

at line 76
static protected mixed resolveFacadeInstance(string $name)

Resolve the facade root instance from the coroutine context.

Resolve directly from CoroutineContext, which also owns the instance returned by the container binding.

Parameters

string $name

Return Value

mixed

in Facade at line 312
static void clearResolvedInstance(string|null $name = null)

Clear a resolved facade instance.

Later facade calls everywhere resolve again; only references already held keep the previous instance.

Parameters

string|null $name

Return Value

void

in Facade at line 330
static void clearResolvedInstances()

Clear all of the resolved instances.

Later facade calls everywhere resolve again; only references already held keep the previous instances.

Return Value

void

in Facade at line 344
static Collection defaultAliases()

Get the application default aliases.

Return Value

Collection

in Facade at line 404
static Container|null getFacadeApplication()

Get the application instance behind the facade.

Return Value

Container|null

in Facade at line 415
static void setFacadeApplication(Container|null $app)

Set the application instance.

Replaces the worker-wide facade application reference; runtime use races across coroutines and breaks every facade lookup.

Parameters

Container|null $app

Return Value

void

in Facade at line 427
static mixed __callStatic(string $method, array $args)

Handle dynamic, static calls to the object.

Parameters

string $method
array $args

Return Value

mixed

Exceptions

RuntimeException
Throwable

at line 60
static Repository add(array<string $, mixed>|string $key, mixed $value = 'null')

No description

Parameters

array<string $
mixed>|string $key
mixed $value

Return Value

Repository

at line 60
static Repository addHidden(array<string $, mixed>|string $key, mixed $value = 'null')

No description

Parameters

array<string $
mixed>|string $key
mixed $value

Return Value

Repository

at line 60
static Repository addHiddenIf(string $key, mixed $value)

No description

Parameters

string $key
mixed $value

Return Value

Repository

at line 60
static Repository addIf(string $key, mixed $value)

No description

Parameters

string $key
mixed $value

Return Value

Repository

at line 60
static void array()

<string, mixed> onlyHidden(array<int, string> $keys)

Return Value

void

at line 60
static Repository decrement(string $key, int $amount = '1')

No description

Parameters

string $key
int $amount

Return Value

Repository

at line 60
static Repository dehydrating(callable $callback)

No description

Parameters

callable $callback

Return Value

Repository

at line 60
static Repository flush()

No description

Return Value

Repository

at line 60
static void flushMacros()

No description

Return Value

void

at line 60
static void flushState()

No description

Return Value

void

at line 60
static Repository forget(array<int $, string>|string $key)

No description

Parameters

array<int $
string>|string $key

Return Value

Repository

at line 60
static Repository forgetHidden(array<int $, string>|string $key)

No description

Parameters

array<int $
string>|string $key

Return Value

Repository

at line 60
static mixed get(string $key, mixed $default = 'null')

No description

Parameters

string $key
mixed $default

Return Value

mixed

at line 60
static mixed getHidden(string $key, mixed $default = 'null')

No description

Parameters

string $key
mixed $default

Return Value

mixed

at line 60
static Repository getInstance()

No description

Return Value

Repository

at line 60
static Repository handleUnserializeExceptionsUsing(callable|null $callback)

No description

Parameters

callable|null $callback

Return Value

Repository

at line 60
static bool has(string $key)

No description

Parameters

string $key

Return Value

bool

at line 60
static bool hasHidden(string $key)

No description

Parameters

string $key

Return Value

bool

at line 60
static bool hasInstance()

No description

Return Value

bool

at line 60
static bool hasMacro(string $name)

No description

Parameters

string $name

Return Value

bool

at line 60
static bool hiddenStackContains(string $key, mixed $value, bool $strict = 'false')

No description

Parameters

string $key
mixed $value
bool $strict

Return Value

bool

at line 60
static Repository hydrated(callable $callback)

No description

Parameters

callable $callback

Return Value

Repository

at line 60
static Repository increment(string $key, int $amount = '1')

No description

Parameters

string $key
int $amount

Return Value

Repository

at line 60
static bool isEmpty()

No description

Return Value

bool

at line 60
static void macro(string $name, callable|object $macro)

No description

Parameters

string $name
callable|object $macro

Return Value

void

at line 60
static bool missing(string $key)

No description

Parameters

string $key

Return Value

bool

at line 60
static bool missingHidden(string $key)

No description

Parameters

string $key

Return Value

bool

at line 60
static void mixin(object $mixin, bool $replace = 'true')

No description

Parameters

object $mixin
bool $replace

Return Value

void

at line 60
static mixed pop(string $key)

No description

Parameters

string $key

Return Value

mixed

at line 60
static mixed popHidden(string $key)

No description

Parameters

string $key

Return Value

mixed

at line 60
static mixed pull(string $key, mixed $default = 'null')

No description

Parameters

string $key
mixed $default

Return Value

mixed

at line 60
static mixed pullHidden(string $key, mixed $default = 'null')

No description

Parameters

string $key
mixed $default

Return Value

mixed

at line 60
static Repository push(string $key, mixed ...$values)

No description

Parameters

string $key
mixed ...$values

Return Value

Repository

at line 60
static Repository pushHidden(string $key, mixed ...$values)

No description

Parameters

string $key
mixed ...$values

Return Value

Repository

at line 60
static mixed remember(string $key, mixed $value)

No description

Parameters

string $key
mixed $value

Return Value

mixed

at line 60
static mixed rememberHidden(string $key, mixed $value)

No description

Parameters

string $key
mixed $value

Return Value

mixed

at line 60
static Repository replicate()

No description

Return Value

Repository

at line 60
static Model restoreModel(ModelIdentifier $value)

No description

Parameters

ModelIdentifier $value

Return Value

Model

at line 60
static mixed scope(callable $callback, array<string $, mixed> $data = '[]', mixed> $hidden = '[]')

No description

Parameters

callable $callback
array<string $
mixed> $data
mixed> $hidden

Return Value

mixed

at line 60
static bool stackContains(string $key, mixed $value, bool $strict = 'false')

No description

Parameters

string $key
mixed $value
bool $strict

Return Value

bool

at line 60
static mixed unless(mixed $value = 'null', null|callable $callback = 'null', null|callable $default = 'null')

No description

Parameters

mixed $value
null|callable $callback
null|callable $default

Return Value

mixed

at line 60
static mixed when(mixed $value = 'null', null|callable $callback = 'null', null|callable $default = 'null')

No description

Parameters

mixed $value
null|callable $callback
null|callable $default

Return Value

mixed