aws / aws-sdk-php

Official repository of the AWS SDK for PHP (@awsforphp)
http://aws.amazon.com/sdkforphp
Apache License 2.0
6.03k stars 1.22k forks source link

LambdaClient::invokeAsync type incorrect #3004

Open gauthierm opened 1 month ago

gauthierm commented 1 month ago

Describe the issue

The LambdaClient::invokeAsync method has two type definitions, the second of which appears to be incorrect and overrides the first.

As I understand the SDK, invokeAsync should return a Promise, but the API docs say it returns a Result. This causes warnings when combined with PHPStan or other type checking tools.

Links

https://github.com/aws/aws-sdk-php/blob/master/src/Lambda/LambdaClient.php#L80-L81

yenfryherrerafeliz commented 1 month ago

Hi @gauthierm, thanks for reporting this. The issue here is that the name of the operation from Lambda conflicts with our method naming convention. For every service operation we declare two methods, one is the synchronous version where we do not alter its name, for example Invoke, and the other is the asynchronous one that we suffix it with Async, for example InvokeAsync. And this last one is the one that should return a Promise. However, in this particular scenario Lambda has one operation called Invoke, for which we declare the two magic methods defined above, and another operation called 'InvokeAsync', for which we do the same. But, the synchronous method declaration for InvokeAsync will conflict with the asynchronous method of Invoke which will also be InvokeAsync.

I will add this to our backlog so I can discuss this further with my team.

Thanks!