[Scoper] Clean up scoper replace namespace stub (#2002)

This commit is contained in:
Abdul Malik Ikhsan 2022-04-03 07:52:39 +07:00 committed by GitHub
parent b00a4fcfc4
commit 02bb2edef3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,6 @@ use Rector\Compiler\PhpScoper\StaticEasyPrefixer;
use Rector\Compiler\Unprefixer;
use Rector\Compiler\ValueObject\ScoperOption;
use Rector\Core\Application\VersionResolver;
use Rector\Core\Util\StringUtils;
require_once __DIR__ . '/vendor/autoload.php';
@ -181,18 +180,6 @@ return [
return $content;
},
// fixes https://github.com/rectorphp/rector/issues/6010 + test case prefix
function (string $filePath, string $prefix, string $content): string {
// @see https://regex101.com/r/bA1nQa/1
if (! StringUtils::isMatch($filePath, '#vendor/symfony/polyfill-php\d{2}/Resources/stubs#')) {
return $content;
}
// @see https://regex101.com/r/x5Ukrx/1
$namespace = sprintf('#namespace %s;#m', $prefix);
return Strings::replace($content, $namespace);
},
// unprefix string classes, as they're string on purpose - they have to be checked in original form, not prefixed
function (string $filePath, string $prefix, string $content): string {
// skip vendor, expect rector packages