From 91988188f780a5b587a0982fd9404b229494f0e4 Mon Sep 17 00:00:00 2001 From: Jip Date: Thu, 28 Oct 2021 17:22:26 +0200 Subject: [PATCH] PHP 8.0 | Update OAuth PHP Scoper config PHP Scoper is prefixing the attribute use statement that will need to be pulled into the TheLeague OAuth Client implenetation of the JSONSerializableInterface. See https://github.com/thephpleague/oauth2-client/pull/919 This change removes the prefix from the use statement. PHP Scoper was updated to 0.15.0 during investigation of this issue and was not worked as desired on the newer version. Bumping the version in this commit seemed out of scope. This is addressed in the following ticket: https://github.com/humbug/php-scoper/issues/539 --- config/php-scoper/oauth2-client.inc.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/config/php-scoper/oauth2-client.inc.php b/config/php-scoper/oauth2-client.inc.php index 0f893a08edf..915e546d949 100644 --- a/config/php-scoper/oauth2-client.inc.php +++ b/config/php-scoper/oauth2-client.inc.php @@ -36,6 +36,25 @@ * @return string The modified content. */ function( $file_path, $prefix, $content ) { + /* + * Restore incorrect PHP 8.0+ attribute use statement prefix. + * + * This implementation is not ideal, php-scoper should be improved to deal with this. + * php-scoper is not yet PHP 8.0 compatible in run-time either, not expecting a fix soon. + * + * This was tested with php-scoper 0.15.0 - but not committed as it seemed out of scope. + * + * This will become relevant when the following PR is merged and the dependency is upgraded + * to the released version. + * + * https://github.com/thephpleague/oauth2-client/pull/919 + */ + $content = str_replace( + sprintf( 'use %s\ReturnTypeWillChange;', $prefix ), + 'use ReturnTypeWillChange;', + $content + ); + // 26 is the length of the GrantFactory.php file path. if ( substr( $file_path, -26 ) !== 'src/Grant/GrantFactory.php' ) { return $content;