Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
[scoped] remove class alias (fixed in next php-scoper)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 9, 2021
1 parent dac8622 commit c01edcd
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/easy-coding-standard/scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,26 @@
// unprefix polyfill functions
// @see https://github.com/humbug/php-scoper/issues/440#issuecomment-795160132
function (string $filePath, string $prefix, string $content): string {
if (Strings::match($filePath, POLYFILL_FILE_NAME_REGEX)) {
$content = Strings::replace($content, '#namespace '. $prefix . ';#', '');

// add missing use statements prefixes
// @see https://github.com/symplify/easy-coding-standard/commit/5c11eca46fbe341ac30d0d5da2c51e1596950299#diff-87ecc51ebcf33f4c2699c08f35403560ad1ea98d22771df83a29d00dc5f53a1cR12
return Strings::replace($content, '#use Symfony\\\\Polyfill#', 'use ' . $prefix . ' Symfony\Polyfill');
if (! Strings::match($filePath, POLYFILL_FILE_NAME_REGEX)) {
return $content;
}

return $content;
$content = Strings::replace($content, '#namespace ' . $prefix . ';#', '');

// add missing use statements prefixes
// @see https://github.com/symplify/easy-coding-standard/commit/5c11eca46fbe341ac30d0d5da2c51e1596950299#diff-87ecc51ebcf33f4c2699c08f35403560ad1ea98d22771df83a29d00dc5f53a1cR12
return Strings::replace($content, '#use Symfony\\\\Polyfill#', 'use ' . $prefix . ' Symfony\Polyfill');
},
// remove namespace frompoly fill stubs
function (string $filePath, string $prefix, string $content): string {
if (Strings::match($filePath, POLYFILL_STUBS_NAME_REGEX)) {
return Strings::replace($content, '#namespace '. $prefix . ';#', '');
if (! Strings::match($filePath, POLYFILL_STUBS_NAME_REGEX)) {
return $content;
}
return $content;
// remove alias to class have origina PHP names - fix in
$content = Strings::replace($content, '#\\\\class_alias(.*?);#', '');

return Strings::replace($content, '#namespace ' . $prefix . ';#', '');
},

function (string $filePath, string $prefix, string $content): string {
Expand Down

0 comments on commit c01edcd

Please sign in to comment.