Merge condition instances.

@param  ConditionInterface $old
@param  ConditionInterface $new
@return ConditionInterface
346622
public function mergeConditions( ConditionInterface $old, ConditionInterface $new ) {
		if ( $old instanceof UrlCondition && $new instanceof UrlCondition ) {
			return $old->concatenate( $new->getUrl(), $new->getUrlWhere() );
		}

		return $this->makeFromArrayOfConditions( [$old, $new] );
	}
18733
public function _mergeWithPrevious($previous)
    {
        if (!$previous)
        {
            return $this;
        }
        if ($previous instanceof DeleteOperation)
        {
            return new SetOperation($this->objects);
        }
        if ($previous instanceof SetOperation)
        {
            $oldValue = $previous->getValue();
            $result = $this->_apply($oldValue, null, null);

            return new SetOperation($result);
        }
        if ($previous instanceof AddUniqueOperation)
        {
            $oldList = $previous->getValue();
            $result = $this->_apply($oldList, null, null);

            return new AddUniqueOperation($result);
        }
        throw new AVException('Operation is invalid after previous operation.');
    }
801412
public function override($new)
    {
        $old = iterator_to_array($this->collection);
        $new = $new instanceof Traversable ? iterator_to_array($this->collection) : $new;

        if (!is_array($new)) {
            throw new Exception("Argument must be an array or instance of Traversable");
        }

        // Create restore point
        $this->overrides[] = $old;

        // Override collection with new data
        $merged = $this->merge($old, $new);
        $this->apply($merged, $purge = false);

        return $this;
    }
775007
public static function registerCustomView(string $old, string $new): void
    {
        if (Str::contains($old, self::NAMESPACE_SEPARATOR) && Str::contains($new, self::NAMESPACE_SEPARATOR)) {
            self::$replacements[$old] = $new;
        } else {
            throw new InvalidArgumentException();
        }
    }
530890
public function renameTable($old, $new)
    {
        $this->append(sprintf('RENAME TABLE %s TO %s ', $this->quote($old), $this->quote($new)));
        return $this;
    }
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
        );
    }
321415
public function handle($old, $new)
    {
        if ( ! $this->canHandle($old) || ! $this->canHandle($new)) {
            return null;
        }

        if ($this->equals($old, $new)) {
            return false;
        }

        $this->lastException = new FailedConstraint(
            sprintf(
                '%s() body changed',
                $new->name
            )
        );

        return true;
    }
577589
public function createFromIlluminate(IlluminateRequest $old)
    {
        $new = new static(
            $old->query->all(), $old->request->all(), $old->attributes->all(),
            $old->cookies->all(), $old->files->all(), $old->server->all(), $old->content
        );

        if ($session = $old->getSession()) {
            $new->setLaravelSession($old->getSession());
        }

        $new->setRouteResolver($old->getRouteResolver());
        $new->setUserResolver($old->getUserResolver());

        return $new;
    }
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;
    }
772774
public function update($old, $new): bool
    {
        if ($this->hasNot($old)) {
            return false;
        }

        $this->set($old, $new);

        return true;
    }
362823
protected function mergeConfigs(array $old, array $new) : array
    {
      foreach ($new as $key => $val) {
        if (!array_key_exists($key, $old) || !is_array($old[$key]) || !is_array($val)) {
          $old[$key] = $val;
          continue;
        }

        if (is_int($key)) {
          $old[] = $val;
          continue;
        }

        $old[$key] = $this->mergeConfigs($old[$key], $val);
      }

      return $old;
    }
624707
private function buildDiff(Text $old, Text $new, $diffTable) {
        $inserted = 0;
        $deleted = 0;
        $diff = [];

        $row = count($this->old);
        $col = count($this->new);
        while ($row > 0 || $col > 0) {
            if ($row > 0 && $col > 0 && $this->old[$row - 1] === $this->new[$col - 1]) {
                $diff[] = new UnmodifiedEntry($old, $row - 1, $col - 1);
                $row--;
                $col--;
            } elseif ($col > 0 && $diffTable[$row][$col] === $diffTable[$row][$col - 1]) {
                $diff[] = new InsertedEntry($new, $col - 1);
                $inserted++;
                $col--;
            } else {
                $diff[] = new DeletedEntry($old, $row - 1);
                $deleted++;
                $row--;
            }
        }

        return [array_reverse($diff), $inserted, $deleted];
    }
1157539
public function update( $new_instance, $old_instance ) 
    {   
        $this->form->updater->set_new_instance( $new_instance );
        return $this->form->updater->update( $old_instance );
    }
328564
private function renameTable($old, $new) {
        $renameSql = 'alter table '.
            $this->prefixTable($old).
            ' rename to '.
            $this->prefixTable($new);
        $this->queryDefine($renameSql);
    }
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;
	}
1336466
public function _mergeWithPrevious($previous)
    {
        if (!$previous)
        {
            return $this;
        }
        if ($previous instanceof DeleteOperation)
        {
            return $previous;
        }
        if ($previous instanceof SetOperation)
        {
            return new SetOperation($this->_apply($previous->getValue(), $this->objects, null));
        }
        if ($previous instanceof RemoveOperation)
        {
            $oldList = $previous->getValue();

            return new RemoveOperation(array_merge((array) $oldList, (array) $this->objects));
        }
        throw new AVException('Operation is invalid after previous operation.');
    }
782859
protected function getNewFeedItems(array $new, array $old)
    {
        $map = array();
        $getKey = function($item) {
            return $item->getPermalink();
        };
        $logger = $this->getLogger();
        foreach ($new as $item) {
            $key = $getKey($item);
            $logger->debug('New: ' . $key);
            $map[$key] = $item;
        }
        foreach ($old as $item) {
            $key = $getKey($item);
            $logger->debug('Old: ' . $key);
            unset($map[$key]);
        }
        $logger->debug('Diff: ' . implode(' ', array_keys($map)));
        return array_values($map);
    }