- Notifications
You must be signed in to change notification settings - Fork 52
Closed
Description
PHP version: 8.1.22
Description
Method handleRequest() has parameter [...] with generic interface Http\Promise\Promise but does not specify its types: T
How to reproduce
<?php declare(strict_types=1); use Http\Client\Common\Plugin; use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; final class Authentication implements Plugin { public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { $request = $request->withHeader('Authorization', 'token bla'); return $next($request); } }
PHPStan config:
parameters: level: max checkMissingIterableValueType: false treatPhpDocTypesAsCertain: false paths: - src
PHPStan playground: https://phpstan.org/r/52113abc-06c9-4058-a970-4be7b8c9b311
ignore Http\Client\Common\Plugin
error
Possible Solution
You can add a custom PHPDoc with the correct code, but it seems a bit redundant.
#233 (comment) has an example of this.
/** * @param callable(RequestInterface): Promise<ResponseInterface> $next * @param callable(RequestInterface): Promise<ResponseInterface> $first * * @return Promise<ResponseInterface> */ public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
Additional context
Seems #234 is already on the way to get it fixed!
But I could hardly find ANY information about "issue". So creating a new issue for documentation purposes.
Metadata
Metadata
Assignees
Labels
No labels