Skip to content

Commit

Permalink
[scoper] fix preg_replace buggy prefixing
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Feb 22, 2022
1 parent 99c4608 commit 81152d3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ function (string $filePath, string $prefix, string $content): string {
'PHPUnit\Framework\Constraint\IsEqual'
),

// fixes https://github.com/rectorphp/rector/issues/7017
function (string $filePath, string $prefix, string $content): string {
if (!str_ends_with($filePath, 'vendor/symfony/string/ByteString.php')) {
return $content;
}

return Strings::replace(
$content,
'#' . $prefix . '\\\\_1\\\\_2',
'\1_\2_'
);
},

// unprefixed ContainerConfigurator
function (string $filePath, string $prefix, string $content): string {
// keep vendor prefixed the prefixed file loading; not part of public API
Expand Down

1 comment on commit 81152d3

@TomasVotruba
Copy link
Member Author

@TomasVotruba TomasVotruba commented on 81152d3 Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.