Skip to content

Commit

Permalink
php-scoper & PSR-0 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed May 14, 2021
1 parent 46c5129 commit 61d7997
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ gulp.task(
)
.pipe(
replace(
"'Google\\\\' => \n",
"'Sgdg\\\\Vendor\\\\Google\\\\' => \n"
/'(.*)\\\\' => \n/g,
"'Sgdg\\\\Vendor\\\\$1\\\\' => \n"
)
)
).pipe( gulp.dest( 'dist/bundled/vendor/composer/' ) );
Expand Down
3 changes: 3 additions & 0 deletions scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
static function ( $file_path, $prefix, $contents ) {
$regex_prefix = mb_ereg_replace( '\\\\', '\\\\\\\\', $prefix );
$replace_prefix = mb_ereg_replace( '\\\\', '\\\\', $prefix );
if ( mb_ereg_match( preg_quote( __DIR__, '/' ) . '\\/vendor\\/composer\\/ClassLoader.php', $file_path ) ) {
$contents = mb_ereg_replace( "// PSR-0 lookup\n", "// PSR-0 lookup\n \$scoperPrefix = 'Sgdg\\\\Vendor\\\\';\n if (substr(\$class, 0, strlen(\$scoperPrefix)) == \$scoperPrefix) {\n \$class = substr(\$class, strlen(\$scoperPrefix));\n \$first = \$class[0];\n }\n", $contents );
}
if ( mb_ereg_match( preg_quote( __DIR__, '/' ) . '\\/vendor\\/composer\\/autoload_real.php', $file_path ) ) {
$contents = mb_ereg_replace( "if \\('Composer\\\\\\\\Autoload\\\\\\\\ClassLoader' === \\\$class\\)", "if ('{$replace_prefix}\\\\Composer\\\\Autoload\\\\ClassLoader' === \$class)", $contents );
$contents = mb_ereg_replace( "\\\\spl_autoload_unregister\\(array\\('ComposerAutoloaderInit", "\\spl_autoload_unregister(array('{$replace_prefix}\\\\ComposerAutoloaderInit", $contents );
Expand Down

0 comments on commit 61d7997

Please sign in to comment.