php-enum
php-enum copied to clipboard
Support phan annotations such as `@phan-return` and `@phan-side-effect-free`?
https://github.com/phan/phan/wiki/Annotating-Your-Source-Code documents the available options. https://github.com/phan/phan/wiki/About-Union-Types documents union types supported by Phan.
non-empty-string is not supported in array keys.
IMHO we shouldn't add annotations for phan + phpstan + psalm. It adds to much overhead to support all of those and next week we might have another 3 additionally. Pick one and stick to it.
Hi @TysonAndre,
A lot has been done already in #140 & #138 and a phpstan extension is available here https://github.com/marc-mabe/php-enum-phpstan/
Type-hints are defined with standard annotations and some special hints like non-empty-string are marked with @psalm-.
What exactly are you missing?
This was for https://github.com/phan/phan , not psalm or phpstan, because I'm using phan in a project using php-enum. So phan would get the generic types without any information about key types, and not be provided the information to warn about somesubclass::getValues()['not_an_integer']
@phan-return list<null|bool|int|float|string|array> for getValues()
@phan-return list<non-empty-string> for getNames() instead of string[]
@phan-return array<string, null|bool|int|float|string|array> for getConstants()
Although I may eventually add an option for phan to read psalm-specific annotations, and ignore syntax that it doesn't understand, that approach would cause bugs in custom types declared with @psalm-type