|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of phpDocumentor. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
* |
|
8
|
|
|
* @copyright 2010-2015 Mike van Riel<[email protected]> |
|
9
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
|
10
|
|
|
* @link http://phpdoc.org |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace phpDocumentor\Reflection\Php; |
|
14
|
|
|
|
|
15
|
|
|
use phpDocumentor\Reflection\DocBlock; |
|
16
|
|
|
use phpDocumentor\Reflection\Element; |
|
17
|
|
|
use phpDocumentor\Reflection\Fqsen; |
|
18
|
|
|
use phpDocumentor\Reflection\Location; |
|
19
|
|
|
use phpDocumentor\Reflection\Type; |
|
20
|
|
|
use phpDocumentor\Reflection\Types\Mixed_; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Descriptor representing a function |
|
24
|
|
|
*/ |
|
25
|
|
|
// @codingStandardsIgnoreStart |
|
26
|
|
|
final class Function_ implements Element |
|
27
|
|
|
// // @codingStandardsIgnoreEnd |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* @var Fqsen Full Qualified Structural Element Name |
|
31
|
|
|
*/ |
|
32
|
|
|
private $fqsen; |
|
33
|
|
|
|
|
34
|
|
|
/** @var Argument[] $arguments */ |
|
35
|
|
|
private $arguments = array(); |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var DocBlock|null |
|
39
|
|
|
*/ |
|
40
|
|
|
private $docBlock; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var Location |
|
44
|
|
|
*/ |
|
45
|
|
|
private $location; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var Type |
|
49
|
|
|
*/ |
|
50
|
|
|
private $returnType; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Initializes the object. |
|
54
|
|
|
* |
|
55
|
|
|
* @param Fqsen $fqsen |
|
56
|
|
|
* @param DocBlock|null $docBlock |
|
57
|
|
|
* @param Location|null $location |
|
58
|
|
|
* @param Type|null $returnType |
|
59
|
|
|
*/ |
|
60
|
5 |
|
public function __construct( |
|
61
|
|
|
Fqsen $fqsen, |
|
62
|
|
|
DocBlock $docBlock = null, |
|
63
|
|
|
Location $location = null, |
|
64
|
|
|
Type $returnType = null |
|
65
|
|
|
) { |
|
66
|
5 |
|
if ($location === null) { |
|
67
|
5 |
|
$location = new Location(-1); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
5 |
|
if ($returnType === null) { |
|
71
|
5 |
|
$returnType = new Mixed_(); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
5 |
|
$this->fqsen = $fqsen; |
|
75
|
5 |
|
$this->docBlock = $docBlock; |
|
76
|
5 |
|
$this->location = $location; |
|
77
|
5 |
|
$this->returnType = $returnType; |
|
78
|
5 |
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Returns the arguments of this function. |
|
82
|
|
|
* |
|
83
|
|
|
* @return Argument[] |
|
84
|
|
|
*/ |
|
85
|
1 |
|
public function getArguments() |
|
86
|
|
|
{ |
|
87
|
1 |
|
return $this->arguments; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Add an argument to the function. |
|
92
|
|
|
* |
|
93
|
|
|
* @param Argument $argument |
|
94
|
|
|
*/ |
|
95
|
1 |
|
public function addArgument(Argument $argument) |
|
96
|
|
|
{ |
|
97
|
1 |
|
$this->arguments[] = $argument; |
|
98
|
1 |
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Returns the Fqsen of the element. |
|
102
|
|
|
* |
|
103
|
|
|
* @return Fqsen |
|
104
|
|
|
*/ |
|
105
|
1 |
|
public function getFqsen() |
|
106
|
|
|
{ |
|
107
|
1 |
|
return $this->fqsen; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Returns the name of the element. |
|
112
|
|
|
* |
|
113
|
|
|
* @return string |
|
114
|
|
|
*/ |
|
115
|
1 |
|
public function getName() |
|
116
|
|
|
{ |
|
117
|
1 |
|
return $this->fqsen->getName(); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Returns the DocBlock of the element if available |
|
122
|
|
|
* |
|
123
|
|
|
* @return null|DocBlock |
|
124
|
|
|
*/ |
|
125
|
1 |
|
public function getDocBlock() |
|
126
|
|
|
{ |
|
127
|
1 |
|
return $this->docBlock; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @return Location |
|
132
|
|
|
*/ |
|
133
|
|
|
public function getLocation() |
|
134
|
|
|
{ |
|
135
|
|
|
return $this->location; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @return Type |
|
140
|
|
|
*/ |
|
141
|
2 |
|
public function getReturnType() : Type |
|
142
|
|
|
{ |
|
143
|
2 |
|
return $this->returnType; |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|