Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Replace all occurrences of the search string with the replacement string
<?php str_replace(    array|string $search,    array|string $replace,    string|array $subject,    int &$count = null): string|array
<?php         $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);



        $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);

        $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);



        $namespacesFile = <<<EOF

<?php
<?php         }



        foreach ($ambiguousClasses as $className => $ambiguousPaths) {

            $cleanPath = str_replace(array('$vendorDir . \'', '$baseDir . \'', "',\n"), array($vendorPath, $basePath, ''), $classMap[$className]);



            $this->io->writeError(

                '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.
<?php                 return 99999;

            }



            $version = str_replace('-', '.', $bound->getVersion());

            $chunks = array_map('intval', explode('.', $version));



            return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2];
<?php                 return 99999;

            }



            $version = str_replace('-', '.', $bound->getVersion());

            $chunks = explode('.', $version);

            $chunks = array_slice($chunks, 0, 3);
<?php                     if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !Filesystem::isReadable($installPath.'/'.$path)) {


                        if ($package === $rootPackage) {

                            $targetDir = str_replace('\\<dirsep\\>', '[\\\\/]', preg_quote(str_replace(array('/', '\\'), '<dirsep>', $package->getTargetDir())));

                            $path = ltrim(Preg::replace('{^'.$targetDir.'}', '', ltrim($path, '\\/')), '\\/');

                        } else {
<?php                             function ($matches) use (&$updir) {

                                if (isset($matches[1])) {


                                    $updir = str_replace('\\.', '.', $matches[1]);

                                }



                                return '';
<?php                 if (false !== $namespaceLength) {

                    $namespace = substr($class, 0, $namespaceLength + 1);

                    $className = substr($class, $namespaceLength + 1);

                    $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)

                        . str_replace('_', DIRECTORY_SEPARATOR, $className);

                } else {

                    $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
<?php                     $namespace = substr($class, 0, $namespaceLength + 1);

                    $className = substr($class, $namespaceLength + 1);

                    $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)

                        . str_replace('_', DIRECTORY_SEPARATOR, $className);

                } else {

                    $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);

                }
<?php                     $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)

                        . str_replace('_', DIRECTORY_SEPARATOR, $className);

                } else {

                    $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);

                }

            } elseif ('psr-4' === $namespaceType) {

                $subNamespace = ('' !== $baseNamespace) ? substr($class, strlen($baseNamespace)) : $class;
<?php                 }

            } elseif ('psr-4' === $namespaceType) {

                $subNamespace = ('' !== $baseNamespace) ? substr($class, strlen($baseNamespace)) : $class;

                $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $subNamespace);

            } else {

                throw new \RuntimeException("namespaceType must be psr-0 or psr-4, $namespaceType given");

            }
<?php         for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {

            if (!empty($matches['ns'][$i])) {

                $namespace = str_replace(array(' ', "\t", "\r", "\n"), '', $matches['nsname'][$i]) . '\\';

            } else {

                $name = $matches['name'][$i];
<?php                 }

                if ($name[0] === ':') {


                    $name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);

                } elseif ($matches['type'][$i] === 'enum') {
<?php     {

        $io = $this->getIO();

        if (!$io->isDecorated()) {

            $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);

        }



        $io->write($line);
<?php             $json = $this->httpDownloader->get($protocol . '://repo.packagist.org/packages.json')->decodeJson();

            $hash = reset($json['provider-includes']);

            $hash = $hash['sha256'];

            $path = str_replace('%hash%', $hash, key($json['provider-includes']));

            $provider = $this->httpDownloader->get($protocol . '://repo.packagist.org/'.$path)->getBody();



            if (hash('sha256', $provider) !== $hash) {
<?php                 $part = Preg::replace('/[^a-z0-9]/i', ' ', $part);

                $part = ucwords($part);



                return str_replace(' ', '', $part);

            },

            explode('/', $packageName)

        );