diff --git a/.github/workflows/wordpress.yml b/.github/workflows/wordpress.yml index c15e5a5..7089a1c 100644 --- a/.github/workflows/wordpress.yml +++ b/.github/workflows/wordpress.yml @@ -111,6 +111,7 @@ jobs: composer global require humbug/php-scoper ~/.composer/vendor/bin/php-scoper add-prefix --output-dir=vendor-prefixed --force composer dump-autoload --working-dir vendor-prefixed --classmap-authoritative + composer help-scoper - name: Clean Unwanted files run: bash bin/clean.sh diff --git a/bin/patcher.php b/bin/patcher.php new file mode 100644 index 0000000..c697684 --- /dev/null +++ b/bin/patcher.php @@ -0,0 +1,22 @@ + function ( string $content ) { + return preg_replace( '/(GuzzleHttp.*ClientInterface::)(MAJOR_VERSION|VERSION)/u', 'GaCommunicatorVendor\\\\' . '$1$2', $content ); + }, + 'vendor/guzzlehttp/guzzle/src/HandlerStack.php' => function ( string $content ) { + return preg_replace( '/(\$handler \?: )(choose_handler\(\))/u', '$1\\GaCommunicatorVendor\\GuzzleHttp\\\\$2', $content ); + }, +] as $path => $callable ) { + $path = dirname( __DIR__ ) . '/vendor-prefixed/' . ltrim( $path, '' ); + if ( ! file_exists( $path ) ) { + echo "File missing: {$path}" . PHP_EOL; + continue; + } + $content = file_get_contents( $path ); + file_put_contents( $path, $callable( $content ) ); + echo "File Updated: {$path}" . PHP_EOL; +} diff --git a/composer.json b/composer.json index f8d38ad..034a44d 100644 --- a/composer.json +++ b/composer.json @@ -16,9 +16,13 @@ "fix": "phpcbf --standard=phpcs.ruleset.xml $(find ./ -name '*.php')", "scoper": "php-scoper", "prefix": [ + "composer install --no-dev", "php-scoper add-prefix --output-dir=vendor-prefixed --force", - "composer dump-autoload --working-dir vendor-prefixed --classmap-authoritative" - ] + "composer dump-autoload --working-dir vendor-prefixed --classmap-authoritative", + "composer install", + "@help-scoper" + ], + "help-scoper": "php bin/patcher.php" }, "require": { "php": ">=7.2", diff --git a/phpcs.ruleset.xml b/phpcs.ruleset.xml index 21e4363..eaf34ef 100644 --- a/phpcs.ruleset.xml +++ b/phpcs.ruleset.xml @@ -34,6 +34,7 @@ */scoper.inc.php *.js */vendor/* + */vendor-prefixed/* */wp/* */tests/* */.github/*