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

Add support for phpstorm #99

Open
zmitic opened this issue Aug 15, 2019 · 0 comments
Open

Add support for phpstorm #99

zmitic opened this issue Aug 15, 2019 · 0 comments

Comments

@zmitic
Copy link

zmitic commented Aug 15, 2019

In PHPStorm, when you have code like $enum->equals() you don't have autocomplete of possible options.

That should be achievable with meta file: https://blog.jetbrains.com/phpstorm/2019/02/new-phpstorm-meta-php-features/

Now... I am not going to lie, I tried and failed:

// my enum class
/**
 * @method static Status INCOMPLETE()
 * @method static Status PENDING()
 * @method static Status FEEDBACK()
 * @method static Status OPTIONAL()
 * @method static Status APPROVED()
 */
class Status extends Enum
{
    private const INCOMPLETE = '(incomplete)';
    private const PENDING = '(pending)';
    private const FEEDBACK = '(feedback)';
    private const OPTIONAL = '(optional)';
    private const APPROVED = '(approved)';
}

and failed attempt of meta file (cache invalidated, just in case):

<?php

namespace PHPSTORM_META {

    registerArgumentsSet('profile_status_enum',
        \App\Doctrine\Enum\Status::PENDING(),
        \App\Doctrine\Enum\Status::APPROVED(),
        \App\Doctrine\Enum\Status::FEEDBACK(),
        \App\Doctrine\Enum\Status::INCOMPLETE(),
        \App\Doctrine\Enum\Status::OPTIONAL(),
    );

    expectedArguments(\App\Doctrine\Enum\Status::equals(), 0, argumentsSet('profile_status_enum'));
}

Used example was intentionally for real enum class, just to see if I can make it work.

I am honestly not sure if this is a bug in PHPStorm or more likely that I messed up but if someone has experience with this, it would be nice to have autocomplete by reading from values() method.


The reason I created this issue is that if this library has meta file, PHPStorm will automatically pick it up. One composer update should be enough for end-users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant