Skip to content

Commit

Permalink
Add scoping config for paragonie
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed May 30, 2018
1 parent 09eb629 commit b6458f0
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,42 @@ function (string $filePath, string $prefix, string $contents): string {
$contents
);
},
function (string $filePath, string $prefix, string $contents): string {
if ('vendor/paragonie/sodium_compat/autoload.php' !== $filePath) {
return $contents;
}

return preg_replace(
'/\'sodiumCompatAutoloader\'/',
sprintf(
'\'%s\\%s\'',
$prefix,
'sodiumCompatAutoloader'
),
preg_replace(
'/\$namespace = \'ParagonIE_Sodium_\';/',
sprintf(
'$namespace = \'%s\\ParagonIE_Sodium_\';',
$prefix
),
$contents
)
);
},
function (string $filePath, string $prefix, string $contents): string {
if ('vendor/paragonie/sodium_compat/lib/php72compat.php' !== $filePath) {
return $contents;
}

return preg_replace(
'/\\\\define\\("SODIUM_{\\$constant}", \\\\constant\\("ParagonIE_Sodium_Compat::{\\$constant}"\\)\\);/',
sprintf(
'\define("SODIUM_{$constant}", \constant("%s\\ParagonIE_Sodium_Compat::{$constant}"));',
$prefix
),
$contents
);
},
],
'whitelist' => [
\Composer\Autoload\ClassLoader::class,
Expand Down

0 comments on commit b6458f0

Please sign in to comment.