-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Scoper] Add polyfill support #440
Comments
I can confirm this. The problem is, how shall we approach this from within scoper? Quick workaround, add the following to your <?php
declare(strict_types=1);
use Isolated\Symfony\Component\Finder\Finder;
$symfonyPolyfills = (static function (): array {
$files = [];
foreach (
Finder::create()
->files()
->in(__DIR__ . '/vendor/symfony/polyfill-*')
->name('bootstrap.php') as $bootstrap
) {
$files[] = $bootstrap->getPathName();
}
return $files;
})();
return [
'whitelist' => [
'\Phpcq\PluginApi\*'
],
'files-whitelist' => $symfonyPolyfills,
]; |
Scratch my last comment, this results in the bootstrap files not being scoped but the classes implementing the polyfills are still scoped. So this is only half of the way to go. The scoper should emit classes/functions from whitelisted files "as is" while still changing scoped class usage within. |
In addition to workaround <?php
declare(strict_types=1);
use Isolated\Symfony\Component\Finder\Finder;
$polyfillsBootstrap = Finder::create()
->files()
->in(__DIR__ . '/vendor/symfony/polyfill-*')
->name('bootstrap.php');
return [
'whitelist' => [
'spaceonfire\\ApiDoc\\*',
'Symfony\\Polyfill\\*',
],
'files-whitelist' => array_map(
static function ($file) {
return $file->getPathName();
},
iterator_to_array($polyfillsBootstrap)
),
]; |
You are right, I also stumbled upon that one also. However, I feel we should address the root cause some how. |
I'm not too sure yet how this should be handled to be honest. A few ideas & notes:
|
Hi, This works just fine for me, however, I'm using php-scoper with #457 and #460 |
Fixed it within PHP-Scoper this way #481; thanks all for the leads. As we are all aware though, this is but a workaround. I am however not too sure how we could fix this yet |
We stumbled upon this as well, when we tried to box a laravel zero application under php 7.4 but the box.phar requires php 8 as the get_debug_type gets the global namespace and the polyfills are scoped far far away. |
Box has not been patched yet IIRC, but it shouldn’t be too hard to do so
…On Sun 15 Aug 2021 at 02:57, Joshua Behrens ***@***.***> wrote:
We stumbled upon this as well, when we tried to box a laravel zero
application under php 7.4 but the box.phar requires php 8 as the
get_debug_type gets the global namespace and the polyfills are scoped far
far away.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#440 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABHPVAPMRIRQKBAFKDTSVGLT44GIVANCNFSM4UCSSWCA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
So there is no pul request on box yet about it? 💭 |
A doc entry has been added since then: https://github.com/humbug/php-scoper/blob/main/docs/further-reading.md#polyfills and with the new upcoming release this should also be drastically simper. |
Bug report
Function aliasing described in docs seems not working with symfony polyfills functions. File scoped by namespace, but not
function_exist
check, also no aliases inscoper-autoload.php
.Can this caused because they all are oneliners? For example,
dd
function fromsymfony/var-dumper
prefixed and aliased as expected.Original vendor/symfony/polyfill-php80/bootstrap.php
Prefixed one
scoper.inc.php
The text was updated successfully, but these errors were encountered: