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

Minor code cleanup #1079

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Minor code cleanup #1079

wants to merge 9 commits into from

Conversation

valzargaming
Copy link
Contributor

@valzargaming valzargaming commented Mar 25, 2023

Made some readability changes and moved the resolved/reject handling code into functions outside of the Deferred constructor, and used === instead of ==

@valzargaming
Copy link
Contributor Author

I think I fixed it now, should be good to test

$promise = coroutine([$handler, 'handle'], $data->d);
$promise->done([$deferred, 'resolve'], [$deferred, 'reject']);
$promise->done(&$onResolve, &$onReject);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
$promise->done(&$onResolve, &$onReject);
$promise->done($onResolve, $onReject);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

&$deferred was previously passed by reference, and these functions replace deferred

/** @var ExtendedPromiseInterface */

if (! $this->emittedInit && ! in_array($data->t, $parse)) {
$this->unparsedPackets[] = function () use (&$handler, &$onResolve, &$onReject, &$data) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are you passing these as reference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

&$deferred was previously passed by reference, and these functions replace deferred

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.

None yet

2 participants