Switch position between two images.

@param integer $new
@param integer $old
@return boolean
966216
public function callbackChangeSortIndex($new, $old)
    {
        // get old position
        $newPos = (new Query)->select([$this->sortIndexFieldName])->from($this->refTableName)->where([$this->imageIdFieldName => $new['originalImageId']])->scalar();
        $oldPos = (new Query)->select([$this->sortIndexFieldName])->from($this->refTableName)->where([$this->imageIdFieldName => $old['originalImageId']])->scalar();
        
        // switch positions
        $changeNewPos = Yii::$app->db->createCommand()->update($this->refTableName, [$this->sortIndexFieldName => $oldPos], [
            $this->imageIdFieldName => $new['originalImageId'],
            $this->refFieldName => $this->itemId,
        ])->execute();
        
        $changeOldPos = Yii::$app->db->createCommand()->update($this->refTableName, [$this->sortIndexFieldName => $newPos], [
            $this->imageIdFieldName => $old['originalImageId'],
            $this->refFieldName => $this->itemId,
        ])->execute();
        
        return true;
    }
652425
public function mergeConditionAttribute( $old, $new ) {
		try {
			$condition = $this->condition_factory->merge( $old, $new );
		} catch ( ConfigurationException $e ) {
			throw new ConfigurationException( 'Route condition is not a valid route string or condition.' );
		}

		return $condition;
	}
854433
private function isExtensionChangedAndIsChangeAllowed($oldName, $newName)
    {
        $user = $this->getUser();
        if ($this->users()->hasRole($user['id'], 'root') || $this->users()->hasRole($user['id'], 'admin')) {
            return true;
        }

        $oldFile = new \SplFileInfo($oldName);
        $newFile = new \SplFileInfo($newName);

        return $oldFile->getExtension() === $newFile->getExtension();
    }
575356
protected function mergeGroup(array $new, array $old)
    {
        $new['namespace'] = $this->formatNamespace($new, $old);

        $new['prefix'] = $this->formatPrefix($new, $old);

        foreach (['middleware', 'providers', 'scopes', 'before', 'after'] as $option) {
            $new[$option] = $this->formatArrayBasedOption($option, $new);
        }

        if (isset($new['domain'])) {
            unset($old['domain']);
        }

        if (isset($new['conditionalRequest'])) {
            unset($old['conditionalRequest']);
        }

        if (isset($new['uses'])) {
            $new['uses'] = $this->formatUses($new, $old);
        }

        $new['where'] = array_merge(array_get($old, 'where', []), array_get($new, 'where', []));

        return array_merge_recursive(array_except($old, ['namespace', 'prefix', 'where']), $new);
    }
739951
function createDifferenceObject( $old, $new )
    {
        $container = new eZDiffContainerObject();
        $container->setOldContent( $old );
        $container->setNewContent( $new );

        return $container;
    }
1320698
protected static function formatPrefix($new, $old)
    {
        $old = $old['prefix'] ?? null;

        return isset($new['prefix']) ? trim($old, '/').'/'.trim($new['prefix'], '/') : $old;
    }
1289236
public function lines(array $old, array $new)
    {
        $out = [];
        $newLen = count($new);
        $oldLen = count($old);
        for ($i = 0; $i < $oldLen || $i < $newLen; $i++) {
            if ($i >= $oldLen) {
                $out[] = ['col' => 0, 'str' => $new[$i]]; // write out the entire line for extra lines
            } elseif ($i >= $newLen) {
                $out[] = ['col' => 0, 'str' => '']; // clear the line if the new array has less entries than the old one
            } else {
                $col = $this->firstDifference($old[$i], $new[$i]);
                if ($col === -1) {
                    $out[] = null;
                } else {
                    $out[] = ['col' => $col, 'str' => mb_substr($new[$i], $col)];
                }
            }
        }
        return $out;
    }
1244634
protected function formatPrefix($new, $old)
    {
        if (isset($new['prefix'])) {
            return trim(Arr::get($old, 'prefix'), '/').'/'.trim($new['prefix'], '/');
        }

        return Arr::get($old, 'prefix', '');
    }
106403
private function diffRecords($old, $new)
	{
		$diff = Set::diff($old, $new);
		$formatted = array();

		foreach ($diff as $key => $value) {
			if (!isset($old[$key]) || !isset($new[$key])) {
				continue;
			}

			$formatted[$key] = array('old' => $old[$key], 'new' => $new[$key]);
		}

		return $formatted;
	}
530836
protected function merge(array $old, array $new)
    {
        foreach ($new as $key => $value) {
            if (isset($old[$key]) && is_array($old[$key]) && is_array($value)) {
                $old[$key] = $this->merge($old[$key], $value);
            } else {
                $old[$key] = $value;
            }
        }

        return $old;
    }
15099
public function firstDifference($old, $new)
    {
        // loop through old and new character by character and compare
        $oldLen = mb_strlen($old);
        $newLen = mb_strlen($new);

        if ($oldLen === 0) {
            return 0;
        }

        for ($i = 0; $i < $oldLen && $i < $newLen; $i++) {
            if (mb_substr($old, $i, 1) !== mb_substr($new, $i, 1)) {
                return $i;
            }
        }
        if ($i < $oldLen || $i < $newLen) {
            return $i;
        }
        return -1;
    }
93268
public static function mergeGroup($new, $old)
    {
        $new['namespace'] = static::formatUsesPrefix($new, $old);

        $new['prefix'] = static::formatGroupPrefix($new, $old);

        if (isset($new['domain'])) {
            unset($old['domain']);
        }

        $new['where'] = array_merge(
            isset($old['where']) ? $old['where'] : array(),
            isset($new['where']) ? $new['where'] : array()
        );

        if (isset($old['as'])) {
            $new['as'] = $old['as'] .(isset($new['as']) ? $new['as'] : '');
        }

        return array_merge_recursive(
            Arr::except($old, array('namespace', 'prefix', 'where', 'as')), $new
        );
    }
981620
protected function renameResult(array &$result, $old, $new)
    {

        // Check to see if the old item is there
        if (isset($result[$old])) {
            $result[$new] = $result[$old];
            unset($result[$old]);
        }
    }
1146402
function diff( $old, $new, $options = false )
    {
        $diff = new eZDiff();
        $diff->setDiffEngineType( $diff->engineType( 'container' ) );
        $diff->initDiffEngine();
        $diffObject = $diff->diff( $old, $new );
        return $diffObject;
    }
529573
public function mergeQueryAttribute( $old, $new ) {
		if ( $new === null ) {
			return $old;
		}

		if ( $old === null ) {
			return $new;
		}

		return function ( $query_vars ) use ( $old, $new ) {
			return call_user_func( $new, call_user_func( $old, $query_vars ) );
		};
	}
22250
public function move($oldName = false)
    {
        $this->arguments[] = '-M';
        if ($oldName) {
            $this->arguments[] = $oldName;
        }
        return $this;
    }
1006521
public function rename($old, $new)
    {
        return ($this->isConnected() === true) ? ftp_rename($this->getConnection(), $old, $new) : false;
    }