Skip to content
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

Merged
merged 7 commits into from
Jan 6, 2017
Merged

Rewording of README and docblock #35

merged 7 commits into from
Jan 6, 2017

Conversation

kelunik
Copy link
Member

@kelunik kelunik commented Dec 31, 2016

This PR supercedes #34. It additionally formats @param as in async-interop/event-loop.

* 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
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bwoebi Discuss this with @krakjoe.

Copy link
Member

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.
Copy link
Member

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.

Copy link
Member Author

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AsyncInterop now.

Copy link
Member Author

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.
Copy link
Member

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.

Copy link
Member

@bwoebi bwoebi Jan 5, 2017

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added parens.

@kelunik kelunik force-pushed the krakjoe-rewording branch from d0258b3 to ac187c1 Compare January 5, 2017 18:02
@@ -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
Copy link
Member

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.
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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.)

Copy link
Member Author

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.

Copy link
Member

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.

@kelunik
Copy link
Member Author

kelunik commented Jan 6, 2017

@trowski @jsor Can we go ahead and merge this one?

@kelunik kelunik requested review from jsor and trowski January 6, 2017 19:58
@bwoebi bwoebi merged commit 511ae43 into master Jan 6, 2017
@kelunik kelunik deleted the krakjoe-rewording branch January 20, 2017 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants