2023-02-05 23:33:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/** @var iterable<SplFileInfo> $files */
|
2024-08-03 16:11:29 +00:00
|
|
|
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__));
|
2023-02-05 23:33:16 +00:00
|
|
|
foreach ($files as $file) {
|
|
|
|
if ($file->getExtension() === 'php' && $file->getPathname() !== __FILE__) {
|
|
|
|
$fileContents = file_get_contents($file->getPathname());
|
|
|
|
if ($fileContents === false) {
|
2024-08-03 16:11:29 +00:00
|
|
|
throw new RuntimeException('file_get_contents() failed: ' . $file->getPathname());
|
2023-02-05 23:33:16 +00:00
|
|
|
}
|
|
|
|
$patternToReplacementMap = [
|
|
|
|
'~ function assertMatchesRegularExpression\(\$pattern, \$string, \$message = \'\'\)~' => ' function _assertMatchesRegularExpression(string $pattern, string $string, string $message = \'\')',
|
|
|
|
];
|
|
|
|
$updatedFileContents = preg_replace(
|
|
|
|
array_keys($patternToReplacementMap),
|
|
|
|
array_values($patternToReplacementMap),
|
|
|
|
$fileContents
|
|
|
|
);
|
|
|
|
if (file_put_contents($file->getPathname(), $updatedFileContents) === false) {
|
2024-08-03 16:11:29 +00:00
|
|
|
throw new RuntimeException('file_put_contents() failed: ' . $file->getPathname());
|
2023-02-05 23:33:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|