src/Controller/Plugin/EntitySnapshot.php
protected function array_compare($array1, $array2, $maxDepth = 2)
    {
        $result = array();
        $arraykeys = array_unique(array_merge(array_keys($array1), array_keys($array2)));
        foreach ($arraykeys as $key) {
            if (!empty($key) && is_string($key) && $key[0] != "\0" && substr($key, 0, 8) != 'Doctrine') {
                if (array_key_exists($key, $array1) && !array_key_exists($key, $array2)) {
                    $result[$key] = array($array1[$key], '');
                }
                if (!array_key_exists($key, $array1) && array_key_exists($key, $array2)) {
                    $result[$key] = array('', $array2[$key]);
                }
                if (array_key_exists($key, $array1) && array_key_exists($key, $array2)) {
                    $subResult = null;
                    if (is_array($array1[$key]) && is_array($array2[$key])) {
                        if (0 < $maxDepth) {
                            $subResult = $this->array_compare($array1[$key], $array2[$key], $maxDepth - 1);
                        }
                    } elseif (is_object($array1[$key]) && is_object($array2[$key])) {
                        if (0 < $maxDepth) {
                            $hydrator = new EntityHydrator();
                            $a1 = $hydrator->extract($array1[$key]);
                            $a2 = $hydrator->extract($array2[$key]);
                            $subResult = $this->array_compare($a1, $a2, $maxDepth - 1);
                        }
                    } else {
                        if ($array1[$key] != $array2[$key]) {
                            $result[$key] = array( $array1[$key], $array2[$key]);
                        }
                    }
                    if (!empty($subResult)) {
                        foreach ($subResult as $subKey => $subValue) {
                            if (!empty($subKey) && is_string($subKey)) {
                                $result[$key . '.' . $subKey] = $subValue;
                            }
                        }
                    }
                }
            }
        }
        return $result;
    }
protected function array_compare($array1, $array2, $maxDepth = 2)
    {
        $result = array();
        $arraykeys = array_unique(array_merge(array_keys($array1), array_keys($array2)));
        foreach ($arraykeys as $key) {
            if (!empty($key) && is_string($key) && $key[0] != "\0" && substr($key, 0, 8) != 'Doctrine') {
                if (array_key_exists($key, $array1) && !array_key_exists($key, $array2)) {
                    $result[$key] = array($array1[$key], '');
                }
                if (!array_key_exists($key, $array1) && array_key_exists($key, $array2)) {
                    $result[$key] = array('', $array2[$key]);
                }
                if (array_key_exists($key, $array1) && array_key_exists($key, $array2)) {
                    $subResult = null;
                    if (is_array($array1[$key]) && is_array($array2[$key])) {
                        if (0 < $maxDepth) {
                            $subResult = $this->array_compare($array1[$key], $array2[$key], $maxDepth - 1);
                        }
                    } elseif (is_object($array1[$key]) && is_object($array2[$key])) {
                        if (0 < $maxDepth) {
                            $hydrator = new EntityHydrator();
                            $a1 = $hydrator->extract($array1[$key]);
                            $a2 = $hydrator->extract($array2[$key]);
                            $subResult = $this->array_compare($a1, $a2, $maxDepth - 1);
                        }
                    } else {
                        if ($array1[$key] != $array2[$key]) {
                            $result[$key] = array( $array1[$key], $array2[$key]);
                        }
                    }
                    if (!empty($subResult)) {
                        foreach ($subResult as $subKey => $subValue) {
                            if (!empty($subKey) && is_string($subKey)) {
                                $result[$key . '.' . $subKey] = $subValue;
                            }
                        }
                    }
                }
            }
        }
        return $result;
    }
makes a recursiv difference between array1 and array2
found commands like  'array_diff_assoc' wanting

the result looks like
key => array( old, new)
in subarrays it looks like
key.subkey = array( old, new)

@param $array1
@param $array2
@param int $maxDepth
@return array