Merger

Deep-merges any variable.

This class is capable of merging together arrays and objects of the same class; all other types of variables are replaced. In addition this merger also supports the Replace annotation; this annotation can be placed on a property of a class and will indicate that that property must not be merged but replaced in its entirety.

package

Default

Methods

Initializes this merger with the annotation reader.

__construct(\Doctrine\Common\Annotations\AnnotationReader $reader) 

Arguments

$reader

\Doctrine\Common\Annotations\AnnotationReader

Deep-merges the source array over the destination array.

mergeArray(array $destinationArray, array $sourceArray) : array

Arguments

$destinationArray

array

$sourceArray

array

Response

array

Deep-merge the source object over the destination object and return the results.

mergeObject(object $destinationObject, object $sourceObject) : object

Arguments

$destinationObject

object

$sourceObject

object

Response

object

Merges the two properties over eachother.

mergeProperty(object $destinationObject, \ReflectionProperty $destinationProperty, object $sourceObject, \ReflectionProperty $sourceProperty, array<mixed,mixed> $defaultPropertyValues) : object

Arguments

$destinationObject

object

$destinationProperty

\ReflectionProperty

$sourceObject

object

$sourceProperty

\ReflectionProperty

$defaultPropertyValues

array<mixed,mixed>

Response

object

Merges the source on top of the destination and returns the result.

run(mixed $destination, mixed $source, mixed $default = null) : mixed

Arguments

$destination

mixed

The destination variable that will be overwritten with the data from the source.

$source

mixed

The source variable that should be merged over the destination.

$default

mixed

For normal variables; only replace that variable if the provided source does not equal this value.

Response

mixed

the merged variable.

Tests whether the value of the property should be replaced instead of merged by checking if it has the `Replace` annotation.

shouldPropertyBeReplaced(\ReflectionProperty $destinationProperty) : boolean

Arguments

$destinationProperty

\ReflectionProperty

Response

boolean

Properties

Object used to fetch all annotations for structural elements in a given piece of code

reader : \Doctrine\Common\Annotations\AnnotationReader
var

Object used to fetch all annotations for structural elements in a given piece of code

Type(s)

\Doctrine\Common\Annotations\AnnotationReader