1 | <?php |
||
22 | trait ContainerTrait |
||
23 | { |
||
24 | use ScopeTrait, FactoryAwareTrait; |
||
25 | |||
26 | /** |
||
27 | * instances pool |
||
28 | * |
||
29 | * @var object[] |
||
30 | * @access protected |
||
31 | */ |
||
32 | protected $pool = []; |
||
33 | |||
34 | /** |
||
35 | * for loop detection |
||
36 | * |
||
37 | * @var array |
||
38 | * @access protected |
||
39 | */ |
||
40 | protected $loop = []; |
||
41 | |||
42 | /** |
||
43 | * @var int |
||
44 | * @access protected |
||
45 | */ |
||
46 | protected $counter = 0; |
||
47 | |||
48 | /** |
||
49 | * execute init methods defined in 'di.init' node |
||
50 | * |
||
51 | * @return $this |
||
52 | * @throws RuntimeException if anything goes wrong |
||
53 | * @access protected |
||
54 | */ |
||
55 | protected function initContainer() |
||
64 | |||
65 | /** |
||
66 | * Get the instance either from the pool or create it |
||
67 | * |
||
68 | * @param string $id service id with or without the scope |
||
69 | * @param array $args arguments for the constructor |
||
70 | * @return object |
||
71 | * @throws LogicException if instantiation goes wrong |
||
72 | * @throws RuntimeException if method execution goes wrong |
||
73 | * @access protected |
||
74 | */ |
||
75 | protected function getInstance(/*# string */ $id, array $args) |
||
92 | |||
93 | /** |
||
94 | * Full scope info with consideration of ancestor instances |
||
95 | * |
||
96 | * @param string $id |
||
97 | * @return array |
||
98 | * @access protected |
||
99 | */ |
||
100 | protected function realScopeInfo(/*# string */ $id)/*# : array */ |
||
111 | |||
112 | /** |
||
113 | * Create the instance with loop detection |
||
114 | * |
||
115 | * Loop: an instance depends on itself in the creation chain. |
||
116 | * |
||
117 | * @param string $rawId |
||
118 | * @param array $args arguments for the constructor if any |
||
119 | * @return object |
||
120 | * @throws LogicException if instantiation goes wrong or loop detected |
||
121 | * @access protected |
||
122 | */ |
||
123 | protected function createInstance(/*# string */ $rawId, array $args = []) |
||
141 | } |
||
142 |