src/ThreeWayMerge.php
public function performMerge(array $ancestor, array $local, array $remote)
    {
        // Returning a new Array for now. Can return the modified ancestor as well.
        $merged = [];
        foreach ($ancestor as $key => $value) {
            // Checks if the value contains an array itself.
            if (is_array($value) && array_key_exists($key, $local) && array_key_exists($key, $remote)) {
                $merged[$key] = $this->performMerge(
                    $value,
                    $local[$key],
                    $remote[$key]
                );
            } else {
                if (array_key_exists($key, $local) && array_key_exists($key, $remote)) {
                    $merged[$key] = $this->merge(
                        $ancestor[$key],
                        $local[$key],
                        $remote[$key],
                        $key
                    );
                } elseif (array_key_exists($key, $local)) {
                    if ($ancestor[$key] != $local[$key]) {
                        throw new ConflictException("A conflict has occured");
                    }
                } elseif (array_key_exists($key, $remote)) {
                    if ($ancestor[$key] != $remote[$key]) {
                        throw new ConflictException("A conflict has occured");
                    }
                } else {
                    unset($merged[$key]);
                }
            }
        }
        return $merged;
    }
public function performMerge(array $ancestor, array $local, array $remote)
    {
        // Returning a new Array for now. Can return the modified ancestor as well.
        $merged = [];
        foreach ($ancestor as $key => $value) {
            // Checks if the value contains an array itself.
            if (is_array($value) && array_key_exists($key, $local) && array_key_exists($key, $remote)) {
                $merged[$key] = $this->performMerge(
                    $value,
                    $local[$key],
                    $remote[$key]
                );
            } else {
                if (array_key_exists($key, $local) && array_key_exists($key, $remote)) {
                    $merged[$key] = $this->merge(
                        $ancestor[$key],
                        $local[$key],
                        $remote[$key],
                        $key
                    );
                } elseif (array_key_exists($key, $local)) {
                    if ($ancestor[$key] != $local[$key]) {
                        throw new ConflictException("A conflict has occured");
                    }
                } elseif (array_key_exists($key, $remote)) {
                    if ($ancestor[$key] != $remote[$key]) {
                        throw new ConflictException("A conflict has occured");
                    }
                } else {
                    unset($merged[$key]);
                }
            }
        }
        return $merged;
    }
Perform merge on associative array

@param array $ancestor
@param array $local
@param array $remote

@return array