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

Correclty prefix PHAR to avoid Composer\* namespaces conflicts with the application code #1708

Merged
merged 5 commits into from
Jul 30, 2022

Conversation

maks-rafalko
Copy link
Member

@maks-rafalko maks-rafalko commented Jul 28, 2022

Fixes #1677

Previously, we excluded the whole Composer\* namespace from prefixing, leaving it as is. And since Infection uses composer/xdebug-handler v2, it failed for all the projects that use v1 because of incompatible API.

This PR prefixes all the classes in Composer\*, except one.

I believe there is still a bug in Box/PHP-Scoper which I reported and had to workaround it humbug/php-scoper#678

With this workaround it works and the new e2e test that fails for master now works in this branch

* Remove `Composer\*` from `whitelist`
* Upgrade Box from 3.16.0 to 4.0.2
* Add static `prefix` - "Infected" for more convenient debugging and comparing files in different generated PHARs
* Add `exclude-classes` setting with `\Composer\InstalledVersions::class` file. This is needed because by default PHP-Scoper does not use previxed class name inside `autoload_classmap.php` file (is it a bug?):

  'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',

  so we don't need to prefix it in our code
@maks-rafalko maks-rafalko force-pushed the bugfix/prefix-composer-namespace branch from 5f9f43c to c76b1f0 Compare July 29, 2022 13:45
@maks-rafalko maks-rafalko added this to the next milestone Jul 29, 2022
@maks-rafalko maks-rafalko merged commit 83a2092 into master Jul 30, 2022
@maks-rafalko maks-rafalko deleted the bugfix/prefix-composer-namespace branch July 30, 2022 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Call to undefined method Composer\XdebugHandler\XdebugHandler::isXdebugActive
1 participant