You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PHPStan error Promise but does not specify its types: T #235
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.
/** * 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 */publicfunction then(callable$onFulfilled = null, callable$onRejected = null);
that's a half measure, but at least something. Following chained Promise will have mixed type. We don't chain calls too often in PHP world anyway.
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.
Activity
Ndiritu commentedon Nov 15, 2023
Sorry for the delay. Finally getting to focus on this. Working to resolve it today.
dbu commentedon Jan 4, 2024
i reverted the annotations in php-http/promise#33 until we can figure out if there even is a way to correctly do them.
ybelenko commentedon May 11, 2024
How about this:
that's a half measure, but at least something. Following chained Promise will have
mixedtype. We don't chain calls too often in PHP world anyway.dbu commentedon May 16, 2024
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.