Skip to content

Commit

Permalink
add patcher for PEAR and prefix all pear libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Feb 26, 2024
1 parent d9baabb commit 36d8400
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions resources/core-scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
'prefix' => 'Matomo\\Dependencies',
'finders' => $finders,
'patchers' => [
// patchers for PEAR (pear libraries do not use psr autoloading and put everything in a global namespace,
// so we can't automatically rename references to PEAR libraries)
static function (string $filePath, string $prefix, string $content) use ($isRenamingReferences): string {
if (!$isRenamingReferences) {
return $content;
}

$content = preg_replace('/([^\\\\A-Za-z0-9_])\\\\PEAR_/', '$1\\Matomo\\Dependencies\\PEAR_', $content);
return $content;
},

// patchers for twig
static function (string $filePath, string $prefix, string $content) use ($isRenamingReferences): string {
// correct use statements in generated templates
Expand Down
4 changes: 4 additions & 0 deletions src/Prefixers/CorePrefixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class CorePrefixer extends Prefixer
'php-di/php-di',
'geoip2/geoip2',
'pear/pear_exception',
'pear/archive_tar',
'pear/console_getopt',
'pear/pear-core-minimal',
'pear/pear_exception',
];

const DEPENDENCIES_TO_IGNORE = [
Expand Down

0 comments on commit 36d8400

Please sign in to comment.