1 | <?php |
||
9 | class DI implements DIInterface |
||
10 | { |
||
11 | /** |
||
12 | * Properties |
||
13 | * |
||
14 | */ |
||
15 | public $loaded = []; // Store all lazy loaded services, ready to be instantiated |
||
16 | public $active = []; // A service is instantiated into this array, once its accessed |
||
17 | |||
18 | |||
19 | |||
20 | /** |
||
21 | * Finds an entry of the container by its identifier and returns it. |
||
22 | * |
||
23 | * @param string $service Identifier of the entry to look for. |
||
24 | * |
||
25 | * @throws NotFoundException No entry was found for this identifier. |
||
26 | * @throws Exception Error while retrieving the entry. |
||
27 | * |
||
28 | * @return mixed Entry. |
||
29 | */ |
||
30 | 2 | public function get($service) |
|
52 | |||
53 | |||
54 | |||
55 | /** |
||
56 | * Returns true if the container can return an entry for the given |
||
57 | * identifier, otherwise false |
||
58 | * |
||
59 | * @param string $service Identifier of the entry to look for. |
||
60 | * |
||
61 | * @return boolean |
||
62 | */ |
||
63 | public function has($service) |
||
69 | |||
70 | |||
71 | |||
72 | /** |
||
73 | * Set a service and connect it to a task which creates the object (lazy loading). |
||
74 | * |
||
75 | * @param string $service as a service label, naming this service. |
||
76 | * @param mixed $loader contains a pre-defined object, a string with classname or an |
||
77 | * callable which returns an instance of the service object. Its the way to |
||
78 | * actually load, insantiate, the serviceobject. |
||
79 | * @param boolean $singleton set if service is to act as singleton or not, default is false. |
||
80 | * |
||
81 | * @return nothing. |
||
|
|||
82 | */ |
||
83 | 2 | public function set($service, $loader, $singleton = false) |
|
88 | |||
89 | |||
90 | |||
91 | /** |
||
92 | * Return an arry with all loaded services names. |
||
93 | * |
||
94 | * @return void |
||
95 | */ |
||
96 | public function getServices() |
||
100 | |||
101 | |||
102 | |||
103 | /** |
||
104 | * Return an array with all loaded services that are controllers. |
||
105 | * |
||
106 | * @return void |
||
107 | */ |
||
108 | public function getControllers() |
||
117 | |||
118 | |||
119 | |||
120 | /** |
||
121 | * Return an arry with all active services names. |
||
122 | * |
||
123 | * @return void |
||
124 | */ |
||
125 | public function getActiveServices() |
||
129 | |||
130 | |||
131 | |||
132 | /** |
||
133 | * Set a singleton service and connect it to a task which creates the object (lazy loading). |
||
134 | * |
||
135 | * @param string $service as a service label, naming this service. |
||
136 | * @param mixed $loader contains a pre-defined object, a string with |
||
137 | * classname or an callable which returns an |
||
138 | * instance of the service object. Its the way |
||
139 | * to actually load, insantiate, the serviceobject. |
||
140 | * |
||
141 | * @return nothing. |
||
142 | */ |
||
143 | 1 | public function setShared($service, $loader) |
|
147 | |||
148 | |||
149 | |||
150 | /** |
||
151 | * Magic method to get and create services. |
||
152 | * When created it is also stored as a parameter of this object. |
||
153 | * |
||
154 | * @param string $service name of class property not existing. |
||
155 | * |
||
156 | * @return class as the service requested. |
||
157 | */ |
||
158 | public function __get($service) |
||
162 | |||
163 | |||
164 | |||
165 | /** |
||
166 | * Magic method to get and create services. |
||
167 | * When created it is also stored as a parameter of this object. |
||
168 | * |
||
169 | * @param string $service name of class property not existing. |
||
170 | * @param array $arguments currently NOT USED. |
||
171 | * |
||
172 | * @return class as the service requested. |
||
173 | */ |
||
174 | public function __call($service, $arguments = []) |
||
178 | |||
179 | |||
180 | |||
181 | /** |
||
182 | * Lazy load a service object and create an instance of it. |
||
183 | * |
||
184 | * @param string $service as a service label, naming this service. |
||
185 | * |
||
186 | * @return object as instance of the service object. |
||
187 | * @throws Exception when service could not be loaded. |
||
188 | */ |
||
189 | 2 | protected function load($service) |
|
219 | } |
||
220 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.