-
Notifications
You must be signed in to change notification settings - Fork 654
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 enums as parameters or return types #16
Comments
#17 could make this even awesomer |
What do you think of https://flowtype.org/docs/builtins.html#literal-types? Pretty much identical to your first proposition. And it could be used together with #18 to avoid repetition |
Seems like this might break from the standard PHPDoc |
Looks good! @erunion there's a |
How about /*
* @psalm-param enum-string('some-option'|Class::CONSTANT) $foo
*/
function takesConstant(string $foo) {} |
Oh I like that. |
that looks good! but it should support ints as well as strings |
@JanTvrdik did you have any plan to support a particular format in PHPStan, given you already have value types? |
and also
|
I reckon it's just a syntax proposal at this stage, and it's not implemented yet, right? |
Yeah, have updated - was unintentional |
Actually it can be simpler like |
That's perfect |
Merged basic support into master, will follow up with |
You always have to fake enums in PHP since they're not supported. Psalm could help this!
One option would be to do a syntax like this:
The quotes would differentiate the strings from classes, and this would fit pretty naturally with the way Psalm currently allows notation with
false
likeOr, you could do something like
which would kind of match the current fancy array syntax.
The text was updated successfully, but these errors were encountered: