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

Indentation causes invalid flatMap code replacement #19

Closed
squatto opened this issue Nov 4, 2020 · 3 comments · Fixed by #22
Closed

Indentation causes invalid flatMap code replacement #19

squatto opened this issue Nov 4, 2020 · 3 comments · Fixed by #22
Labels
bug Something isn't working

Comments

@squatto
Copy link
Contributor

squatto commented Nov 4, 2020

I have the following code:

collect($shopifyOrder->fulfillments)
    ->map(
        fn (ShopifyFulfillment $fulfillment) => $this->mapLineItems($order, $shopifyOrder, $fulfillment)
    )
    ->flatten(1);

It correctly suggests that I should use flatMap, but when I apply the refactoring, it ends up like this:

collect($shopifyOrder->fulfillments)
    flatMapmap(
        fn (ShopifyFulfillment $fulfillment) => $this->mapLineItems($order, $shopifyOrder, $fulfillment)
    );

Note the flatMapmap( instead of ->flatMap(

However, if I change the original code by pulling ->map( up to the previous line:

collect($shopifyOrder->fulfillments)->map(
        fn (ShopifyFulfillment $fulfillment) => $this->mapLineItems($order, $shopifyOrder, $fulfillment)
    )
    ->flatten(1);

It correctly refactors:

collect($shopifyOrder->fulfillments)->flatMap(
        fn (ShopifyFulfillment $fulfillment) => $this->mapLineItems($order, $shopifyOrder, $fulfillment)
    );

I'd be happy to provide more examples or to help in any way. Thanks!

@olivernybroe
Copy link
Owner

Haha, that's an interesting bug!

Thanks for reporting it ♥️

@olivernybroe olivernybroe added the bug Something isn't working label Nov 5, 2020
@olivernybroe
Copy link
Owner

olivernybroe commented Nov 5, 2020

I think I got this fixed now also 👍
You can install it manually here, I'll queue up a new release soon with the fixes. So they will also be available in the marketplace in a few days.
Collector-0.0.1-EAP.6.zip

Again, thanks a lot for the nice and detailed issues, makes it so much easier for me to debug and fix.

@squatto
Copy link
Contributor Author

squatto commented Nov 6, 2020

My pleasure! I know the pain that comes with "this is broken" issues 😂

Thanks for jumping on this (and #20) so quickly 👍🏻 I'll give the updated build a try right now. I found another weird foreach/use issue that I'll send over on #20 if the new build doesn't fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants