1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* phpDocumentor |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @link http://phpdoc.org |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace phpDocumentor\GraphViz\PHPStan; |
15
|
|
|
|
16
|
|
|
use phpDocumentor\GraphViz\AttributeNotFound; |
17
|
|
|
use PHPStan\Reflection\ClassMemberReflection; |
18
|
|
|
use PHPStan\Reflection\ClassReflection; |
19
|
|
|
use PHPStan\Reflection\FunctionVariant; |
20
|
|
|
use PHPStan\Reflection\MethodReflection; |
21
|
|
|
use PHPStan\Reflection\ParametersAcceptor; |
22
|
|
|
use PHPStan\Reflection\Php\DummyParameter; |
23
|
|
|
use PHPStan\Reflection\Php\PhpParameterReflection; |
24
|
|
|
use PHPStan\TrinaryLogic; |
25
|
|
|
use PHPStan\Type\Generic\TemplateTypeHelper; |
26
|
|
|
use PHPStan\Type\Generic\TemplateTypeMap; |
27
|
|
|
use PHPStan\Type\ObjectType; |
28
|
|
|
use PHPStan\Type\StringType; |
29
|
|
|
use PHPStan\Type\Type; |
30
|
|
|
|
31
|
|
|
final class AttributeSetterMethodReflection implements MethodReflection |
32
|
|
|
{ |
33
|
|
|
/** @var ClassReflection */ |
34
|
|
|
private $classReflection; |
35
|
2 |
|
|
36
|
|
|
/** @var string */ |
37
|
2 |
|
private $name; |
38
|
2 |
|
/** @var Type */ |
39
|
2 |
|
private $attributeType; |
40
|
2 |
|
|
41
|
|
|
public function __construct(ClassReflection $classReflection, string $name, Type $attributeType) |
42
|
|
|
{ |
43
|
|
|
$this->classReflection = $classReflection; |
44
|
|
|
$this->name = $name; |
45
|
|
|
$this->attributeType = $attributeType; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getDeclaringClass() : ClassReflection |
49
|
|
|
{ |
50
|
|
|
return $this->classReflection; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function isStatic() : bool |
54
|
|
|
{ |
55
|
|
|
return false; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function isPrivate() : bool |
59
|
|
|
{ |
60
|
|
|
return false; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function isPublic() : bool |
64
|
|
|
{ |
65
|
|
|
return true; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getName() : string |
69
|
|
|
{ |
70
|
|
|
return $this->name; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getPrototype() : ClassMemberReflection |
74
|
|
|
{ |
75
|
2 |
|
return $this; |
76
|
|
|
} |
77
|
2 |
|
|
78
|
2 |
|
/** |
79
|
2 |
|
* @return ParametersAcceptor[] |
80
|
2 |
|
*/ |
81
|
|
|
public function getVariants() : array |
82
|
|
|
{ |
83
|
|
|
return [new FunctionVariant( |
84
|
|
|
TemplateTypeMap::createEmpty(), |
85
|
|
|
TemplateTypeMap::createEmpty(), |
86
|
|
|
[ |
87
|
|
|
new DummyParameter('value', $this->attributeType, false, null, false, null), |
88
|
|
|
], |
89
|
|
|
false, |
90
|
|
|
new ObjectType($this->classReflection->getName()) |
91
|
|
|
), |
92
|
|
|
]; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function getDocComment() : ?string |
96
|
|
|
{ |
97
|
|
|
return null; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function isDeprecated() : TrinaryLogic |
101
|
|
|
{ |
102
|
|
|
return TrinaryLogic::createNo(); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function getDeprecatedDescription() : ?string |
106
|
|
|
{ |
107
|
|
|
return null; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function isFinal() : TrinaryLogic |
111
|
|
|
{ |
112
|
|
|
return TrinaryLogic::createNo(); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function isInternal() : TrinaryLogic |
116
|
|
|
{ |
117
|
|
|
return TrinaryLogic::createNo(); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function getThrowType() : ?Type |
121
|
|
|
{ |
122
|
|
|
return new ObjectType(AttributeNotFound::class); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function hasSideEffects() : TrinaryLogic |
126
|
|
|
{ |
127
|
|
|
return TrinaryLogic::createYes(); |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|