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

Fix type method

This commit is contained in:
Brown 2020-05-15 16:23:50 -04:00
parent c62e08a88e
commit e7db21fd44

View File

@ -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<string, TTypeAlias>|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();
}