-
-
Notifications
You must be signed in to change notification settings - Fork 87
feat: introduce mapEach()
method
#834
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: 2.x
Are you sure you want to change the base?
Conversation
d057df8
to
5e011a5
Compare
5e011a5
to
c0a3c18
Compare
|
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.
Would you mind adding the docs for this with a real example? It'd help me understand the feature more I think.
I agree |
* | ||
* @return self<T, TFactory> | ||
*/ | ||
public function mapEach(callable $callback, array $values): self // @phpstan-ignore missingType.callable (cannot properly type the callable) |
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.
public function mapEach(callable $callback, array $values): self // @phpstan-ignore missingType.callable (cannot properly type the callable) | |
public function map(callable $callback, array $values): self // @phpstan-ignore missingType.callable (cannot properly type the callable) |
Maybe then it would be better to use the same signature as *
* @return self<T, TFactory>
*/
function map(callable $callback, array... $arguments): self Instead of calling |
yeah this could be a good idea... I still need to work on this one and think of a good real life example to convince @kbond 😆 I'm not really sure It's a mix between a "map()" and the new BTW, I'm still not 100% convince of the API of this method. But I really would like something to call so-called "state method" on each element of a |
I'm bringing back this
mapEach()
method.On the project I'm working on, we have tons of factories with "withers" which prevents to use sequences and fluent usage of the factories when collections are involved.
I'm opened to any better api, or naming 😅