trait Macro

Trait Macros.

Allows users to register macros within the Carbon class.

Traits

Trait Mixin.

Properties

staticprotectedarray $macroContextStack Stack of macro instance contexts. from Mixin
staticprotectedarray $globalMacros The registered macros.
staticprotectedarray $globalGenericMacros The registered generic macros.

Methods

static void
mixin(object|string$mixin)

Mix another object into the class.

from Mixin
static mixed
bindMacroContext(Mixin|null$context,callable$callable)

Stack a Carbon context from inside calls of self::this() and execute a given action.

from Mixin
static Mixin|null
context()

Return the current context from inside a macro callee or a null if static.

from Mixin
static Mixin
this()

Return the current context from inside a macro callee or a new one if static.

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

Register a custom macro.

static 
resetMacros()

Remove all macros and generic macros.

static void
genericMacro(object|callable$macro,int$priority =0)

Register a custom macro.

static bool
hasMacro(string$name)

Checks if macro is registered globally.

static callable|null
getMacro(string$name)

Get the raw callable macro registered globally for a given name.

bool
hasLocalMacro(string$name)

Checks if macro is registered globally or locally.

callable|null
getLocalMacro(string$name)

Get the raw callable macro registered globally or locally for a given name.

Details

inMixinat line66
staticvoid mixin(object|string$mixin)

Mix another object into the class.

Parameters

object|string $mixin

Return Value

void

Exceptions

ReflectionException

inMixinat line151
staticprotectedmixed bindMacroContext(Mixin|null$context,callable$callable)

Stack a Carbon context from inside calls of self::this() and execute a given action.

Parameters

Mixin|null $context
callable $callable

Return Value

mixed

Exceptions

Throwable

inMixinat line177
staticprotectedMixin|null context()

Return the current context from inside a macro callee or a null if static.

Return Value

Mixin|null

inMixinat line187
staticprotectedMixin this()

Return the current context from inside a macro callee or a new one if static.

Return Value

Mixin

at line57
staticvoid macro(string$name,object|callable$macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

at line65
static resetMacros()

Remove all macros and generic macros.

at line79
staticvoid genericMacro(object|callable$macro,int$priority =0)

Register a custom macro.

Parameters

object|callable $macro
int $priority marco with higher priority is tried first

Return Value

void

at line96
staticbool hasMacro(string$name)

Checks if macro is registered globally.

Parameters

string $name

Return Value

bool

at line108
staticcallable|null getMacro(string$name)

Get the raw callable macro registered globally for a given name.

Parameters

string $name

Return Value

callable|null

at line120
bool hasLocalMacro(string$name)

Checks if macro is registered globally or locally.

Parameters

string $name

Return Value

bool

at line132
callable|null getLocalMacro(string$name)

Get the raw callable macro registered globally or locally for a given name.

Parameters

string $name

Return Value

callable|null