@@ -36,8 +36,7 @@ potentially very difficult to debug due to dissimilar or unsupported package ver
36
36
- [ Configuration] ( #configuration )
37
37
- [ Finders and paths] ( #finders-and-paths )
38
38
- [ Patchers] ( #patchers )
39
- - [ Global Namespace Whitelisting] ( #global-namespace-whitelisting )
40
- - [ Whitelist] ( #whitelist )
39
+ - [ Whitelist] [ whitelist ]
41
40
- [ Building A Scoped PHAR] ( #building-a-scoped-phar )
42
41
- [ Step 1: Configure build location and prep vendors] ( #step-1-configure-build-location-and-prep-vendors )
43
42
- [ 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
46
45
- [ PSR-0 support] ( #psr-0-support )
47
46
- [ String values] ( #string-values )
48
47
- [ Native functions and constants shadowing] ( #native-functions-shadowing )
48
+ - [ Composer] ( #composer )
49
+ - [ Composer Plugins] ( #composer-plugins )
49
50
- [ Contributing] ( #contributing )
50
51
- [ Credits] ( #credits )
51
52
@@ -244,35 +245,6 @@ return [
244
245
];
245
246
```
246
247
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
-
276
248
277
249
### Whitelist
278
250
@@ -473,6 +445,23 @@ is_array([]);
473
445
The situation is exactly the same for constants.
474
446
475
447
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
+
476
465
## Contributing
477
466
478
467
[ Contribution Guide] ( CONTRIBUTING.md )
@@ -493,3 +482,4 @@ now been moved under the
493
482
[ releases ] : https://github.com/humbug/php-scoper/releases
494
483
[ symfony_finder ] : https://symfony.com/doc/current/components/finder.html
495
484
[ releases ] : https://github.com/humbug/php-scoper/releases
485
+ [ whitelist ] : #whitelist
0 commit comments