1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* This file is part of 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\Descriptor; |
15
|
|
|
|
16
|
|
|
use phpDocumentor\Reflection\Fqsen; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Descriptor representing an Interface. |
20
|
|
|
*/ |
21
|
|
|
class InterfaceDescriptor extends DescriptorAbstract implements Interfaces\InterfaceInterface |
22
|
|
|
{ |
23
|
|
|
/** @var Collection $extends */ |
24
|
|
|
protected $parents; |
25
|
|
|
|
26
|
|
|
/** @var Collection $constants */ |
27
|
|
|
protected $constants; |
28
|
|
|
|
29
|
|
|
/** @var Collection $methods */ |
30
|
|
|
protected $methods; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Initializes the all properties representing a collection with a new Collection object. |
34
|
|
|
*/ |
35
|
|
|
public function __construct() |
36
|
|
|
{ |
37
|
|
|
parent::__construct(); |
38
|
|
|
|
39
|
|
|
$this->setParent(new Collection()); |
40
|
|
|
$this->setConstants(new Collection()); |
41
|
|
|
$this->setMethods(new Collection()); |
42
|
|
|
} |
43
|
|
|
|
44
|
1 |
|
public function setParent(Collection $parents) : void |
45
|
|
|
{ |
46
|
1 |
|
$this->parents = $parents; |
47
|
1 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritDoc} |
51
|
|
|
*/ |
52
|
1 |
|
public function getParent() : Collection |
53
|
|
|
{ |
54
|
1 |
|
return $this->parents; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* {@inheritDoc} |
59
|
|
|
*/ |
60
|
1 |
|
public function setConstants(Collection $constants) : void |
61
|
|
|
{ |
62
|
1 |
|
$this->constants = $constants; |
63
|
1 |
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* {@inheritDoc} |
67
|
|
|
*/ |
68
|
1 |
|
public function getConstants() : Collection |
69
|
|
|
{ |
70
|
1 |
|
return $this->constants; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* {@inheritDoc} |
75
|
|
|
*/ |
76
|
2 |
|
public function getInheritedConstants() : Collection |
77
|
|
|
{ |
78
|
2 |
|
$inheritedConstants = new Collection(); |
79
|
|
|
|
80
|
|
|
/** @var self $parent */ |
81
|
2 |
|
foreach ($this->getParent() as $parent) { |
82
|
1 |
|
if (!$parent instanceof Interfaces\InterfaceInterface) { |
83
|
1 |
|
continue; |
84
|
|
|
} |
85
|
|
|
|
86
|
1 |
|
$inheritedConstants = $inheritedConstants->merge($parent->getConstants()); |
|
|
|
|
87
|
1 |
|
$inheritedConstants = $inheritedConstants->merge($parent->getInheritedConstants()); |
88
|
|
|
} |
89
|
|
|
|
90
|
2 |
|
return $inheritedConstants; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* {@inheritDoc} |
95
|
|
|
*/ |
96
|
1 |
|
public function setMethods(Collection $methods) : void |
97
|
|
|
{ |
98
|
1 |
|
$this->methods = $methods; |
99
|
1 |
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* {@inheritDoc} |
103
|
|
|
*/ |
104
|
1 |
|
public function getMethods() : Collection |
105
|
|
|
{ |
106
|
1 |
|
return $this->methods; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* {@inheritDoc} |
111
|
|
|
*/ |
112
|
2 |
|
public function getInheritedMethods() : Collection |
113
|
|
|
{ |
114
|
2 |
|
$inheritedMethods = new Collection(); |
115
|
|
|
|
116
|
|
|
/** @var self $parent */ |
117
|
2 |
|
foreach ($this->getParent() as $parent) { |
118
|
1 |
|
if (!$parent instanceof Interfaces\InterfaceInterface) { |
119
|
|
|
continue; |
120
|
|
|
} |
121
|
|
|
|
122
|
1 |
|
$inheritedMethods = $inheritedMethods->merge($parent->getMethods()); |
|
|
|
|
123
|
1 |
|
$inheritedMethods = $inheritedMethods->merge($parent->getInheritedMethods()); |
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
126
|
2 |
|
return $inheritedMethods; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @inheritDoc |
131
|
|
|
*/ |
132
|
|
|
public function setPackage($package) : void |
133
|
|
|
{ |
134
|
|
|
parent::setPackage($package); |
135
|
|
|
|
136
|
|
|
foreach ($this->getConstants() as $constant) { |
137
|
|
|
$constant->setPackage($package); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
foreach ($this->getMethods() as $method) { |
141
|
|
|
$method->setPackage($package); |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return InterfaceDescriptor|Fqsen|null |
147
|
|
|
*/ |
148
|
|
|
public function getInheritedElement() |
149
|
|
|
{ |
150
|
|
|
return $this->getParent()->count() > 0 |
151
|
|
|
? $this->getParent()->getIterator()->current() |
|
|
|
|
152
|
|
|
: null; |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: