0 follower

Final Class Yiisoft\Config\Merger

InheritanceYiisoft\Config\Merger

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Config\Merger
merge() Merges two or more arrays into one recursively. Yiisoft\Config\Merger
reset() Yiisoft\Config\Merger

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\Config\ConfigPaths $configPaths, Yiisoft\Config\DataModifiers $dataModifiers )
$configPaths Yiisoft\Config\ConfigPaths

The config paths instance.

$dataModifiers Yiisoft\Config\DataModifiers

The data modifiers that affect merge process.

                public function __construct(
    private readonly ConfigPaths $configPaths,
    private readonly DataModifiers $dataModifiers,
) {
}

            
merge() public method

Merges two or more arrays into one recursively.

public array merge ( Yiisoft\Config\Context $context, array $arrayA, array $arrayB )
$context Yiisoft\Config\Context

Context containing the name of the file, package, group and environment.

$arrayA array

First array to merge.

$arrayB array

Second array to merge.

return array

The merged array.

throws ErrorException

If an error occurred during the merge.

                public function merge(Context $context, array $arrayA, array $arrayB): array
{
    $recursionDepth = $this->dataModifiers->getRecursionDepth($context->originalGroup());
    $isReverseMerge = $this->dataModifiers->isReverseMergeGroup($context->originalGroup());
    if ($isReverseMerge) {
        $arrayB = $this->prepareArrayForReverse($context, [], $arrayB, $recursionDepth !== false);
    }
    return $this->performMerge(
        $context,
        [],
        $isReverseMerge ? $arrayB : $arrayA,
        $isReverseMerge ? $arrayA : $arrayB,
        $recursionDepth,
        $isReverseMerge,
    );
}

            
reset() public method

public void reset ( )

                public function reset(): void
{
    $this->cacheKeys = [];
}