@param string|array $toReplace
@param string|array $replacement
@param string       $fullPath

@return string
357548
protected static function stringReplaceIgnoringStreamWrapper($toReplace, $replacement, string $fullPath):string
    {
        if (strpos($fullPath, '://') !== false) {
            list($streamWrapper, $path) = explode('://', $fullPath, 2);

            return $streamWrapper . '://' . ltrim(str_replace(
                $toReplace,
                $replacement,
                $path
            ), DIRECTORY_SEPARATOR);
        } else {
            return str_replace($toReplace, $replacement, $fullPath);
        }
    }
656640
protected String renderLink(String fullPath) {
		renderedLinks.add(new RenderedLink(fullPath, bundler.getConfig().isDebugModeOn()));
		return fullPath;
	}
1367056
public function queueForReplacement($originalUrl, $expandedUrl, $trackingUrl, $shortenedTrackingUrl)
    {
        $this->replacementUrls[$originalUrl][] = array(
            self::URL_TYPE_EXPANDED => $expandedUrl,
            self::URL_TYPE_TRACKED => $trackingUrl,
            self::URL_TYPE_SHORTENED_TRACKED => $shortenedTrackingUrl
        );
    }
1140630
public function replacePath($value, $replace)
    {
        $this->data['path'] = str_replace($value, $replace, $this->data['path']);
        return $this;
    }
714703
public function expandPath($path, $clean = false) {
        $todo = explode('/', $path);
        $fullPath = [];

        foreach ($todo as $dir) {
            if ($dir == '..') {
                $element = array_pop($fullPath);
                if (is_null($element)) {
                    return false;
                }
            } else {
                if ($clean) {
                    $dir = $this->normalizeString($dir);
                }
                array_push($fullPath, $dir);
            }
        }
        return implode('/', $fullPath);
    }
974557
public function replaceEntityRepositoriesNamespace(string $replacement, string $filePath): self
    {
        $this->findReplace(
            AbstractGenerator::FIND_ENTITY_REPOSITORIES_NAMESPACE,
            $this->namespaceHelper->tidy($replacement),
            $filePath
        );

        return $this;
    }
1035975
private function ensureValidImportAndReplace (array $matches, callable $contentReplaceFunction) : string
    {
        $path = $matches["path"];
        $openingQuote = substr($matches["path"], 0, 1);
        $closingQuote = \substr($matches["path"], -1);
        $usedQuotes = "";

        // check if quoted and whether valid quoted
        if ($openingQuote === "'" || $openingQuote === '"')
        {
            if ($openingQuote !== $closingQuote)
            {
                // looks like invalid CSS, as there is a leading quote, but no closing one, so bail
                return $matches[0];
            }

            // strip quotes from path
            $path = \substr($path, 1, -1);
            $usedQuotes = $openingQuote;
        }

        $path = $contentReplaceFunction($path);
        return "url({$usedQuotes}{$path}{$usedQuotes})";
    }
871733
public static function replaceStrict(array $source, array ...$replace) {

        $replacements = [];

        foreach ($replace as $items) {
            $replacements[] = array_intersect_key($items, $source);
        }

        return array_merge($source, ...$replacements);

    }
1315407
public function searchAndReplace()
	{
		$this->search();

		$this->replacement = new Replacement($this->formatted, $this->str);

		$this->replacement->replace();
		
		return $this->replacement->getStr();
	}
699206
public function replaceAll($path, array $replacements) {
        foreach ($replacements as $key => $value) {
            $path = $this->replace($path, $key, $value);
        }

        return $path;
    }
181264
protected function createDirectoryIfNotExists(string $fullPath)
    {
        $dirName = dirname($fullPath);
        if (!@is_dir($dirName)) {
            @mkdir($dirName, 0777, true);
        }
    }
1255522
private function buildNodeTemplate(array $replacements, bool $isActive) : string
    {
        $node = str_replace(self::PLACEHOLDERS_NODE, $replacements, $this->node());

        if (!$isActive) {
            $node = str_replace(' active', '', $node);
        }

        return $node;
    }
1084181
public static function replaceFilePlaceholders($filePath, $variables, $destPath = null, $pending = '$')
    {
        if (!$destPath) {
            $destPath = $filePath;
        }
        if (is_dir($filePath)) {
            $files = scandir($filePath);
            foreach ($files as $file) {
                if ($file != "." && $file != "..") {
                    Utils::replaceFilePlaceholders("$filePath" . DIRECTORY_SEPARATOR . "$file", $variables, $destPath,
                        $pending);
                }
            }
        } elseif (file_exists($filePath)) {
            $template = file_get_contents($filePath);
            $templateData = Utils::fillTemplate($variables, $template, $pending);
            $folder = dirname($destPath);
            if (!file_exists($folder)) {
                mkdir($folder, 0755, true);
            }
            file_put_contents($destPath, $templateData);
        }
    }
932293
public function replaceRootContentSet(ContentSet $contentToReplace, ContentSet $newContentSet, $checkContentsLinkToParent = true)
    {
        $checkContentsLinkToParent = (true === $checkContentsLinkToParent);
        $contentIsLinked = true === $checkContentsLinkToParent ? $this->isLinkedToHisParentBy($contentToReplace) : true;

        if (true === $contentIsLinked) {
            if (null !== $this->getContentSet()) {
                $this->getContentSet()->replaceChildBy($contentToReplace, $newContentSet);
            }
        }

        return $newContentSet;
    }
561750
public static function mb_substr_replace($original, $replacement, $position, $length)
    {
        $startString = mb_substr($original, 0, $position, "UTF-8");
        $endString = mb_substr($original, $position + $length, mb_strlen($original), "UTF-8");

        return $startString . $replacement . $endString;
    }
532752
public function moveTo(string $fullPath) : IFile
    {
        if ($this->moveCallback) {
            return call_user_func($this->moveCallback, $fullPath);
        }

        return $this->file;
    }
311719
public function replace($search, $replacement, &$count = null)
    {
        return $this->cloneInstance(
            function (StringObject $new) use ($search, $replacement, &$count) {
                $new->string = str_replace($search, $replacement, $new->string, $count);
            }
        );
    }