/
TTypeAlias.php
85 lines (70 loc) · 1.88 KB
/
TTypeAlias.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
namespace Psalm\Type\Atomic;
use Psalm\Type\Atomic;
use function array_map;
use function implode;
class TTypeAlias extends Atomic
{
/**
* @var array<string, TTypeAlias>|null
*/
public $extra_types;
/** @var string */
public $declaring_fq_classlike_name;
/** @var string */
public $alias_name;
public function __construct(string $declaring_fq_classlike_name, string $alias_name)
{
$this->declaring_fq_classlike_name = $declaring_fq_classlike_name;
$this->alias_name = $alias_name;
}
public function getKey(bool $include_extra = true): string
{
return 'type-alias(' . $this->declaring_fq_classlike_name . '::' . $this->alias_name . ')';
}
public function __toString(): string
{
if ($this->extra_types) {
return $this->getKey() . '&' . implode(
'&',
array_map(
'strval',
$this->extra_types
)
);
}
return $this->getKey();
}
public function getId(bool $nested = false): string
{
if ($this->extra_types) {
return $this->getKey() . '&' . implode(
'&',
array_map(
fn($type) => $type->getId(true),
$this->extra_types
)
);
}
return $this->getKey();
}
/**
* @param array<lowercase-string, string> $aliased_classes
*/
public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
int $analysis_php_version_id
): ?string {
return null;
}
public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool
{
return false;
}
public function getAssertionString(): string
{
return 'mixed';
}
}