googleapis / googleapis/google-cloud-php

PHPStan Error in google/cloud-recaptcha-enterprise

Open
#8,372 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
1.2k
Forks
463
Avg merge
2d 1h
Merged PRs (30d)
145

Description

Since the package is deprecated, I was unsure which issue type would be appropriate, but I am submitting this as a **Bug Report** because a PHPStan error occurs.

#### Environment details

- OS: Debian GNU/Linux 12 (bookworm)
- PHP version: 8.3.22
- Package name and version: `google/cloud-recaptcha-enterprise:2.1.1`, `google/protobuf:4.31.1`
#### Steps to reproduce

1. Create an instance of `RecaptchaEnterpriseServiceClient`.
2. Create a `CreateAssessmentRequest` object.
3. Send the request using the client.
4. Access the `RiskAnalysis` of the returned `Assessment` and call `getReasons()`.
5. Attempt to call `getIterator()` on the result of `getReasons()`.
6. A PHPStan error occurs.
#### Code example

```php
use Google\Cloud\RecaptchaEnterprise\V1\Assessment;
use Google\Cloud\RecaptchaEnterprise\V1\Client\RecaptchaEnterpriseServiceClient;
use Google\Cloud\RecaptchaEnterprise\V1\CreateAssessmentRequest;

// Credentials are actually passed when creating the client
$client = new RecaptchaEnterpriseServiceClient();

// Omitted: building the Assessment instance
$assessment = new Assessment();
$assessmentRequest = CreateAssessmentRequest::build($parent, $assessment);

$createdAssessment = $client->createAssessment($assessmentRequest);
$createdAssessment->getRiskAnalysis()?->getReasons()->getIterator(); // Call to an undefined method Google\Protobuf\Internal\RepeatedField::getIterator().
```

I’ve been following the protobuf updates and it appears this issue may be due to changes introduced here:

[https://github.com/protocolbuffers/protobuf-php/commit/9a6ad10d77de8a6d3320f10bd097bed8d6021ac1#diff-f4adb7d6333d82634864e3424d178a65e8c6e413c257198fd8371622e1e0b303](https://github.com/protocolbuffers/protobuf-php/commit/9a6ad10d77de8a6d3320f10bd097bed8d6021ac1#diff-f4adb7d6333d82634864e3424d178a65e8c6e413c257198fd8371622e1e0b303)

I understand that this package is deprecated and things still function for now, but I wanted to report this for future compatibility and also because this causes a PHPStan error. I’d appreciate it if you could consider addressing it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.