|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the Composite Utils package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Emily Shepherd <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the |
|
8
|
|
|
* LICENSE.md file that was distributed with this source code. |
|
9
|
|
|
* |
|
10
|
|
|
* @package spaark/composite-utils |
|
11
|
|
|
* @author Emily Shepherd <[email protected]> |
|
12
|
|
|
* @license MIT |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Spaark\CompositeUtils\Model\Reflection; |
|
16
|
|
|
|
|
17
|
|
|
use Spaark\CompositeUtils\Model\Collection\Map\HashMap; |
|
18
|
|
|
use Spaark\CompositeUtils\Model\Collection\Map\OrderedMap; |
|
19
|
|
|
use Spaark\CompositeUtils\Model\Collection\ListCollection\FixedList; |
|
20
|
|
|
use Spaark\CompositeUtils\Model\Collection\ListCollection\FlexibleList; |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Represents a composite class |
|
25
|
|
|
* |
|
26
|
|
|
* @property-read HashMap $properties |
|
27
|
|
|
* @property-read FixedList $requiredProperties |
|
28
|
|
|
* @property-read FixedList $optionalProperties |
|
29
|
|
|
* @property-read FixedList $builtProperties |
|
30
|
|
|
* @property-read HashMap $methods |
|
31
|
|
|
* @property-read ReflectionFile $file |
|
32
|
|
|
* @property-read NamespaceBlock $namespace |
|
33
|
|
|
* @property-read string $classname |
|
34
|
|
|
*/ |
|
35
|
|
|
class ReflectionComposite extends Reflector |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* @var ?ReflectionComposite |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $parent; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var FixedList |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $traits; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var FixedList |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $interfaces; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* The properties within the composite |
|
54
|
|
|
* |
|
55
|
|
|
* @var HashMap |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $properties; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Properties local to this composite |
|
61
|
|
|
* |
|
62
|
|
|
* @var FixedList |
|
63
|
|
|
*/ |
|
64
|
|
|
protected $localProperties; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* The properties which are required in the composite's constructor |
|
68
|
|
|
* |
|
69
|
|
|
* @var FixedList |
|
70
|
|
|
*/ |
|
71
|
|
|
protected $requiredProperties; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* The properties which can be optionally passed to the composite's |
|
75
|
|
|
* constructor |
|
76
|
|
|
* |
|
77
|
|
|
* @var FixedList |
|
78
|
|
|
*/ |
|
79
|
|
|
protected $optionalProperties; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* The properties which will be built without input in the |
|
83
|
|
|
* composite's constructor |
|
84
|
|
|
* |
|
85
|
|
|
* @var FixedList |
|
86
|
|
|
*/ |
|
87
|
|
|
protected $builtProperties; |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* The methods within the composite |
|
91
|
|
|
* |
|
92
|
|
|
* @var HashMap |
|
93
|
|
|
*/ |
|
94
|
|
|
protected $methods; |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Method local to this composite |
|
98
|
|
|
* |
|
99
|
|
|
* @var FixedList |
|
100
|
|
|
*/ |
|
101
|
|
|
protected $localMethods; |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* The file in which this composite was declared |
|
105
|
|
|
* |
|
106
|
|
|
* @var ReflectionFile |
|
107
|
|
|
*/ |
|
108
|
|
|
protected $file; |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* The namespace this composite was declared inside |
|
112
|
|
|
* |
|
113
|
|
|
* @var NamespaceBlock |
|
114
|
|
|
*/ |
|
115
|
|
|
protected $namespace; |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* The name of this composite class |
|
119
|
|
|
* |
|
120
|
|
|
* @var string |
|
121
|
|
|
*/ |
|
122
|
|
|
protected $classname; |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* The generics this class uses |
|
126
|
|
|
* |
|
127
|
|
|
* @var OrderedMap<string, AbstractType> |
|
128
|
|
|
*/ |
|
129
|
|
|
protected $generics; |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* Creates the ReflectionComposite by initializing its FixedList |
|
133
|
|
|
* properties |
|
134
|
|
|
* |
|
135
|
|
|
* As the ReflectionComposite use a requirement of the AutoConstruct |
|
136
|
|
|
* feature, this class is not able to make use of it (as it would |
|
137
|
|
|
* create an unresolvable circular dependancy) |
|
138
|
|
|
*/ |
|
139
|
22 |
|
public function __construct() |
|
140
|
|
|
{ |
|
141
|
22 |
|
$this->properties = new HashMap(); |
|
142
|
22 |
|
$this->methods = new HashMap(); |
|
143
|
22 |
|
$this->generics = |
|
144
|
22 |
|
new OrderedMap(new HashMap(), new FlexibleList()); |
|
145
|
22 |
|
} |
|
146
|
|
|
} |
|
147
|
|
|
|