|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Ray\Di; |
|
6
|
|
|
|
|
7
|
|
|
use ArrayObject; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Type definitions for Ray.Di |
|
11
|
|
|
* |
|
12
|
|
|
* @phpcs:disable SlevomatCodingStandard.Commenting.DocCommentSpacing |
|
13
|
|
|
* @template T of object |
|
14
|
|
|
* |
|
15
|
|
|
* Basic Types |
|
16
|
|
|
* @psalm-type ModuleName = non-empty-string |
|
17
|
|
|
* @psalm-type ClassName = class-string |
|
18
|
|
|
* @psalm-type InterfaceName = class-string |
|
19
|
|
|
* @psalm-type MethodName = non-empty-string |
|
20
|
|
|
* @psalm-type ParameterName = non-empty-string |
|
21
|
|
|
* @psalm-type PropertyName = non-empty-string |
|
22
|
|
|
* @psalm-type AnnotationName = non-empty-string |
|
23
|
|
|
* @psalm-type QualifierName = non-empty-string |
|
24
|
|
|
* @psalm-type BindingName = non-empty-string |
|
25
|
|
|
* @psalm-type ScopeName = 'Singleton'|'Prototype' |
|
26
|
|
|
* @psalm-type InstanceId = positive-int |
|
27
|
|
|
* @psalm-type ScriptDir = non-empty-string |
|
28
|
|
|
* @psalm-type DependencyChain = non-empty-string |
|
29
|
|
|
* @psalm-type Name = ''|non-empty-string |
|
30
|
|
|
* |
|
31
|
|
|
* Dependency Types |
|
32
|
|
|
* @psalm-type ArgumentList = array<int, Argument> |
|
33
|
|
|
* @psalm-type SetterMethodList = array<SetterMethod> |
|
34
|
|
|
* @psalm-type DependencyParams = array<int, mixed> |
|
35
|
|
|
* @psalm-type ConstructorParameter = array{ |
|
36
|
|
|
* name: ParameterName, |
|
37
|
|
|
* type: class-string, |
|
38
|
|
|
* defaultValue?: mixed, |
|
39
|
|
|
* qualifiers?: list<QualifierName>, |
|
40
|
|
|
* isOptional: bool |
|
41
|
|
|
* } |
|
42
|
|
|
* @psalm-type ConstructorParameters = array<ParameterName, ConstructorParameter> |
|
43
|
|
|
* @psalm-type ConstructorArguments = array<ParameterName, mixed> |
|
44
|
|
|
* |
|
45
|
|
|
* Binding Types |
|
46
|
|
|
* @psalm-type BindingDefinition = array{ |
|
47
|
|
|
* interface: InterfaceName, |
|
48
|
|
|
* target: ClassName, |
|
49
|
|
|
* scope: ScopeName, |
|
50
|
|
|
* qualifiers?: list<QualifierName>, |
|
51
|
|
|
* parameters?: ConstructorParameters, |
|
52
|
|
|
* postConstruct?: MethodName |
|
53
|
|
|
* } |
|
54
|
|
|
* @psalm-type BindingMap = array<InterfaceName, BindingDefinition> |
|
55
|
|
|
* @psalm-type ScopeBindings = array<ScopeName, array<InstanceId, object>> |
|
56
|
|
|
* @psalm-type ContainerArray = array<string, DependencyInterface> |
|
57
|
|
|
* |
|
58
|
|
|
* Multi Binding Types |
|
59
|
|
|
* @psalm-type LazyMap = array<string, non-empty-array<array-key, LazyInterface>> |
|
60
|
|
|
* @psalm-type MultiBindingsList = array<string, LazyInterface> |
|
61
|
|
|
* @psalm-type MapProviders = array<string, ProviderInterface> |
|
62
|
|
|
* @psalm-type ContextualBinding = array{ |
|
63
|
|
|
* interface: InterfaceName, |
|
64
|
|
|
* qualifier: QualifierName, |
|
65
|
|
|
* context: ClassName |
|
66
|
|
|
* } |
|
67
|
|
|
* |
|
68
|
|
|
* Provider Types |
|
69
|
|
|
* @psalm-type ProviderClassName = class-string<ProviderInterface> |
|
70
|
|
|
* @psalm-type ProviderParams = array<ParameterName, mixed> |
|
71
|
|
|
* @psalm-type ProviderDefinition = array{ |
|
72
|
|
|
* class: ProviderClassName, |
|
73
|
|
|
* params: ProviderParams, |
|
74
|
|
|
* context?: array<ParameterName, mixed> |
|
75
|
|
|
* } |
|
76
|
|
|
* |
|
77
|
|
|
* Injection Types |
|
78
|
|
|
* @psalm-type InjectionPoint = array{ |
|
79
|
|
|
* class: ClassName, |
|
80
|
|
|
* method: MethodName, |
|
81
|
|
|
* parameter: ParameterName, |
|
82
|
|
|
* position: positive-int, |
|
83
|
|
|
* type: class-string, |
|
84
|
|
|
* isOptional: bool |
|
85
|
|
|
* } |
|
86
|
|
|
* @psalm-type InjectionPoints = array<MethodName, list<InjectionPoint>> |
|
87
|
|
|
* @psalm-type SetterInjection = array{ |
|
88
|
|
|
* method: MethodName, |
|
89
|
|
|
* parameters: list<InjectionPoint> |
|
90
|
|
|
* } |
|
91
|
|
|
* @psalm-type PropertyInjection = array{ |
|
92
|
|
|
* property: PropertyName, |
|
93
|
|
|
* type: class-string, |
|
94
|
|
|
* qualifier?: QualifierName |
|
95
|
|
|
* } |
|
96
|
|
|
* @psalm-type QualifierAnnotations = array<object> |
|
97
|
|
|
* |
|
98
|
|
|
* Container Types |
|
99
|
|
|
* @psalm-type PointcutList = array<int, Pointcut> |
|
100
|
|
|
* @psalm-type ModuleConfig = array{ |
|
101
|
|
|
* container: ContainerArray, |
|
102
|
|
|
* pointcuts: PointcutList, |
|
103
|
|
|
* multiBindings: MultiBindingsList |
|
104
|
|
|
* } |
|
105
|
|
|
* |
|
106
|
|
|
* Cache Types |
|
107
|
|
|
* @psalm-type CacheKey = non-empty-string |
|
108
|
|
|
* @psalm-type CacheEntry = array{ |
|
109
|
|
|
* bindings: BindingMap, |
|
110
|
|
|
* scopes: ScopeBindings, |
|
111
|
|
|
* timestamp: int, |
|
112
|
|
|
* version: non-empty-string |
|
113
|
|
|
* } |
|
114
|
|
|
* @psalm-type ScriptCache = array<CacheKey, string> |
|
115
|
|
|
* @psalm-type CompilationCache = array<ClassName, string> |
|
116
|
|
|
* |
|
117
|
|
|
* Error Types |
|
118
|
|
|
* @psalm-type UnboundTrace = list<array{ |
|
119
|
|
|
* class: ClassName, |
|
120
|
|
|
* parameter: ParameterName, |
|
121
|
|
|
* method: MethodName, |
|
122
|
|
|
* type: class-string, |
|
123
|
|
|
* dependencyChain: DependencyChain |
|
124
|
|
|
}> |
|
125
|
|
|
* @psalm-type CircularDependencyTrace = list<array{ |
|
126
|
|
|
* class: ClassName, |
|
127
|
|
|
* dependency: ClassName, |
|
128
|
|
|
* path: list<ClassName> |
|
129
|
|
|
}> |
|
130
|
|
|
* |
|
131
|
|
|
* Instance Management |
|
132
|
|
|
* @psalm-type SingletonInstances = array<InstanceId, object> |
|
133
|
|
|
* @psalm-type PrototypeInstances = array<InstanceId, object> |
|
134
|
|
|
* @psalm-type InjectionPointInstances = array<InstanceId, InjectionPointInterface> |
|
135
|
|
|
* @psalm-type InstanceRegistry = array{ |
|
136
|
|
|
* singletons: SingletonInstances, |
|
137
|
|
|
* prototypes: PrototypeInstances, |
|
138
|
|
|
* injectionPoints: InjectionPointInstances |
|
139
|
|
|
* } |
|
140
|
|
|
* |
|
141
|
|
|
* Named Binding Types |
|
142
|
|
|
* @psalm-type NamedParams = array<string, string> |
|
143
|
|
|
* @psalm-type NamedBinding = array{ |
|
144
|
|
|
* name: Name, |
|
145
|
|
|
* names: NamedParams |
|
146
|
|
|
* } |
|
147
|
|
|
* @psalm-type NameKeyVarPair = array{ |
|
148
|
|
|
* key: string, |
|
149
|
|
|
* var: string |
|
150
|
|
|
* } |
|
151
|
|
|
* @phpcs:enable |
|
152
|
|
|
*/ |
|
153
|
|
|
final class Types |
|
154
|
|
|
{ |
|
155
|
|
|
/** @codeCoverageIgnore */ |
|
156
|
|
|
private function __construct() |
|
157
|
|
|
{ |
|
158
|
|
|
} |
|
159
|
|
|
} |
|
160
|
|
|
|