From d9baabb6f67f38d7291c081c50ff3b89cb096eba Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sun, 25 Feb 2024 14:43:27 -0800 Subject: [PATCH 1/2] prefix pear/pear_exception --- src/Prefixers/CorePrefixer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Prefixers/CorePrefixer.php b/src/Prefixers/CorePrefixer.php index b8e3fa0..f5beb43 100644 --- a/src/Prefixers/CorePrefixer.php +++ b/src/Prefixers/CorePrefixer.php @@ -25,6 +25,7 @@ class CorePrefixer extends Prefixer 'symfony/console', // new version now depends on service-contracts which symfony/monolog-bridge also depends on 'php-di/php-di', 'geoip2/geoip2', + 'pear/pear_exception', ]; const DEPENDENCIES_TO_IGNORE = [ From 36d840095f1f046765026b25b2e31925244ba362 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Sun, 25 Feb 2024 16:09:23 -0800 Subject: [PATCH 2/2] add patcher for PEAR and prefix all pear libraries --- resources/core-scoper.inc.php | 11 +++++++++++ src/Prefixers/CorePrefixer.php | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/resources/core-scoper.inc.php b/resources/core-scoper.inc.php index fef3f3a..2cc4162 100644 --- a/resources/core-scoper.inc.php +++ b/resources/core-scoper.inc.php @@ -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 diff --git a/src/Prefixers/CorePrefixer.php b/src/Prefixers/CorePrefixer.php index f5beb43..592626d 100644 --- a/src/Prefixers/CorePrefixer.php +++ b/src/Prefixers/CorePrefixer.php @@ -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 = [