1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

avoid formating useless type (#4651)

This commit is contained in:
orklah 2020-11-21 23:42:26 +01:00 committed by GitHub
parent ffb0c4ae17
commit 98370b65d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -410,14 +410,14 @@ class Union implements TypeNode
$multi_floats = count($this->literal_float_types) > 1;
foreach ($this->types as $type) {
$type_string = $type->toNamespacedString($namespace, $aliased_classes, $this_class, $use_phpdoc_format);
if ($type instanceof TLiteralInt && !$multi_ints) {
$type_string = 'int';
} elseif ($type instanceof TLiteralFloat && !$multi_floats) {
$type_string = 'float';
} elseif ($type instanceof TLiteralString && !$multi_strings) {
$type_string = 'string';
} else {
$type_string = $type->toNamespacedString($namespace, $aliased_classes, $this_class, $use_phpdoc_format);
}
$types[] = $type_string;