idea-php-laravel-plugin icon indicating copy to clipboard operation
idea-php-laravel-plugin copied to clipboard

Support Laravel collections "Higher Order Messages" feature

Open velosipedist opened this issue 7 years ago • 3 comments

It would be great to catch keywords listed there to get autocompletion and refactoring lookup support of collection items methods, like

$users->each->markAs|// <ctrl-space>
$users->each->markAsVip(); // Shift-F6 may rename method in-place

velosipedist avatar Sep 18 '17 10:09 velosipedist

It's very hard to implement.

$users = User::where('votes', '>', 500)->get();
// $users here is just an object of class Collection. 
// PhpStorm can't understand that it's a collection of User objects...
$users->each->markAsVip();

adelf avatar Sep 18 '17 10:09 adelf

@adelf sure, it is not easy to implement. But not seems impossible for me.

Anyway, having an ability to recognize resulting type of collection items returned by find*** would be useful by itself. But it deserves a separate task, of course.

This task is not for catching any collections usage scenarios. But catching at least following

$collection = collect([$foo, $bar]);
$collection->each->/* ctrl + space shows all possible members autocompletions */;

would be already very useful.

Unfortunately, i have no experience in Java, otherwise i'd help to research this idea solution. :/

velosipedist avatar Sep 20 '17 10:09 velosipedist

Isn't this made easier by https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata ? I'm thinking especially of 'elementType'

sztyup avatar Aug 04 '19 18:08 sztyup