Skip to content

Commit

Permalink
Avoid choose_handler error on PHP7.3. (#46)
Browse files Browse the repository at this point in the history
- クラス書き換えがうまくいっていなかった部分で書き換えを行う
  • Loading branch information
fumikito committed Jun 30, 2023
2 parents 99a0f20 + 5a0e276 commit d7440eb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/wordpress.yml
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions bin/patcher.php
@@ -0,0 +1,22 @@
<?php
/**
* Add patch for php-scoper.
*/

foreach ( [
'vendor/google/auth/src/HttpHandler/HttpHandlerFactory.php' => 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;
}
8 changes: 6 additions & 2 deletions composer.json
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions phpcs.ruleset.xml
Expand Up @@ -34,6 +34,7 @@
<exclude-pattern>*/scoper.inc.php</exclude-pattern>
<exclude-pattern>*.js</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/vendor-prefixed/*</exclude-pattern>
<exclude-pattern>*/wp/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/.github/*</exclude-pattern>
Expand Down

0 comments on commit d7440eb

Please sign in to comment.