W3cubDocs

/Symfony 4.1

AbstractCloner

abstract class AbstractCloner implements ClonerInterface

AbstractCloner implements a generic caster mechanism for objects and resources.

Properties

static $defaultCasters
protected $maxItems
protected $maxString
protected $minDepth

Methods

__construct(array $casters = null)
addCasters(array $casters)

Adds casters for resources and objects.

setMaxItems(int $maxItems)

Sets the maximum number of items to clone past the minimum depth in nested structures.

setMaxString(int $maxString)

Sets the maximum cloned length for strings.

setMinDepth(int $minDepth)

Sets the minimum tree depth where we are guaranteed to clone all the items. After this depth is reached, only setMaxItems items will be cloned.

Data cloneVar(mixed $var, int $filter = 0)

Clones a PHP variable.

array doClone(mixed $var)

Effectively clones the PHP variable.

array castObject(Stub $stub, bool $isNested)

Casts an object to an array representation.

array castResource(Stub $stub, bool $isNested)

Casts a resource to an array representation.

Details

__construct(array $casters = null)

Parameters

array $casters A map of casters

See also

addCasters

addCasters(array $casters)

Adds casters for resources and objects.

Maps resources or objects types to a callback. Types are in the key, with a callable caster for value. Resource types are to be prefixed with a :, see e.g. static::$defaultCasters.

Parameters

array $casters A map of casters

setMaxItems(int $maxItems)

Sets the maximum number of items to clone past the minimum depth in nested structures.

Parameters

int $maxItems

setMaxString(int $maxString)

Sets the maximum cloned length for strings.

Parameters

int $maxString

setMinDepth(int $minDepth)

Sets the minimum tree depth where we are guaranteed to clone all the items. After this depth is reached, only setMaxItems items will be cloned.

Parameters

int $minDepth

Data cloneVar(mixed $var, int $filter = 0)

Clones a PHP variable.

Parameters

mixed $var Any PHP variable
int $filter A bit field of Caster::EXCLUDE_* constants

Return Value

Data The cloned variable represented by a Data object

abstract protected array doClone(mixed $var)

Effectively clones the PHP variable.

Parameters

mixed $var Any PHP variable

Return Value

array The cloned variable represented in an array

protected array castObject(Stub $stub, bool $isNested)

Casts an object to an array representation.

Parameters

Stub $stub The Stub for the casted object
bool $isNested True if the object is nested in the dumped structure

Return Value

array The object casted as array

protected array castResource(Stub $stub, bool $isNested)

Casts a resource to an array representation.

Parameters

Stub $stub The Stub for the casted resource
bool $isNested True if the object is nested in the dumped structure

Return Value

array The resource casted as array

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/VarDumper/Cloner/AbstractCloner.html