-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat(option): new Option::apply()
method
#426
Conversation
Pull Request Test Coverage Report for Build 7355771608
💛 - Coveralls |
What would be the big benifit of this over using I don't see how I'dd use it personally at this moment, but I'm open for opinions :) |
Just syntactic sugar for operations if it holds Code like this (probably not the best example) $stock
->map(function (int $value) use ($logger) {
$logger->info('New stock requested', ['stock' => $value]);
return $value;
})
->map(Stock::create(...))
->map(function (Stock $value) use ($product) {
$product->updateStock($value);
return $value;
}); could be much more readable, and probably more expressive about intention: $stock
->apply(fn (int $value) => $logger->info('New stock requested', ['stock' => $value]))
->map(Stock::create(...))
->apply(fn (Stock $value) => $product->updateStock($stock)); |
@devnix can you rebase against the next branch to get the github actions green again and add some tests? |
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.
Looks good thanks. I've added a small couple of nitpicks to the code review.
After those it should be good to go!
@veewee I think this should be ready too, conflicts are resolved |
Cool, Thanks again! |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [azjezz/psl](https://togithub.com/azjezz/psl) | `2.8.0` -> `2.9.0` | [![age](https://developer.mend.io/api/mc/badges/age/packagist/azjezz%2fpsl/2.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/azjezz%2fpsl/2.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/azjezz%2fpsl/2.8.0/2.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/azjezz%2fpsl/2.8.0/2.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>azjezz/psl (azjezz/psl)</summary> ### [`v2.9.0`](https://togithub.com/azjezz/psl/releases/tag/2.9.0): Lenalee - 2.9.0 [Compare Source](https://togithub.com/azjezz/psl/compare/2.8.0...2.9.0) #### What's Changed - Apply fixes for Psalm 5.17 by [@​veewee](https://togithub.com/veewee) in [https://github.com/azjezz/psl/pull/431](https://togithub.com/azjezz/psl/pull/431) - feat(type): add class_string types ([#​432](https://togithub.com/azjezz/psl/issues/432)) by [@​zerkms](https://togithub.com/zerkms) in [https://github.com/azjezz/psl/pull/435](https://togithub.com/azjezz/psl/pull/435) - feat(option): add `Option::zip()`, `Option::zipWith()` and `Option::unzip()` methods by [@​devnix](https://togithub.com/devnix) in [https://github.com/azjezz/psl/pull/434](https://togithub.com/azjezz/psl/pull/434) - feat(option): add `Option::proceed()` method by [@​devnix](https://togithub.com/devnix) in [https://github.com/azjezz/psl/pull/433](https://togithub.com/azjezz/psl/pull/433) - feat(option): new `Option::apply()` method by [@​devnix](https://togithub.com/devnix) in [https://github.com/azjezz/psl/pull/426](https://togithub.com/azjezz/psl/pull/426) #### New Contributors - [@​zerkms](https://togithub.com/zerkms) made their first contribution in [https://github.com/azjezz/psl/pull/435](https://togithub.com/azjezz/psl/pull/435) **Full Changelog**: azjezz/psl@2.8.0...2.9.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/ben-challis/sql-migrations). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
I guess it's not an important method because you can return the same value with
map
, but I'll leave the proposal 😄