laravel-idea / plugin

Laravel Idea plugin for PhpStorm
https://laravel-idea.com/
166 stars 7 forks source link

[Feature Request]: Support autocomplete Psalm-style enum string parameters #1024

Open caendesilva opened 2 months ago

caendesilva commented 2 months ago

Feature Description

Hey! Something I think would be really useful is if Idea could fill in enumerated string parameters defined using the Psalm syntax @var 'A'|'B'|'C'

/**
* @param  'dropdown'|'flat'|'hidden'  $displayMode
*/
public function setSubdirectoryDisplayMode(string $displayMode): static
{
    self::assertType(['dropdown', 'flat', 'hidden'], $displayMode);

    $this['subdirectory_display'] = $displayMode;

    return $this;
}

// This would provide autocomplete to fill in the word "hidden"
$builder->setSubdirectoryDisplayMode('hi|'); // Pipe denotes cursor

// This would show a warning/error
$builder->setSubdirectoryDisplayMode('invalid')

See https://psalm.dev/docs/annotating_code/typing_in_psalm/#specifying-stringint-options-aka-enums and https://github.com/vimeo/psalm/issues/16

caendesilva commented 1 month ago

@adelf I'm assuming this could be implemented by hooking in to the ide.json system right?

adelf commented 1 month ago

Hello. Yes. It's the simplest way.

On Fri, 26 Jul 2024, 16:10 Caen De Silva, @.***> wrote:

@adelf https://github.com/adelf I'm assuming this could be implemented by hooking in to the ide.json system right?

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