-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
phpstan/phpstan-src
#3807Description
Feature request
Similar to phpstan/phpstan-src#2764, but useful if narrowed to the same type in PHPDoc too.
/**
* @param enum-string $s
*/
function f(string $s): void {
assertType('class-string<UnitEnum>', $s);
$cases = $s::cases();
assertType('list<UnitEnum>', $cases);
}
/**
* @param enum-string<UnitEnum> $s
*/
function g(string $s): void {
assertType('class-string<UnitEnum>', $s);
$cases = $s::cases();
assertType('list<UnitEnum>', $cases);
}- Psalm: https://psalm.dev/r/ea20c1515d
- PHPStan: https://phpstan.org/r/486783d4-22d5-444a-be21-d5de4aa3c3f5
Did PHPStan help you today? Did it make you happy in any way?
I had been in poor physical condition since the end of last year, but I've started writing a beginner's tutorial to get back into the swing of things. While writing the description for the type, I realized that the enum-string could be improved.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels