1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* phpDocumentor |
4
|
|
|
* |
5
|
|
|
* PHP Version 5.3 |
6
|
|
|
* |
7
|
|
|
* @copyright 2010-2014 Mike van Riel / Naenius (http://www.naenius.com) |
8
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
9
|
|
|
* @link http://phpdoc.org |
10
|
|
|
*/ |
11
|
|
|
namespace phpDocumentor\Descriptor; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Descriptor representing a single Argument of a method or function. |
15
|
|
|
*/ |
16
|
|
|
class ArgumentDescriptor extends DescriptorAbstract implements Interfaces\ArgumentInterface |
17
|
|
|
{ |
18
|
|
|
/** @var MethodDescriptor $method */ |
19
|
|
|
protected $method; |
20
|
|
|
|
21
|
|
|
/** @var string[] $type an array of normalized types that should be in this Argument */ |
22
|
|
|
protected $types = array(); |
23
|
|
|
|
24
|
|
|
/** @var string|null $default the default value for an argument or null if none is provided */ |
25
|
|
|
protected $default; |
26
|
|
|
|
27
|
|
|
/** @var bool $byReference whether the argument passes the parameter by reference instead of by value */ |
28
|
|
|
protected $byReference = false; |
29
|
|
|
|
30
|
|
|
/** @var boolean Determines if this Argument represents a variadic argument */ |
31
|
|
|
protected $isVariadic = false; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* To which method does this argument belong to |
35
|
|
|
* |
36
|
|
|
* @param MethodDescriptor $method |
37
|
|
|
*/ |
38
|
|
|
public function setMethod(MethodDescriptor $method) |
39
|
|
|
{ |
40
|
|
|
$this->method = $method; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritDoc} |
45
|
|
|
*/ |
46
|
|
|
public function setTypes($types) |
47
|
|
|
{ |
48
|
|
|
$this->types = $types; |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritDoc} |
53
|
|
|
*/ |
54
|
|
|
public function getTypes() |
55
|
|
|
{ |
56
|
|
|
$countable = $this->types instanceof \Countable || is_array($this->types); |
57
|
|
|
if ((!$countable || count($this->types) == 0) && $this->getInheritedElement() !== null) { |
58
|
|
|
$this->setTypes($this->getInheritedElement()->getTypes()); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return $this->types; |
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return null|ArgumentDescriptor |
66
|
|
|
*/ |
67
|
|
|
public function getInheritedElement() |
68
|
|
|
{ |
69
|
|
|
if ($this->method instanceof MethodDescriptor && |
70
|
|
|
$this->method->getInheritedElement() instanceof MethodDescriptor) { |
71
|
|
|
$parents = $this->method->getInheritedElement()->getArguments(); |
72
|
|
|
foreach($parents as $parentArgument) |
|
|
|
|
73
|
|
|
{ |
74
|
|
|
if ($parentArgument->getName() === $this->getName()) { |
75
|
|
|
return $parentArgument; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
return null; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* {@inheritDoc} |
84
|
|
|
*/ |
85
|
|
|
public function setDefault($value) |
86
|
|
|
{ |
87
|
|
|
$this->default = $value; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* {@inheritDoc} |
92
|
|
|
*/ |
93
|
|
|
public function getDefault() |
94
|
|
|
{ |
95
|
|
|
return $this->default; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* {@inheritDoc} |
100
|
|
|
*/ |
101
|
|
|
public function setByReference($byReference) |
102
|
|
|
{ |
103
|
|
|
$this->byReference = $byReference; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* {@inheritDoc} |
108
|
|
|
*/ |
109
|
|
|
public function isByReference() |
110
|
|
|
{ |
111
|
|
|
return $this->byReference; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Sets whether this argument represents a variadic argument. |
116
|
|
|
* |
117
|
|
|
* @param boolean $isVariadic |
118
|
|
|
* |
119
|
|
|
* @return false |
120
|
|
|
*/ |
121
|
|
|
public function setVariadic($isVariadic) |
122
|
|
|
{ |
123
|
|
|
$this->isVariadic = $isVariadic; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Returns whether this argument represents a variadic argument. |
128
|
|
|
* |
129
|
|
|
* @return boolean |
130
|
|
|
*/ |
131
|
|
|
public function isVariadic() |
132
|
|
|
{ |
133
|
|
|
return $this->isVariadic; |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..