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

Specify enum by shared prefix #2739

Closed
ro0NL opened this issue Feb 3, 2020 · 4 comments
Closed

Specify enum by shared prefix #2739

ro0NL opened this issue Feb 3, 2020 · 4 comments

Comments

@ro0NL
Copy link
Contributor

ro0NL commented Feb 3, 2020

Given the class example at https://psalm.dev/docs/annotating_code/typing_in_psalm/#specifying-stringint-options-aka-enums

it's common to have a list of enum values, that belong together. Usually a list of possible statuses, e.g.

class Subject {
  const STATUS_OK = 0;
  const STATUS_KO = 1;
}

Listing all possible statuses would be boring, as such i suggest

@param Subject::STATUS_* $status

Additionally it could allow any const using Subject::* $status, but it looks less like a known const type :/ so it could be confusing to reason about.

@muglug
Copy link
Collaborator

muglug commented Feb 3, 2020

Create a PR for the documentation and I'll add the implementation

@ro0NL
Copy link
Contributor Author

ro0NL commented Feb 3, 2020

@param A::SOME_*|A::SOME_X should be marked redundant btw. Nice to have i guess :)

@muglug
Copy link
Collaborator

muglug commented Feb 3, 2020

@param A::SOME_*|A::SOME_X should be marked redundant

I won't bother with that, I don't think

@weirdan
Copy link
Collaborator

weirdan commented Feb 3, 2020

I had a perfect use-case for * today:

/**
 * @psalm-type _LogLevel=LogLevel::EMERGENCY|LogLevel::ALERT|LogLevel::CRITICAL|LogLevel::ERROR|LogLevel::WARNING|LogLevel::NOTICE|LogLevel::INFO|LogLevel::DEBUG
 */

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

No branches or pull requests

3 participants