-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
add phpdoc templates to PromiseInterface #175
base: 2.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -12,6 +12,7 @@ | |||||||||||||||||||||||||||||||||||||
* the reason why the promise cannot be fulfilled. | ||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||
* @see https://promisesaplus.com/ | ||||||||||||||||||||||||||||||||||||||
* @template T | ||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||
interface PromiseInterface | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
|
@@ -25,6 +26,7 @@ interface PromiseInterface | |||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||
* @param callable $onFulfilled Invoked when the promise fulfills. | ||||||||||||||||||||||||||||||||||||||
* @param callable $onRejected Invoked when the promise is rejected. | ||||||||||||||||||||||||||||||||||||||
* @return PromiseInterface<T> | ||||||||||||||||||||||||||||||||||||||
Comment on lines
27
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The result of fulfillment and rejection are 2 separate types and need to be handled separately. If |
||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||
public function then( | ||||||||||||||||||||||||||||||||||||||
?callable $onFulfilled = null, | ||||||||||||||||||||||||||||||||||||||
|
@@ -82,7 +84,7 @@ public function cancel(): void; | |||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||
* If the promise cannot be waited on, then the promise will be rejected. | ||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||
* @return mixed | ||||||||||||||||||||||||||||||||||||||
* @return T|PromiseInterface<T> | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think
The return of the callback should determine the new template type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In reality, * @template TNextValue
* @param callable(TReason): TNextValue $onRejected Invoked when the promise is rejected.
*
* @return (TNextValue is PromiseInterface
* ? PromiseInterface<template-type<TNextValue, PromiseInterface, 'TValue'>, TReason|template-type<TNextValue, PromiseInterface, 'TReason'>>
* : PromiseInterface<TNextValue, TReason>
* )
As an aside, I made a mistake earlier: neither There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait there was this PR that tackled the problem too, but did not see a response: #157 . It might be better to handle it as a stub rather than duplicate annotations for each static analyzer |
||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||
* @throws \LogicException if the promise has no wait function or if the | ||||||||||||||||||||||||||||||||||||||
* promise does not settle after waiting. | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.