@@ -36,8 +36,7 @@ potentially very difficult to debug due to dissimilar or unsupported package ver
3636- [ Configuration] ( #configuration )
3737 - [ Finders and paths] ( #finders-and-paths )
3838 - [ Patchers] ( #patchers )
39- - [ Global Namespace Whitelisting] ( #global-namespace-whitelisting )
40- - [ Whitelist] ( #whitelist )
39+ - [ Whitelist] [ whitelist ]
4140- [ Building A Scoped PHAR] ( #building-a-scoped-phar )
4241 - [ Step 1: Configure build location and prep vendors] ( #step-1-configure-build-location-and-prep-vendors )
4342 - [ Step 2: Run PHP-Scoper] ( #step-2-run-php-scoper )
@@ -46,6 +45,8 @@ potentially very difficult to debug due to dissimilar or unsupported package ver
4645 - [ PSR-0 support] ( #psr-0-support )
4746 - [ String values] ( #string-values )
4847 - [ Native functions and constants shadowing] ( #native-functions-shadowing )
48+ - [ Composer] ( #composer )
49+ - [ Composer Plugins] ( #composer-plugins )
4950- [ Contributing] ( #contributing )
5051- [ Credits] ( #credits )
5152
@@ -244,35 +245,6 @@ return [
244245];
245246```
246247
247- ### Global Namespace Whitelisting
248-
249- By default, PHP-Scoper only scopes (or prefixes) code where the namespace is
250- non-global. In other words, non-namespaced code is not scoped. This leaves the
251- majority of classes, functions and constants in PHP, and most extensions,
252- untouched.
253-
254- This is not necessarily a desirable outcome for vendor dependencies which are
255- also not namespaced. To ensure they are isolated, you can configure PHP-Scoper to
256- allow their prefixing from ` scoper.inc.php ` using basic strings or callables:
257-
258- ``` php
259- <?php declare(strict_types=1);
260-
261- // scoper.inc.php
262-
263- return [
264- 'global_namespace_whitelist' => [
265- 'AppKernel',
266- function ($className) {
267- return 'PHPUnit' === substr($className, 0, 6);
268- },
269- ],
270- ];
271- ```
272-
273- In this example, we're ensuring that the ` AppKernal ` class, and any
274- non-namespaced PHPUnit packages are prefixed.
275-
276248
277249### Whitelist
278250
@@ -473,6 +445,23 @@ is_array([]);
473445The situation is exactly the same for constants.
474446
475447
448+ ### Composer
449+
450+ PHP-Scoper does not support prefixing the dumped Composer autoloader and autoloading files. This is why you have to
451+ manually dump the autoloader again after prefixing an application.
452+
453+
454+ ### Composer Plugins
455+
456+ Composer plugins are not supported. The issue is that for [ whitelisting symbols] ( #whitelist ) PHP-Scoper relies on the
457+ fact that you should load the ` vendor/scoper-autoload.php ` file instead of ` vendor/autoload.php ` to trigger the loading
458+ of the right classes with their class aliases. However Composer does not do that and as a result interfaces such as
459+ ` Composer\Plugin\Capability\Capable ` are prefixed but the alias is not registered.
460+
461+ This cannot be changed easily so for now when you are using an isolated version of Composer, you will need to use the
462+ ` --no-plugins ` option.
463+
464+
476465## Contributing
477466
478467[ Contribution Guide] ( CONTRIBUTING.md )
@@ -493,3 +482,4 @@ now been moved under the
493482[ releases ] : https://github.com/humbug/php-scoper/releases
494483[ symfony_finder ] : https://symfony.com/doc/current/components/finder.html
495484[ releases ] : https://github.com/humbug/php-scoper/releases
485+ [ whitelist ] : #whitelist
0 commit comments