googleads / googleads-php-lib

Google Ad Manager SOAP API Client Library for PHP
Apache License 2.0
656 stars 769 forks source link

PHP 8.1 compatibility #759

Closed tobias-trozowski closed 2 years ago

tobias-trozowski commented 2 years ago

running tests with php 8.1 raised some deprecation messages (see below) which are fixed with this PR.

❯ docker run --rm -v $(pwd):$(pwd) -w $(pwd) -it php:8.1-gads vendor/bin/phpunit
PHPUnit 9.5.20 #StandWithUkraine

Warning:       No code coverage driver available

...................................
Deprecated: Return type of Google\AdsApi\Common\AdsSoapClient::__soapCall($function_name, $arguments, $options = null, $input_headers = null, &$output_headers = null) should either be compatible with SoapClient::__soapCall(string $name, array $args, ?array $options = null, $inputHeaders = null, &$outputHeaders = null): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php on line 107

Deprecated: Return type of Google\AdsApi\Common\AdsSoapClient::__doRequest($request, $location, $action, $version, $one_way = 0) should either be compatible with SoapClient::__doRequest(string $request, string $location, string $action, int $version, bool $oneWay = false): ?string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php on line 90
............................  63 / 507 ( 12%)
............................................................... 126 / 507 ( 24%)
............................................................... 189 / 507 ( 37%)
.......
Deprecated: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/AdWordsHeaderHandler.php on line 70

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/SoapLogMessageFormatter.php on line 187

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/SoapLogMessageFormatter.php on line 145

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/LogMessageScrubbers.php on line 91

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/SoapLogMessageFormatter.php on line 156
.
Deprecated: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/AdWordsHeaderHandler.php on line 70

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/SoapLogMessageFormatter.php on line 187

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/SoapLogMessageFormatter.php on line 145

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/LogMessageScrubbers.php on line 91

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/SoapLogMessageFormatter.php on line 156
.
Deprecated: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/AdWordsHeaderHandler.php on line 70

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/SoapLogMessageFormatter.php on line 187

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/SoapLogMessageFormatter.php on line 145

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/Util/LogMessageScrubbers.php on line 91

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/Common/SoapLogMessageFormatter.php on line 156
...................................................... 252 / 507 ( 49%)
..................................
Deprecated: DateTime::createFromFormat(): Passing null to parameter #2 ($datetime) of type string is deprecated in /home/tobias/repositories/googleads/googleads-php-lib/src/Google/AdsApi/AdWords/Query/QueryValidator.php on line 78
............................. 315 / 507 ( 62%)
............................................................... 378 / 507 ( 74%)
............................................................... 441 / 507 ( 86%)
............................................................... 504 / 507 ( 99%)
...                                                             507 / 507 (100%)

Time: 00:04.300, Memory: 24.00 MB

OK (507 tests, 1138 assertions)
PierrickVoulet commented 2 years ago

Successfully tested with 7.3, 7.4, 8.0, and 8.1.