trait PreventsCircularRecursion (View source)

Properties

static protected WeakMap<static,array<string,mixed>> $recursionCache

The cache of objects processed to prevent infinite recursion.

Methods

mixed
withoutRecursion(callable $callback, mixed $default = null)

Prevent a method from being called multiple times on the same object within the same call stack.

static 
clearRecursiveCallValue(object $object, string $hash)

Remove an entry from the recursion cache for an object.

static array
getRecursiveCallStack(object $object)

Get the stack of methods being called recursively for the current object.

static WeakMap
getRecursionCache()

Get the current recursion cache being used by the model.

static mixed
setRecursiveCallValue(object $object, string $hash, mixed $value)

Set a value in the recursion cache for the given object and method.

Details

protected mixed withoutRecursion(callable $callback, mixed $default = null)

Prevent a method from being called multiple times on the same object within the same call stack.

Parameters

callable $callback
mixed $default

Return Value

mixed

static protected clearRecursiveCallValue(object $object, string $hash)

Remove an entry from the recursion cache for an object.

Parameters

object $object
string $hash

static protected array getRecursiveCallStack(object $object)

Get the stack of methods being called recursively for the current object.

Parameters

object $object

Return Value

array

static protected WeakMap getRecursionCache()

Get the current recursion cache being used by the model.

Return Value

WeakMap

static protected mixed setRecursiveCallValue(object $object, string $hash, mixed $value)

Set a value in the recursion cache for the given object and method.

Parameters

object $object
string $hash
mixed $value

Return Value

mixed