[Scoper] Fixes #6010 Remove namespaced on polyfill symfony Stubs (#6011)

This commit is contained in:
Abdul Malik Ikhsan 2021-03-30 01:48:45 +07:00 committed by GitHub
parent 903e98e28e
commit c060086f69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,6 +84,18 @@ return [
return $content;
},
// fixes https://github.com/rectorphp/rector/issues/6010
function (string $filePath, string $prefix, string $content): string {
// @see https://regex101.com/r/bA1nQa/1
if (! Strings::match($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