Deprecation notices when using with PHP 8.4
Your client library and Google Ads API versions:
- Client library version:
dev-legacy-v25.0.0 - Google Ads API version:
V18Your environment: PHP 7. 4 up to PHP 8.4
Description of the bug:
When using the library on PHP 8.4 there are several deprecation notices which are logged. They all seem to be coming from the same function parseName which must make the $template parameter type nullable.
There might be other occurrences of PHP 8.4 incompatibilities in the library, but these are the ones we encountered from the parts that we use.
Steps to reproduce: Use one of the services from the library with PHP 8.4 ensuring that deprecation notices are being logged.
Expected behavior: No deprecation notices when running on PHP 8.4
Request/Response Logs: These are the notices we are currently encountering:
GoogleAdsServiceClient::parseName(): Implicitly marking parameter $template as nullable is deprecated, the explicit nullable type must be used instead
google-listings-and-ads/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/V16/Services/Client/GoogleAdsServiceClient.php:1789
CustomerServiceClient::parseName(): Implicitly marking parameter $template as nullable is deprecated, the explicit nullable type must be used instead
google-listings-and-ads/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/V16/Services/Client/CustomerServiceClient.php:163
ConversionActionServiceClient::parseName(): Implicitly marking parameter $template as nullable is deprecated, the explicit nullable type must be used instead
google-listings-and-ads/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/V16/Services/Client/ConversionActionServiceClient.php:157
CampaignServiceClient::parseName(): Implicitly marking parameter $template as nullable is deprecated, the explicit nullable type must be used instead
google-listings-and-ads/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/V16/Services/Client/CampaignServiceClient.php:287
ProductLinkInvitationServiceClient::parseName(): Implicitly marking parameter $template as nullable is deprecated, the explicit nullable type must be used instead
google-listings-and-ads/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/V16/Services/Client/ProductLinkInvitationServiceClient.php:164
LabelServiceClient::parseName(): Implicitly marking parameter $template as nullable is deprecated, the explicit nullable type must be used instead
google-listings-and-ads/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/V16/Services/Client/LabelServiceClient.php:141
CampaignBudgetServiceClient::parseName(): Implicitly marking parameter $template as nullable is deprecated, the explicit nullable type must be used instead
google-listings-and-ads/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/V16/Services/Client/CampaignBudgetServiceClient.php:141
AssetServiceClient::parseName(): Implicitly marking parameter $template as nullable is deprecated, the explicit nullable type must be used instead
google-listings-and-ads/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/V16/Services/Client/AssetServiceClient.php:161
AssetGroupServiceClient::parseName(): Implicitly marking parameter $template as nullable is deprecated, the explicit nullable type must be used instead
google-listings-and-ads/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/V16/Services/Client/AssetGroupServiceClient.php:159
AssetGroupAssetServiceClient::parseName(): Implicitly marking parameter $template as nullable is deprecated, the explicit nullable type must be used instead
google-listings-and-ads/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/V16/Services/Client/AssetGroupAssetServiceClient.php:181
ExtensionFeedItemServiceClient::parseName(): Implicitly marking parameter $template as nullable is deprecated, the explicit nullable type must be used instead
google-listings-and-ads/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/V16/Services/Client/ExtensionFeedItemServiceClient.php:211
Anything else we should know about your project / environment: The error logs from above are from V16 of the API, however this is still the same with the files for the latest V18 as well.
We include the library within a WordPress extension so we need to remain compatible with PHP 7.4 up to PHP 8.4, which is why we are currently using the legacy package: https://packagist.org/packages/googleads/google-ads-php#dev-legacy-v25.0.0
I'm still seeing this warnings. Any update on when these will be resolved?
Changed for Google Ads API v18: #1059 Please check this
Or use Google Ads API v19 with Google Ads API Client Library for PHP v26.1.0: https://github.com/googleads/google-ads-php/releases/tag/v26.1.0
Still the issue in some files, I can list at least those I'm using / tested: https://github.com/googleads/google-ads-php/blob/main/src/Google/Ads/GoogleAds/Lib/V18/GoogleAdsClientBuilder.php#L72-L73 https://github.com/googleads/google-ads-php/blob/main/src/Google/Ads/GoogleAds/Lib/V19/GoogleAdsClientBuilder.php#L72-L73 https://github.com/googleads/google-ads-php/blob/main/src/Google/Ads/GoogleAds/Lib/V20/GoogleAdsClientBuilder.php#L72-L73
PHP Deprecated: Google\Ads\GoogleAds\Lib\V20\UnaryGoogleAdsExceptionMiddleware::__construct(): Implicitly marking parameter $nextHandler as nullable is deprecated, the explicit nullable type must be used instead in /.../vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V20/UnaryGoogleAdsExceptionMiddleware.php on line 41
PHP Deprecated: Google\Ads\GoogleAds\Lib\V20\UnaryGoogleAdsExceptionMiddleware::__construct(): Implicitly marking parameter $statusMetadataExtractor as nullable is deprecated, the explicit nullable type must be used instead in /.../vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V20/UnaryGoogleAdsExceptionMiddleware.php on line 41
PHP Deprecated: Google\Ads\GoogleAds\Lib\GoogleAdsMiddlewareAbstract::__construct(): Implicitly marking parameter $nextHandler as nullable is deprecated, the explicit nullable type must be used instead in /.../vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/GoogleAdsMiddlewareAbstract.php on line 38
PHP Deprecated: Google\Ads\GoogleAds\Lib\V20\UnaryGoogleAdsResponseMetadataCallable::__construct(): Implicitly marking parameter $nextHandler as nullable is deprecated, the explicit nullable type must be used instead in /.../vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V20/UnaryGoogleAdsResponseMetadataCallable.php on line 36
I got deprecated notice in V20. cc. @Raibaz
Hi all,
Thank you for following up on this issue and for providing the specific stack traces for V20. This is extremely helpful!
We've logged this issue internally and will use it to track the completion of all these compatibility fixes. We'll post an update here once the final compatibility fix is available
Thanks!
@ajs424 For me it breaks script execution https://github.com/googleads/google-ads-php/pull/1117 https://github.com/googleads/google-ads-php/pull/1105