Skip to content
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

Imposter plugin doesn't change namespaces correctly #15

Open
dingo-d opened this issue Mar 12, 2021 · 4 comments
Open

Imposter plugin doesn't change namespaces correctly #15

dingo-d opened this issue Mar 12, 2021 · 4 comments

Comments

@dingo-d
Copy link

dingo-d commented Mar 12, 2021

In my project, I'm using the imposter plugin to avoid any conflicts in my project in case I have a plugin that is using different versions of some packages that my project is using.

But for some reason, it only covers these packages and files

Generating optimized autoload files


Running Imposter...
======================
Loading package information from /Users/denis.zoljom/Sites/infinum/myproject/wp-content/themes/myproject/composer.json
 - 1/16: Transforming /Users/denis.zoljom/Sites/infinum/myproject/wp-content/themes/myproject/vendor/a5hleyrich/wp-queue/src/functions.php
 - 2/16: Transforming /Users/denis.zoljom/Sites/infinum/myproject/wp-content/themes/myproject/vendor/nesbot/carbon/src/
 - 3/16: Transforming /Users/denis.zoljom/Sites/infinum/myproject/wp-content/themes/myproject/vendor/kylekatarnls/update-helper/src/
 - 4/16: Transforming /Users/denis.zoljom/Sites/infinum/myproject/wp-content/themes/myproject/vendor/symfony/translation/
 - 5/16: Transforming /Users/denis.zoljom/Sites/infinum/myproject/wp-content/themes/myproject/vendor/symfony/polyfill-mbstring/
 - 6/16: Transforming /Users/denis.zoljom/Sites/infinum/myproject/wp-content/themes/myproject/vendor/symfony/polyfill-mbstring/bootstrap.php
 - 7/16: Transforming /Users/denis.zoljom/Sites/infinum/myproject/wp-content/themes/myproject/vendor/symfony/translation-contracts/

It picks up the dependencies correctly, but from the wp-queue, only the functions.php namespace gets changed. In other classes it remains the same, so now the functions.php file looks like

<?php

use MyProjectVendor\WP_Queue\Queue;
use MyProjectVendor\WP_Queue\QueueManager;

if ( ! function_exists( 'wp_queue' ) ) {

And I get the errors because the Queue.php still has the namespace namespace WP_Queue; and not MyProjectVendor\WP_Queue\Queue.

Any ideas why? It should pick up the namespaces from the autoload directive in the composer.json 🤷🏼‍♂️

Love the library btw! Works like a charm locally, can't wait to test it out on our staging site 🙂

@szepeviktor
Copy link
Contributor

PHP-Scoper may be a superior namespace changer.
humbug/php-scoper#303

@dingo-d
Copy link
Author

dingo-d commented Mar 17, 2021

For scoper I think I'd need to use https://github.com/bamarni/composer-bin-plugin plugin, plus they say that:

Keep in mind however that this library is not designed to be extended.

Which is a bit worrying :S

@szepeviktor
Copy link
Contributor

szepeviktor commented Mar 17, 2021

bin-plugin is really called PHIVE.

phive update humbug/php-scoper --force-accept-unsigned

There is a GitHub Action for PHIVE.

@tangrufus
Copy link

PHP-Scoper may be a superior namespace changer.

Agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants