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

Commit

Permalink
[scoper] unprefixed polyfill functions
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 8, 2021
1 parent 696399c commit a58433f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/easy-coding-standard/scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
use Nette\Utils\DateTime;
use Nette\Utils\Strings;

$polyfillFileInfos = (new \Symfony\Component\Finder\Finder())->files()
->in(__DIR__ . '/vendor/symfony/polyfill-*')
->name('*.php')
->getIterator();

$polyfillFilePaths = [];
foreach ($polyfillFileInfos as $polyfillFileInfo) {
$polyfillFilePaths[] = $polyfillFileInfo->getPathname();
}

$dateTime = DateTime::from('now');
$timestamp = $dateTime->format('Ymd');

Expand All @@ -28,7 +18,7 @@
// these paths are relative to this file location, so it should be in the root directory
'vendor/symfony/deprecation-contracts/function.php',
// for package versions - https://github.com/symplify/easy-coding-standard-prefixed/runs/2176047833
] + $polyfillFilePaths,
],

'whitelist' => [
// needed for autoload, that is not prefixed, since it's in bin/* file
Expand All @@ -40,6 +30,16 @@
'Composer\InstalledVersions',
],
'patchers' => [
// 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, '#vendor/symfony/polyfill-(.*)/bootstrap(.*?).php')) {
return Strings::replace($content, 'namespace '. $prefix . ';', '');
}

return $content;
},

function (string $filePath, string $prefix, string $content): string {
if (! Strings::endsWith($filePath, 'vendor/jean85/pretty-package-versions/src/PrettyVersions.php')) {
return $content;
Expand Down

1 comment on commit a58433f

@TomasVotruba
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.