plugin icon indicating copy to clipboard operation
plugin copied to clipboard

[Feature Request]: Support higher order collection proxies

Open emmadesilva opened this issue 1 year ago • 5 comments

Feature Description

Abstract

Essentially reviving https://github.com/Haehnchen/idea-php-laravel-plugin/issues/149: I think it would be great if the plugin could give IDE support, or at least lessen warnings, when using higher order collection/tap proxies.

Here is what it looks like now:

image

Here is what I would like it to look like image

Implementation idea

I feel like the implementation should not be that hard to at least get rid of the magic property warning? Essentially, if it is known that a symbol contains a collection, and ->map is called directly on that instance, any property directly after the map should assume that the property is accessible (and should not produce a warning, bonus points if it can use generics to lead to the actual property when clicked), and any method called directly after the property called on the map method should be assumed is called back on the original collection.

Here is an illustration breaking it down:

$collection                                 ->map                                    ->name                                                                                                                          ->all();
| This is obviously a collection instance | This initiates a higher order map call | We now (due to it being right after the `map` call) know that this part is forwarded to the collection instance and is valid | Since this is called directly after the property after the `map` call we know that we have returned to the collection instance and can call any method on it |

emmadesilva avatar Mar 17 '24 12:03 emmadesilva

Hello. Have you tried main menu > Laravel > Helper code parameters > Turn on Collection proxies?

I'm not sure about all cases, but basic ones work.

adelf avatar Mar 19 '24 07:03 adelf

Hello. Have you tried main menu > Laravel > Helper code parameters > Turn on Collection proxies?

I'm not sure about all cases, but basic ones work.

Hey! As I noticed this in a HydePHP project (Which is based on Laravel Zero, and thus does not have access to Eloquent), I am unable to generate helper code as it crashes without Eloquent.

emmadesilva avatar Mar 19 '24 12:03 emmadesilva

Hello. Have you tried main menu > Laravel > Helper code parameters > Turn on Collection proxies?

I'm not sure about all cases, but basic ones work.

Is this option also available on PHPStorm? I am unable to find that setting

melvinotieno avatar May 27 '24 13:05 melvinotieno

The first checkbox in the dialog window.

Screenshot 2024-05-27 at 18 09 59

adelf avatar May 27 '24 14:05 adelf

Aaah, thanks. I was looking for it under the IDE settings.

On Mon, May 27, 2024 at 5:12 PM Adel @.***> wrote:

The first checkbox in the dialog window. Screenshot.2024-05-27.at.18.09.59.png (view on web) https://github.com/laravel-idea/plugin/assets/2818394/ff6be7ef-3c56-47c5-b9a2-4347ebb0c4bb

— Reply to this email directly, view it on GitHub https://github.com/laravel-idea/plugin/issues/952#issuecomment-2133568978, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK7YA3CHVVPZYOXQYQS4HALZEM5MDAVCNFSM6AAAAABE2E3LBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZTGU3DQOJXHA . You are receiving this because you commented.Message ID: @.***>

melvinotieno avatar May 27 '24 16:05 melvinotieno

Higher Order Proxy Collections are supported for standard Laravel installations

gorbunov avatar May 20 '25 18:05 gorbunov