Fr3nch13/CakePHP Utilities

MergeVariablesTrait

Provides features for merging object properties recursively with parent classes.

Table of Contents

Methods

_mergeProperty()  : void
Merge a single property with the values declared in all parent classes.
_mergePropertyData()  : array<string|int, mixed>
Merge each of the keys in a property together.
_mergeVars()  : void
Merge the list of $properties with all parent classes of the current class.

Methods

_mergeProperty()

Merge a single property with the values declared in all parent classes.

protected _mergeProperty(string $property, array<string|int, string> $parentClasses, array<string, mixed> $options) : void
Parameters
$property : string

The name of the property being merged.

$parentClasses : array<string|int, string>

An array of classes you want to merge with.

$options : array<string, mixed>

Options for merging the property, see _mergeVars()

_mergePropertyData()

Merge each of the keys in a property together.

protected _mergePropertyData(array<string|int, mixed> $current, array<string|int, mixed> $parent, bool $isAssoc) : array<string|int, mixed>
Parameters
$current : array<string|int, mixed>

The current merged value.

$parent : array<string|int, mixed>

The parent class' value.

$isAssoc : bool

Whether the merging should be done in associative mode.

Return values
array<string|int, mixed>

The updated value.

_mergeVars()

Merge the list of $properties with all parent classes of the current class.

protected _mergeVars(array<string|int, string> $properties[, array<string, mixed> $options = [] ]) : void

Options:

  • associative - A list of properties that should be treated as associative arrays. Properties in this list will be passed through Hash::normalize() before merging.
Parameters
$properties : array<string|int, string>

An array of properties and the merge strategy for them.

$options : array<string, mixed> = []

The options to use when merging properties.


        
On this page

Search results