Skip to content

analytics-data V1Beta using deprecated Protobuf classes #2673

Open
@Michael-O-adtorque

Description

@Michael-O-adtorque

OS: Ubuntu 24.04
PHP: 8.3.19

We use the analytics service to run batch reports using (for example) vendor/google/analytics-data/src/V1beta/BatchRunReportsResponse.php

https://github.com/googleapis/php-analytics-data/blob/main/src/V1beta/RunReportResponse.php

The $reports variable as part of this class (and seemingly this affects the entire analytics suite) uses Google\Protobuf\Internal\RepeatedField, however according to the documentation, this class is now deprecated and the Google\Protobuf\RepeatedField should be used insetad.

This is not a problem, but we use code sniffers in our codebase which now complain because the deprecated class now no longer implements IteratorAggregate, so therefore our code sniffer complains that this field is no longer valid to be iterated over:

`


Line Provider/GoogleAnalytics/BulkReportProcessor.php


142 Argument of an invalid type Google\Protobuf\Internal\RepeatedField supplied for foreach, only iterables are supported.
🪪 foreach.nonIterable
------ ------------------------------------------------------------------------------------------------------------------------`

A sample code block from our system is below. You can see that I am trying to iterate over the 'reports' element. This was working fine in previous versions of the API, but today did a full composer update with all dependencies.

`
use Google\Analytics\Data\V1beta\BatchRunReportsResponse

private function postProcess(
    BatchRunReportsResponse $batchResponse,

....
): int {

foreach ($batchResponse->getReports() as $idx => $reportResponse) {  // 

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions