forked from vimeo/psalm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TDependentGetClass.php
63 lines (53 loc) · 1.42 KB
/
TDependentGetClass.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
<?php
namespace Psalm\Type\Atomic;
use Psalm\Type\Atomic;
use Psalm\Type\Union;
/**
* Represents a string whose value is a fully-qualified class found by get_class($var)
*/
final class TDependentGetClass extends TString implements DependentType
{
/**
* Used to hold information as to what this refers to
*
* @var string
*/
public $typeof;
/**
* @var Union
*/
public $as_type;
/**
* @param string $typeof the variable id
*/
public function __construct(string $typeof, Union $as_type)
{
$this->typeof = $typeof;
$this->as_type = $as_type;
}
public function getId(bool $exact = true, bool $nested = false): string
{
return $this->as_type->isMixed()
|| $this->as_type->hasObject()
? 'class-string'
: 'class-string<' . $this->as_type->getId($exact) . '>';
}
public function getKey(bool $include_extra = true): string
{
return 'get-class-of<' . $this->typeof
. (!$this->as_type->isMixed() && !$this->as_type->hasObject() ? ', ' . $this->as_type->getId() : '')
. '>';
}
public function getVarId(): string
{
return $this->typeof;
}
public function getReplacement(): Atomic
{
return new TClassString();
}
public function canBeFullyExpressedInPhp(int $analysis_php_version_id): bool
{
return false;
}
}