mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 11:50:51 +00:00
return
This commit is contained in:
parent
145096b208
commit
39c7ae65e9
21
scoper.php
21
scoper.php
|
@ -144,6 +144,27 @@ return [
|
|||
return Strings::replace($content, '#' . $prefix . '\\\\Composer\\\\#', 'Composer\\');
|
||||
},
|
||||
|
||||
// fixes https://github.com/rectorphp/rector/issues/6007 - this is fixed in scoper 0.17.2+
|
||||
function (string $filePath, string $prefix, string $content): string {
|
||||
if (! \str_contains($filePath, 'vendor/')) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// @see https://regex101.com/r/lBV8IO/2
|
||||
$fqcnReservedPattern = sprintf('#(\\\\)?%s\\\\(parent|self|static)#m', $prefix);
|
||||
$matches = Strings::matchAll($content, $fqcnReservedPattern);
|
||||
|
||||
if ($matches === []) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
foreach ($matches as $match) {
|
||||
$content = str_replace($match[0], $match[2], $content);
|
||||
}
|
||||
|
||||
return $content;
|
||||
},
|
||||
|
||||
// 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
|
||||
|
|
Loading…
Reference in New Issue
Block a user