Skip to content

Commit

Permalink
Use different namespace for bundled vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Sep 24, 2021
1 parent 372c6cf commit 7b2c674
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

return [
// The prefix configuration. If a non null value will be used, a random prefix will be generated.
'prefix' => 'Phabel',
'prefix' => 'PhabelVendor',

// By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working
// directory. You can however define which files should be scoped by defining a collection of Finders in the
Expand Down
6 changes: 3 additions & 3 deletions tools/convertPhabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ function commit(string $message)

\file_put_contents(
'src/Composer/Plugin.php',
\str_replace('Phabel\\Symfony', 'Symfony', \file_get_contents('src/Composer/Plugin.php'))
\str_replace('PhabelVendor\\Symfony', 'Symfony', \file_get_contents('src/Composer/Plugin.php'))
);

\rename("vendor", "vendor-bundle");
r("find src -type f -exec sed 's/\\\\Phabel\\\\self/self/g' -i {} +");
r("find src -type f -exec sed 's/\\\\PhabelVendor\\\\self/self/g' -i {} +");

\file_put_contents('vendor-bundle/autoload.php', <<<PHP
<?php
Expand Down Expand Up @@ -178,7 +178,7 @@ function commit(string $message)

foreach (['psr-4', 'psr-0'] as $type) {
foreach ($package['autoload'][$type] ?? [] as $namespace => $path) {
$namespace = \str_starts_with($namespace, 'Symfony\\Polyfill') ? $namespace : "Phabel\\$namespace";
$namespace = \str_starts_with($namespace, 'Symfony\\Polyfill') ? $namespace : "PhabelVendor\\$namespace";
$paths = \is_string($path) ? [$path] : $path;
$paths = \array_map(fn ($path) => "vendor-bundle/$name/$path", $paths);
$json['autoload'][$type][$namespace] = $paths;
Expand Down

0 comments on commit 7b2c674

Please sign in to comment.