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

Chained promise returning nothing should be OK #70

Closed
g105b opened this issue Dec 6, 2023 · 0 comments · Fixed by #71
Closed

Chained promise returning nothing should be OK #70

g105b opened this issue Dec 6, 2023 · 0 comments · Fixed by #71
Labels
enhancement New feature or request question Further information is requested
Projects

Comments

@g105b
Copy link
Member

g105b commented Dec 6, 2023

Typical fetch:

$http->fetch("http://example.com")

->then(function(Response $response) {
  if(!$response->ok) {
    return; // HERE LIES AN ISSUE
  }

  return $response->text();
})

->then(function(string $html) {
  // ...
});

Because the next promise in the chain expects a string of html, it's impossible to return nothing.

What's the proper way of returning early? Should we be able to return void at this point?

@g105b g105b added enhancement New feature or request question Further information is requested labels Dec 6, 2023
@g105b g105b added this to Backlog in Overview via automation Dec 6, 2023
@g105b g105b moved this from Backlog to Planned in Overview Jan 16, 2024
@g105b g105b moved this from Planned to WIP in Overview Feb 10, 2024
@g105b g105b closed this as completed in #71 May 5, 2024
g105b added a commit that referenced this issue May 5, 2024
* test: pass existing tests for #70 functionality

* build: php 8.1 compatibility

* ci: use latest phpunit

* ci: use latest phpunit

* ci: debug phpunit

* ci: debug phpunit

* ci: debug phpunit

* test: ensure "finally" can return its own promise

* test: ensure "finally" can return its own promise

* test: fix static analysis

* build: ignore complexity error
Overview automation moved this from WIP to May 2024 May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
Overview
May 2024
Development

Successfully merging a pull request may close this issue.

1 participant