From e7db21fd44b2741dee2f5f4a1b55a3099b6be302 Mon Sep 17 00:00:00 2001 From: Brown Date: Fri, 15 May 2020 16:23:50 -0400 Subject: [PATCH] Fix type method --- src/Psalm/Type/Atomic/TTypeAlias.php | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/Psalm/Type/Atomic/TTypeAlias.php b/src/Psalm/Type/Atomic/TTypeAlias.php index 0b4bc915b..779571a9a 100644 --- a/src/Psalm/Type/Atomic/TTypeAlias.php +++ b/src/Psalm/Type/Atomic/TTypeAlias.php @@ -3,9 +3,16 @@ namespace Psalm\Type\Atomic; use Psalm\CodeLocation; use Psalm\StatementsSource; +use function implode; +use function array_map; class TTypeAlias extends \Psalm\Type\Atomic { + /** + * @var array|null + */ + public $extra_types; + /** @var string */ public $declaring_fq_classlike_name; @@ -31,6 +38,18 @@ class TTypeAlias extends \Psalm\Type\Atomic */ public function __toString() { + if ($this->extra_types) { + return $this->getKey() . '&' . implode( + '&', + array_map( + function ($type) { + return (string) $type; + }, + $this->extra_types + ) + ); + } + return $this->getKey(); } @@ -39,6 +58,18 @@ class TTypeAlias extends \Psalm\Type\Atomic */ public function getId(bool $nested = false) { + if ($this->extra_types) { + return $this->getKey() . '&' . implode( + '&', + array_map( + function ($type) { + return $type->getId(true); + }, + $this->extra_types + ) + ); + } + return $this->getKey(); }