Skip to content

Commit

Permalink
[Scoper] Added namespaces to exclude (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
lulco authored Aug 20, 2022
1 parent ba982e6 commit 2502342
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,23 @@
return [
'prefix' => 'RevealPrefix' . $timestamp,
// @see https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#exposed-symbols - regex format
'exclude-namespaces' => ['#^PHPStan#', '#^Reveal#', '#^PhpParser#'],
'exclude-namespaces' => [
'#^PHPStan#',
'#^Reveal#',
'#^PhpParser#',
'#^Symplify\\\\Astral#',
'#^Symplify\\\\SmartFileSystem#',
'#^Symplify\\\\PackageBuilder#',
],
'expose-functions' => ['u', 'b', 's', 'trigger_deprecation'],
'patchers' => [
// fixes https://github.com/rectorphp/rector/issues/7017 - still needed 2022-06
function (string $filePath, string $prefix, string $content): string {
if (str_ends_with($filePath, 'vendor/symfony/string/ByteString.php')) {
if (\str_ends_with($filePath, 'vendor/symfony/string/ByteString.php')) {
return Strings::replace($content, '#' . $prefix . '\\\\\\\\1_\\\\\\\\2#', '\\\\1_\\\\2');
}

if (str_ends_with($filePath, 'vendor/symfony/string/AbstractUnicodeString.php')) {
if (\str_ends_with($filePath, 'vendor/symfony/string/AbstractUnicodeString.php')) {
return Strings::replace($content, '#' . $prefix . '\\\\\\\\1_\\\\\\\\2#', '\\\\1_\\\\2');
}

Expand All @@ -44,5 +51,14 @@ function (string $filePath, string $prefix, string $content): string {

return Strings::replace($content, '#services\->load\(\'#', "services->load('" . $prefix . '\\');
},

// latte services
function (string $filePath, string $prefix, string $content): string {
if (! \str_ends_with($filePath, 'config.neon') && ! \str_ends_with($filePath, 'services.neon')) {
return $content;
}

return Strings::replace($content, '#- Latte\\\\#', "- $prefix\\Latte\\");
},
],
];

0 comments on commit 2502342

Please sign in to comment.