1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Make name property of enum cases return non-empty-strings (vimeo/psalm#6964)

This commit is contained in:
Ricardo Boss 2021-12-06 00:33:57 +01:00
parent 056497e73d
commit 2ec77fe29c
2 changed files with 4 additions and 1 deletions

View File

@ -202,7 +202,7 @@ class AtomicPropertyFetchAnalyzer
new Type\Union([new Type\Atomic\TLiteralString($lhs_type_part->case_name)])
);
} else {
$statements_analyzer->node_data->setType($stmt, Type::getString());
$statements_analyzer->node_data->setType($stmt, Type::getNonEmptyString());
}
} else {
self::handleNonExistentProperty(

View File

@ -126,6 +126,9 @@ class EnumTest extends TestCase
case PUBLISHED;
case ARCHIVED;
/**
* @return non-empty-string
*/
public function get(): string
{
return $this->name;