Skip to content

Commit

Permalink
Revert "[Scoper] Skip Prefix\Composer\ usage (#6293)" (#6294)
Browse files Browse the repository at this point in the history
This reverts commit e237ffb.
  • Loading branch information
samsonasik authored May 2, 2021
1 parent e237ffb commit 1070505
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,39 @@ function (string $filePath, string $prefix, string $content) use ($filePathsToRe
},

function (string $filePath, string $prefix, string $content): string {
if (! Strings::contains($content, $prefix . '\Composer\\')) {
if (! Strings::endsWith($filePath, 'vendor/composer/package-versions-deprecated/src/PackageVersions/Versions.php')) {
return $content;
}

// see https://regex101.com/r/v8zRMm/1
return Strings::replace(
$content, '
#' . $prefix . '\\\\Composer\\\\InstalledVersions#',
'Composer\InstalledVersions'
);
},

function (string $filePath, string $prefix, string $content): string {
if (! Strings::contains($content, $prefix . '\Composer\Plugin')) {
return $content;
}

return Strings::replace(
$content, '
#' . $prefix . '\\\\Composer\\\\Plugin#',
'Composer\Plugin'
);
},

function (string $filePath, string $prefix, string $content): string {
if (! Strings::contains($content, $prefix . '\Composer\EventDispatcher')) {
return $content;
}

return Strings::replace(
$content, '
#' . $prefix . '\\\\Composer\\\\#',
'Composer\\'
#' . $prefix . '\\\\Composer\\\\EventDispatcher#',
'Composer\EventDispatcher'
);
},

Expand Down

0 comments on commit 1070505

Please sign in to comment.