Replaces all occurrences of $old in this string with $new

@param static|string $old
@param static|string $new
@return static
@throws InvalidArgumentException
@throws TypeError
542120
public function replace($old, $new): self
    {
        Assert::typeOf(['string', __CLASS__], $old, $new);

        return new static(str_replace((string) $old, (string) $new, $this->data), $this->encoding);
    }
1347198
public static function move($oldName, $newName, $context = null)
    {
        return self::rename($oldName, $newName, $context);
    }
1060678
public function recursivelyFindAndReplaceExecutableCode($old)
    {
        if ($this->isArray($old)) {
            return collect($old)->map(function ($item) {
                return $this->recursivelyFindAndReplaceExecutableCode($item);
            });
        }

        $new = $this->replaceContents($old);

        if ($new !== $old) {
            $this->replaced++;
        }

        return $new;
    }
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;
	}
1362288
public function handle($old, $new)
    {
        if ( ! $this->canHandle($old) || ! $this->canHandle($new)) {
            return null;
        }

        if (((string) $new->getReturnType())) {
            return false;
        }

        if (((string) $new->getReturnType()) == ((string) $old->getReturnType())) {
            return false;
        }

        $this->lastException = new FailedConstraint(
            sprintf(
                '%s::%s() return type "%s" were removed',
                $old->getAttribute('parent')->namespacedName,
                $old->name,
                $old->getReturnType(),
                $new->getReturnType()
            )
        );

        return true;
    }
312067
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;
        }

        $oldStripped = $this->cursor->filter($old, static::REPLACEMENT_CHAR);
        $newStripped = $this->cursor->filter($new, static::REPLACEMENT_CHAR);
        $lastReal = 0;

        for ($i = 0; $i < $oldLen && $i < $newLen; $i++) {
            if (mb_substr($old, $i, 1) !== mb_substr($new, $i, 1)) {
                if (($i > 0)
                    && ((mb_substr($oldStripped, $i - 1, 1) === static::REPLACEMENT_CHAR)
                        || (mb_substr($newStripped, $i - 1, 1) === static::REPLACEMENT_CHAR)
                    )
                ) {
                    return $lastReal > 0 ? $lastReal + 1 : 0;
                }
                return $i;
            } elseif (mb_substr($oldStripped, $i, 1) !== static::REPLACEMENT_CHAR) {
                $lastReal = $i;
            }
        }
        if ($i < $oldLen || $i < $newLen) {
            return $i;
        }
        return -1;
    }
648402
public function replace($newNode, $clone = true)
    {
        if ($this->node->parentNode === null) {
            throw new LogicException('Can not replace element without parent node');
        }

        if ($newNode instanceof Element) {
            $newNode = $newNode->getNode();
        }

        if (!$newNode instanceof DOMNode) {
            throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s or DOMNode, %s given', __METHOD__, __CLASS__, (is_object($newNode) ? get_class($newNode) : gettype($newNode))));
        }

        if ($clone) {
            $newNode = $newNode->cloneNode(true);
        }

        if ($newNode->ownerDocument === null || !$this->getDocument()->is($newNode->ownerDocument)) {
            $newNode = $this->node->ownerDocument->importNode($newNode, true);
        }

        $node = $this->node->parentNode->replaceChild($newNode, $this->node);

        return new Element($node);
    }
213223
public function rename($oldName, $newName) {
        if (false === @ftp_rename($this->getConnection(), $oldName, $newName)) {
            throw $this->newFTPException(sprintf("rename %s into %s failed", $oldName, $newName));
        }
        return $this;
    }
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);
    }
379508
public static function formatGroupClass($new, $old)
    {
        if (isset($new['class'])) {
            $classes = trim(trim(array_get($old, 'class')).' '.trim(array_get($new, 'class')));

            return implode(' ', array_unique(explode(' ', $classes)));
        }

        return array_get($old, 'class');
    }
452086
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(Arr::get($old, 'where', []), Arr::get($new, 'where', []));

        if (isset($old['as'])) {
            $new['as'] = trim($old['as'].'.'.Arr::get($new, 'as', ''), '.');
        }

        return array_merge_recursive(array_except($old, ['namespace', 'prefix', 'where', 'as']), $new);
    }
789080
public static function rename(String $oldName, String $newName) : Bool
    {
        $oldName = Info::rpath($oldName);

        if( ! file_exists($oldName) )
        {
            throw new Exception\FileNotFoundException(NULL, $oldName);
        }

        return rename($oldName, $newName);
    }
1196096
public function renameColumn($old, $new, $table = null)
    {
        return $this->db->alterTable($this->getTable($table))
                        ->renameColumn($old, $new)
                        ->execute();
    }
94402
public function move(string $old, string $new){
    if (
      !empty($old) &&
      !empty($new) &&
      ($old = $this->checkFilePath($old)) &&
      ftp_rename($this->cn, $old, $new)
    ){
      return true;
    }
    return false;
  }
1105726
public function rename($new, $old = null)
    {
        $this->arguments[] = 'rename';
        if ($old) {
            $this->arguments[] = $old;
        }
        $this->arguments[] = $new;
        return $this;
    }
466084
protected function getTableMigrationNewDatabase($output, $new, $old)
    {
        if (empty($new['database'])) {
            return $output;
        }
        if ($this->neq($new, $old, ['database', 'default_character_set_name'])) {
            $output[] = $this->getAlterDatabaseCharset($new['database']['default_character_set_name']);
        }
        if ($this->neq($new, $old, ['database', 'default_collation_name'])) {
            $output[] = $this->getAlterDatabaseCollate($new['database']['default_collation_name']);
        }

        return $output;
    }
650964
protected function addChangeMethod($output, $new, $old): array
    {
        $output[] = $this->ind . 'public function change()';
        $output[] = $this->ind . '{';

        if (!empty($this->options['foreign_keys'])) {
            $output[] = $this->getSetUniqueChecks(0);
            $output[] = $this->getSetForeignKeyCheck(0);
        }

        $output = $this->getTableMigrationNewDatabase($output, $new, $old);
        $output = $this->getTableMigrationTables($output, $new, $old);

        if (!empty($this->options['foreign_keys'])) {
            $output[] = $this->getSetForeignKeyCheck(1);
            $output[] = $this->getSetUniqueChecks(1);
        }

        $output[] = $this->ind . '}';

        return $output;
    }