str_replace

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             $className = $this->converter->getTrimmedTestClassName($test); // pest-added

            $testCase->setAttribute('class', $className); // pest-changed

            $testCase->setAttribute('classname', str_replace('\\', '.', $className)); // pest-changed

        }



        $this->currentTestCase = $testCase;
<?php             $filter = sprintf(

                '/%s/i',

                str_replace(

                    '/',

                    '\\/',

                    $filter

                )

            );

        }
<?php             if (count($matches) > 1) {

                if (str_contains($description, 'with '.$matches[0].' /')) {

                    $description = str_replace('with '.$matches[0].' /', '', $description);

                } else {

                    $description = str_replace('with '.$matches[0], '', $description);

                }
<?php                 if (str_contains($description, 'with '.$matches[0].' /')) {

                    $description = str_replace('with '.$matches[0].' /', '', $description);

                } else {

                    $description = str_replace('with '.$matches[0], '', $description);

                }

            }
<?php         assert($method->description !== null);

        $methodDescription = str_replace('*/', '{@*}', $method->description);



        $annotations[] = "@testdox $methodDescription";
<?php             $filename = (string) preg_replace_callback('~^(?P<drive>[a-z]+:\\\)~i', static fn (array $match): string => strtolower($match['drive']), $filename);

        }



        $filename = str_replace('\\\\', '\\', addslashes((string) realpath($filename)));

        $rootPath = TestSuite::getInstance()->rootPath;

        $relativePath = str_replace($rootPath.DIRECTORY_SEPARATOR, '', $filename);
<?php         $filename = str_replace('\\\\', '\\', addslashes((string) realpath($filename)));

        $rootPath = TestSuite::getInstance()->rootPath;

        $relativePath = str_replace($rootPath.DIRECTORY_SEPARATOR, '', $filename);



        $relativePath = ltrim($relativePath, DIRECTORY_SEPARATOR);
<?php         $relativePath = dirname(ucfirst($relativePath)).DIRECTORY_SEPARATOR.$basename;



        $relativePath = str_replace(DIRECTORY_SEPARATOR, '\\', $relativePath);




        $relativePath = (string) preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $relativePath);
<?php         $relativePath = (string) preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $relativePath);


        $relativePath = str_replace(array_map(fn (string $quote): string => sprintf('\\%s', $quote), ['\'', '"']), '', $relativePath);


        $relativePath = (string) preg_replace('/[^A-Za-z0-9\\\\]/', '', $relativePath);
<?php         if ($this->isInternalError($this->buffer)) {

            $type = 'ERROR';

            $this->buffer = str_replace(

                sprintf('An error occurred inside PHPUnit.%s%sMessage:  ', PHP_EOL, PHP_EOL), '', $this->buffer,

            );

        }



        $this->buffer = trim($this->buffer);
<?php     private function toRelativePath(string $path): string

    {


        return str_replace("$this->rootPath".DIRECTORY_SEPARATOR, '', $path);

    }
<?php     private function escapeServiceMessage(string $text): string

    {

        return str_replace(

            ['|', "'", "\n", "\r", ']', '['],

            ['||', "|'", '|n', '|r', '|]', '|['],

            $text

        );

    }



    public static function setFlowId(int $flowId): void
<?php             throw ShouldNotHappen::fromMessage('Snapshot file could not be read.');

        }



        $snapshot = str_replace(dirname($this->testsPath).'/', '', $snapshotFilename);



        return [$snapshot, $contents];

    }
<?php         file_put_contents($snapshotFilename, $snapshot);



        return str_replace(dirname($this->testsPath).'/', '', $snapshotFilename);

    }
<?php     private function getSnapshotFilename(): string

    {

        $relativePath = str_replace($this->testsPath, '', TestSuite::getInstance()->getFilename());




        $relativePath = substr($relativePath, 0, (int) strrpos($relativePath, '.'));