php-http / client-common

Common HTTP Client implementations and tools for HTTPlug
http://httplug.io
MIT License
1.01k stars 53 forks source link

Fix static ci #233

Closed dbu closed 8 months ago

dbu commented 10 months ago

@Ndiritu could you help me here please to figure out what annotations we need to put to avoid the phpstan errors after https://github.com/php-http/promise/pull/27?

Ndiritu commented 10 months ago

Sure

@Ndiritu could you help me here please to figure out what annotations we need to put to avoid the phpstan errors after php-http/promise#27?

Sure, taking a look @dbu

ste93cry commented 10 months ago

I've been hit in one of the projects I contribute to by PHPStan complaining that

Method handleRequest() has parameter [...] with generic interface Http\Promise\Promise but does not specify its types: T

This has happened indirectly because the project implements a custom plugin. Since such method is expected to return a ResponseInterface, the solution that seems to work is the following:

/**
- * @param callable(RequestInterface): Promise $next
+ * @param callable(RequestInterface): Promise<ResponseInterface> $next
- * @param callable(RequestInterface): Promise $first
+ * @param callable(RequestInterface): Promise<ResponseInterface> $first
 *
- * @return Promise
+ * @return Promise<ResponseInterface>
 */
dbu commented 9 months ago

@ste93cry we try to fix just the phpstan issue in #234 but seem to have a problem with phpstan (or some confusion on how to correctly annotate)