googleapis / googleapis/google-api-php-client-services
Incorrect return type annotations for batch requests
- Dominant language
- PHP
- Stars
- 1.3k
- Forks
- 320
- Avg merge
- 2h 32m
- Merged PRs (30d)
- 193
Description
#### Environment details
- OS: Debian testing
- PHP version: 7.3.8
The return type of many API functions is incorrect, missing the option that many functions can return `Request`, if batch requests are enabled.
For example, the function `Google_Service_Drive_Resource_Files::get()` normally returns a `Google_Service_Drive_DriveFile`, as is written in the doc comment.
However, if batch requests are turned on, this function won't return the actual file, but instead a `GuzzleHttp\Psr7\Request`. This is because the function `Google_Service_Drive_Resource_Files::get()` calls `Google_Service_Resource::call()`, which (if batching is enabled) returns the request instead of the response ([source](https://github.com/googleapis/google-api-php-client/blob/d6c7563bdf88d6a0719ea63e21c74dc86032364e/src/Google/Service/Resource.php#L229)).
So the correct PHPDoc return signature for `Google_Service_Drive_Resource_Files::get()` should be
```php
/**
* ...
*
* @return Google_Service_Drive_DriveFile|Request
*/
```
Of course, this applies to many more functions than just this one - possibly to all of them, but I am not really sure.
Contributor guide
Assessment
This issue has not been assessed yet.