Skip to content

Commit 1bd0ab0

Browse files
committed
fix: patchers for mpdf
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 5c8eebc commit 1bd0ab0

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

scoper.inc.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,26 @@ static function (string $filePath, string $prefix, string $content): string {
4949

5050
return $content;
5151
},
52+
// patchers for Mpdf
53+
static function (string $filePath, string $prefix, string $content): string {
54+
if (!str_contains($filePath, 'mpdf/mpdf')) {
55+
return $content;
56+
}
57+
58+
$file = basename($filePath);
59+
60+
return match ($file) {
61+
'Tag.php' => str_replace("'Mpdf\\\\Tag\\\\'", "'$prefix\\\\Mpdf\\\\Tag\\\\'", $content),
62+
'FpdiTrait.php' => str_replace('use \\setasign\\', "use \\$prefix\\setasign\\", $content),
63+
'Svg.php' => preg_replace("/$prefix\\\\(<svg[^>]*>)/", '$1', $content),
64+
'Mpdf.php' => str_replace(["$prefix\\\\r\\\\n", "$prefix\\\\</t"], ['\\r\\n', '</t'], $content),
65+
'functions.php' => str_replace("namespace $prefix;", '', $content),
66+
'LoggerAwareInterface.php',
67+
'LoggerAwareTrait.php',
68+
'MpdfPsrLogAwareTrait.php',
69+
'PsrLogAwareTrait.php' => str_replace("\\$prefix\\Psr\\Log\\LoggerInterface", '\\Psr\\Log\\LoggerInterface', $content),
70+
default => $content,
71+
};
72+
},
5273
],
5374
];

0 commit comments

Comments
 (0)