src/Merging/MergingTrait.php
protected function arrayMerge(array $target, array $source)
    {
        foreach ($source as $key => $value) {
            if ($value instanceof MergingInterface) {
                $value = $value->toArray();
            }
            if (isset($target[$key]) || array_key_exists($key, $target)) {
                if (is_int($key)) {
                    $target[] = $value;
                } elseif (is_array($value) && is_array($target[$key])) {
                    $target[$key] = $this->arrayMerge($target[$key], $value);
                } else {
                    $target[$key] = $value;
                }
            } else {
                $target[$key] = $value;
            }
        }

        return $target;
    }
protected function arrayMerge(array $target, array $source)
    {
        foreach ($source as $key => $value) {
            if ($value instanceof MergingInterface) {
                $value = $value->toArray();
            }
            if (isset($target[$key]) || array_key_exists($key, $target)) {
                if (is_int($key)) {
                    $target[] = $value;
                } elseif (is_array($value) && is_array($target[$key])) {
                    $target[$key] = $this->arrayMerge($target[$key], $value);
                } else {
                    $target[$key] = $value;
                }
            } else {
                $target[$key] = $value;
            }
        }

        return $target;
    }
protected function arrayMerge ( array $ target , array $ source ) { foreach ( $ source as $ key => $ value ) { if ( $ value instanceof MergingInterface ) { $ value = $ value -> toArray ( ) ; } if ( isset ( $ target [ $ key ] ) || array_key_exists ( $ key , $ target ) ) { if ( is_int ( $ key ) ) { $ target [ ] = $ value ; } elseif ( is_array ( $ value ) && is_array ( $ target [ $ key ] ) ) { $ target [ $ key ] = $ this -> arrayMerge ( $ target [ $ key ] , $ value ) ; } else { $ target [ $ key ] = $ value ; } } else { $ target [ $ key ] = $ value ; } } return $ target ; }
Merge data from two arrays.

@param array $target The target array
@param array $source The sourse array

@return array The result of merging
Merge data from two arrays .