diff --git a/src/Psalm/Type/Atomic/TConditional.php b/src/Psalm/Type/Atomic/TConditional.php index cadf204cb..b73defe67 100644 --- a/src/Psalm/Type/Atomic/TConditional.php +++ b/src/Psalm/Type/Atomic/TConditional.php @@ -160,7 +160,5 @@ class TConditional extends \Psalm\Type\Atomic ?Codebase $codebase ) : void { $this->conditional_type->replaceTemplateTypesWithArgTypes($template_result, $codebase); - $this->if_type->replaceTemplateTypesWithArgTypes($template_result, $codebase); - $this->else_type->replaceTemplateTypesWithArgTypes($template_result, $codebase); } } diff --git a/src/Psalm/Type/Atomic/TNumericString.php b/src/Psalm/Type/Atomic/TNumericString.php index 4b0b588c1..e835fb4e1 100644 --- a/src/Psalm/Type/Atomic/TNumericString.php +++ b/src/Psalm/Type/Atomic/TNumericString.php @@ -11,6 +11,11 @@ class TNumericString extends TString return 'numeric-string'; } + public function __toString() + { + return 'numeric-string'; + } + public function getId(bool $nested = false) { return $this->getKey(); diff --git a/src/Psalm/Type/Union.php b/src/Psalm/Type/Union.php index 99eac5ea5..58a824abe 100644 --- a/src/Psalm/Type/Union.php +++ b/src/Psalm/Type/Union.php @@ -1321,6 +1321,10 @@ class Union implements TypeNode $atomic_type->conditional_type )) { $class_template_type = clone $atomic_type->if_type; + $class_template_type->replaceTemplateTypesWithArgTypes( + $template_result, + $codebase + ); } elseif (TypeAnalyzer::isContainedBy( $codebase, $template_type, @@ -1333,10 +1337,24 @@ class Union implements TypeNode ) ) { $class_template_type = clone $atomic_type->else_type; + $class_template_type->replaceTemplateTypesWithArgTypes( + $template_result, + $codebase + ); } } if (!$class_template_type) { + $atomic_type->if_type->replaceTemplateTypesWithArgTypes( + $template_result, + $codebase + ); + + $atomic_type->else_type->replaceTemplateTypesWithArgTypes( + $template_result, + $codebase + ); + $class_template_type = Type::combineUnionTypes( $atomic_type->if_type, $atomic_type->else_type, @@ -1385,6 +1403,8 @@ class Union implements TypeNode $atomic_types, $codebase )->getAtomicTypes(); + + $this->id = null; } }