Actual Typing Support for grpc-php

37 views
Skip to first unread message

Tobias Grether

unread,
Jun 29, 2023, 9:09:07 AM6/29/23
to grpc.io
GRPC is a very useful tool that helps everyone get typesafe APIs set up quickly.
However, a lot of that type safety is sadly lost in the PHP implementation of grpc.

GRPC knows how the response will be structured, however instead of returning a structured response object which will allow autocomplete and static analysis, grpc opts to return the response data of a UnaryCall in an stdclass, which is a dynamic class which can hold any property dynamically. 
The issue with this is that it makes both autocomplete and static analysis with for example PHPStan completely impossible.

Since GRPC already knows how the response is structured, and since PHP has become a lot more type-safe since php5, I think it would be appropriate to update GRPC to reflect that.


dfa...@google.com

unread,
Jun 30, 2023, 12:44:13 PM6/30/23
to grpc.io
Hi Tobias,

Is this the same as the request you filed in the github repo, https://github.com/grpc/grpc/issues/33431?  If so, we should try to consolidate all discussion there.

Thanks,
Doug

Reply all
Reply to author
Forward
0 new messages