Skip to content

Commit

Permalink
correctly rename strings of prefixed PEAR classes in pear-core-minimal
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Jun 11, 2024
1 parent 51ac8d4 commit 3c96ad0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions resources/core-scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
->exclude('build')
->exclude('vendor/prefixed')
->exclude('vendor/composer')
->exclude('vendor/phpmailer') // wordfence creates a false positive here
->exclude('node_modules')
->exclude('tmp')
->exclude('@types')
Expand Down Expand Up @@ -93,6 +94,21 @@ static function (string $filePath, string $prefix, string $content) use ($isRena
$content = preg_replace('/([^\\\\A-Za-z0-9_])\\\\?Archive_Tar(?!\\/)/', '$1\\Matomo\\Dependencies\\Archive_Tar', $content);
$content = preg_replace('/([^\\\\A-Za-z0-9_])\\\\?Console_Getopt(?!\\/)/', '$1\\Matomo\\Dependencies\\Console_Getopt', $content);
$content = preg_replace('/([^\\\\A-Za-z0-9_])\\\\?OS_Guess(?!\\/)/', '$1\\Matomo\\Dependencies\\OS_Guess', $content);

return $content;
},

static function (string $filePath, string $prefix, string $content) use ($isRenamingReferences): string {
if ($isRenamingReferences) {
return $content;
}

if (strpos($filePath, 'pear/pear-core-minimal') !== false) {
$content = str_replace("'PEAR_Error'", "'\\\\Matomo\\\\Dependencies\\\\PEAR_Error'", $content);
$content = str_replace("'PEAR_ErrorStack'", "'\\\\Matomo\\\\Dependencies\\\\PEAR_ErrorStack'", $content);
$content = str_replace("'System'", "'\\\\Matomo\\\\Dependencies\\\\System'", $content);
}

return $content;
},

Expand Down

0 comments on commit 3c96ad0

Please sign in to comment.