-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHPStan error Promise but does not specify its types: T #235
Comments
Sorry for the delay. Finally getting to focus on this. Working to resolve it today. |
i reverted the annotations in php-http/promise#33 until we can figure out if there even is a way to correctly do them. |
How about this: /**
* Adds behavior for when the promise is resolved or rejected (response will be available, or error happens).
*
* If you do not care about one of the cases, you can set the corresponding callable to null
* The callback will be called when the value arrived and never more than once.
*
* @param callable(T): V|null $onFulfilled called when a response will be available
* @param callable(\Throwable): V|null $onRejected called when an exception occurs
*
* @return Promise<mixed> a new resolved promise with value of the executed callback (onFulfilled / onRejected)
*
* @template V
*/
public function then(callable $onFulfilled = null, callable $onRejected = null); that's a half measure, but at least something. Following chained Promise will have |
hm, yeah why not. it would help at least those those who want to handle the promise, if they don't chain things. have you tried this in a project with phpstan, does it report mistakes correctly and not report issues when the callback is used correctly? if you did, do you want to do a pull request for this? i think the return should explain that we can't precisely specify the return but explain in words what happens. |
PHP version: 8.1.22
Description
How to reproduce
PHPStan config:
PHPStan playground: https://phpstan.org/r/52113abc-06c9-4058-a970-4be7b8c9b311
ignore
Http\Client\Common\Plugin
errorPossible Solution
You can add a custom PHPDoc with the correct code, but it seems a bit redundant.
#233 (comment) has an example of this.
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.
/cc @ste93cry @Ndiritu
The text was updated successfully, but these errors were encountered: