-
Notifications
You must be signed in to change notification settings - Fork 3
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
Rewording of README and docblock #35
Conversation
957e6b0
to
d0258b3
Compare
* Warning: If you use type declarations for `$value`, be sure to make them accept `null` in case of failures. | ||
* | ||
* @param callable(\Throwable|\Exception|null $exception, mixed $value) $onResolved Callback to be executed. | ||
* @param callable(mixed $reason, mixed $value) @onResolved `$reason` shall be `null` on success, `$value` shall be |
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.
Why did you remove the type of reason? I want to see at the first look as callee that I'll only ever be passed something I can throw.
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.
See old PR, I asked that, too.
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.
Well, then please revert that. \cc @krakjoe
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.
I reiterate, please revert this.
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.
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.
it's clear to me now bob ~@krakjoe
Please revert it now ;o)
@@ -37,7 +37,7 @@ A `Promise` MUST be in one of three states: `pending`, `succeeded`, `failed`. | |||
|
|||
## Consumption | |||
|
|||
A `Promise` MUST implement `Interop\Async\Promise` and thus provide a `when()` method to access its current or eventual value or reason. | |||
A `Promise` MUST implement `Interop\Async\Promise` and thus provide a `when()` method to access its value or reason. |
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.
I'd retain the "current or future" here as there is no other temporal indication here, currently suggesting that the current
value/reason could be meant.
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.
I think it's fine as is combined with the rest of the spec.
|
||
All callbacks registered before the resolution MUST be executed in the order they were registered. Callbacks registered after the resolution MUST be executed immediately. If one of the callbacks throws an `Exception` or `Throwable`, it MUST be forwarded to `Async\Interop\Promise\ErrorHandler::notify`. The `Promise` implementation MUST then continue to call the remaining callbacks with the original parameters. | ||
All callbacks registered before the resolution MUST be executed in the order they were registered. Callbacks registered after the resolution MUST be executed immediately. If one of the callbacks throws an `Exception` or `Throwable`, it MUST be forwarded to `Interop\Async\Promise\ErrorHandler::notify`. The `Promise` MUST then continue to call the remaining callbacks with the original parameters. |
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.
AsyncInterop
now.
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.
Sure, wasn't rebased yet.
Any implementation MUST at least provide these two parameters. The implementation MAY extend the `Promise` interface with additional parameters passed to the callback. Further arguments to `when()` MUST have default values, so `when()` can always be called with only one argument. `when()` MAY NOT return a value. `when()` MUST NOT throw exceptions bubbling up from a callback invocation. | ||
|
||
> **NOTE:** The signature doesn't specify a type for `$error`. This is due to the new `Throwable` interface introduced in PHP 7. As this specification is PHP 5 compatible, we can use neither `Throwable` nor `Exception`. | ||
The implementation MAY extend `Promise::when` with additional parameters passed to the callback. Further arguments to `Promise::when()` MUST have default values, so `Promise::when()` can always be called with only one argument. `Promise::when()` MAY NOT return a value. `Promise::when()` MUST NOT throw exceptions bubbling up from a callback invocation. |
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.
the first Promise::when
is lacking a trailing parenthesis pair.
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.
Further arguments to Promise::when() MUST have default values, so Promise::when() can always be called with only one argument.
Can be removed altogether IMHO, as that's anyway covered by interface semantics.
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.
Added parens.
d0258b3
to
ac187c1
Compare
@@ -56,20 +56,18 @@ interface Promise | |||
* | |||
* If the promise is already resolved, the callback MUST be executed immediately. | |||
* | |||
* @param callable(mixed $reason, mixed $value) @onResolved `$reason` shall be `null` on success, `$value` shall be | |||
* `null` on failure. | |||
* @param callable(\Throwable|\Exception|null $exception, mixed $value) @onResolved `$reason` shall be `null` on |
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.
I would leave mixed
out… just $value
.
* | ||
* @return void | ||
* @return mixed Return type and value are unspecified. |
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.
In that case one does just omit @return
from docblock. State it in the text, but this is not appropriate in docblock.
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.
It's the right way if we want that. Omitting is equivalent to @return void
, see https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#715-return
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.
(IMHO void
is what we want to mean, according to my interpretation of void
within LSP… but fine. … not going to insist here.)
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.
Your interpretation is not what void
currently is in PHP.
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.
Meh, PHP is only supporting a subset of what should be possible due to LSP anyways... As said, I don't insist.
This PR supercedes #34. It additionally formats
@param
as in async-interop/event-loop.