Skip to content

Commit 3f8a6cb

Browse files
authored
Make prefixed applied for PHP-Scoper PHAR random (#119)
1 parent 079c5bc commit 3f8a6cb

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/box.json
77
/dist/
88
/build/
9+
/fixtures/set004/scoper.inc.php
910
/fixtures/*/vendor
1011
/vendor/
1112
/vendor-bin/box/vendor/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ build: bin/php-scoper src vendor vendor-bin/box/vendor scoper.inc.php
2929
composer install --no-dev --prefer-dist
3030

3131
# Prefixes the code to be bundled
32-
php -d zend.enable_gc=0 bin/php-scoper add-prefix --prefix=Isolated --output-dir=build/php-scoper --force
32+
php -d zend.enable_gc=0 bin/php-scoper add-prefix --output-dir=build/php-scoper --force
3333

3434
# Re-dump the loader to account for the prefixing
3535
# and optimize the loader

bin/php-scoper

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
namespace Humbug\PhpScoper;
1515

16+
use Isolated\Symfony\Component\Finder\Finder as IsolatedFinder;
1617
use RuntimeException;
18+
use Symfony\Component\Finder\Finder;
1719

1820
$findAutoload = function () {
1921
if (file_exists($autoload = __DIR__.'/../../../autoload.php')) {
@@ -39,8 +41,8 @@ $autoload = $findAutoload();
3941
require $autoload;
4042

4143
// Exposes the finder used by PHP-Scoper PHAR to allow its usage in the configuration file.
42-
if (false === class_exists('Isolated\Symfony\Component\Finder\Finder')) {
43-
class_alias('Symfony\Component\Finder\Finder', 'Isolated\Symfony\Component\Finder\Finder');
44+
if (false === class_exists(IsolatedFinder::class)) {
45+
class_alias(Finder::class, IsolatedFinder::class);
4446
}
4547

4648
$isVeryVerbose = array_reduce(

scoper.inc.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
'box.json.dist',
3737
]),
3838
],
39+
'whitelist' => [
40+
Finder::class,
41+
],
3942
'patchers' => [
4043
function (string $filePath, string $prefix, string $content): string {
4144
//

0 commit comments

Comments
 (0)