Skip to content

Commit 49725cd

Browse files
authored
Merge pull request #5494 from LibreSign/fix/patcher-for-mpdf
fix: patcher for mpdf
2 parents c0a3067 + e59f677 commit 49725cd

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
],
4242
"post-install-cmd": [
4343
"@composer bin all install --ansi",
44-
"php -d error_reporting=E_ALL\\&~E_DEPRECATED\\&~E_USER_DEPRECATED vendor-bin/php-scoper/vendor/humbug/php-scoper/bin/php-scoper add-prefix --force && > lib/Vendor/.gitkeep",
44+
"php -d error_reporting=E_ALL\\&~E_DEPRECATED\\&~E_USER_DEPRECATED vendor-bin/php-scoper/vendor/humbug/php-scoper/bin/php-scoper add-prefix --force && cp l10n/.gitkeep lib/Vendor/.gitkeep",
4545
"composer dump-autoload -o"
4646
],
4747
"post-update-cmd": [
48-
"php -d error_reporting=E_ALL\\&~E_DEPRECATED\\&~E_USER_DEPRECATED vendor-bin/php-scoper/vendor/humbug/php-scoper/bin/php-scoper add-prefix --force && > lib/Vendor/.gitkeep",
48+
"php -d error_reporting=E_ALL\\&~E_DEPRECATED\\&~E_USER_DEPRECATED vendor-bin/php-scoper/vendor/humbug/php-scoper/bin/php-scoper add-prefix --force && cp l10n/.gitkeep lib/Vendor/.gitkeep",
4949
"composer dump-autoload"
5050
],
5151
"test:unit": "vendor/bin/phpunit -c tests/php/phpunit.xml --no-coverage --colors=always --fail-on-warning --fail-on-risky --display-deprecations --display-phpunit-deprecations",

scoper.inc.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,22 @@ static function (string $filePath, string $prefix, string $content): string {
5454
if (!str_contains($filePath, 'mpdf/mpdf')) {
5555
return $content;
5656
}
57+
$searchReplacePairs = [
58+
'\\\\Mpdf\\\\' => '\\\\' . $prefix . '\\\\Mpdf\\\\',
59+
"'Mpdf\\\\" => "'" . $prefix . '\\\\Mpdf\\\\',
60+
"'\\\\Mpdf\\\\" => "'\\\\" . $prefix . '\\\\Mpdf\\\\',
61+
'@var \\\\Mpdf\\\\' => '@var \\\\' . $prefix . '\\\\Mpdf\\\\',
62+
'use Mpdf\\\\' => 'use ' . $prefix . '\\\\Mpdf\\\\',
63+
'namespace Mpdf\\\\' => 'namespace ' . $prefix . '\\\\Mpdf\\\\',
64+
];
65+
foreach ($searchReplacePairs as $search => $replace) {
66+
$content = str_replace($search, $replace, $content);
67+
}
5768

5869
$file = basename($filePath);
5970

6071
return match ($file) {
61-
'Tag.php' => str_replace("'Mpdf\\\\Tag\\\\'", "'$prefix\\\\Mpdf\\\\Tag\\\\'", $content),
6272
'FpdiTrait.php' => str_replace('use \\setasign\\', "use \\$prefix\\setasign\\", $content),
63-
'Svg.php' => preg_replace("/$prefix\\\\(<svg[^>]*>)/", '$1', $content),
6473
'Mpdf.php' => str_replace(["$prefix\\\\r\\\\n", "$prefix\\\\</t"], ['\\r\\n', '</t'], $content),
6574
'functions.php' => str_replace("namespace $prefix;", '', $content),
6675
'LoggerAwareInterface.php',

0 commit comments

Comments
 (0)