1 | <?php |
||
11 | class Container |
||
12 | { |
||
13 | private static $instance; |
||
14 | |||
15 | /** |
||
16 | * Resolved types |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $definitions = []; |
||
20 | |||
21 | /** |
||
22 | * Globally available container |
||
23 | * |
||
24 | * @return static |
||
25 | */ |
||
26 | public static function getInstance() |
||
34 | |||
35 | /** |
||
36 | * Add item to the container |
||
37 | * @param string $alias |
||
38 | * @param mixed|null $concrete |
||
39 | */ |
||
40 | public function add($alias, $concrete = null) |
||
48 | |||
49 | /** |
||
50 | * Check if item is available in container |
||
51 | * @param string $alias |
||
52 | * @return boolean |
||
53 | */ |
||
54 | public function has($alias) |
||
62 | |||
63 | /** |
||
64 | * Get an item of the container |
||
65 | * @param string $alias |
||
66 | * @return mixed |
||
67 | */ |
||
68 | public function get($alias) |
||
72 | |||
73 | /** |
||
74 | * Call method with given parameters |
||
75 | * @param string|callable $action |
||
76 | * @param array $args |
||
77 | * @return mixed |
||
78 | */ |
||
79 | public function call ($action, array $args = []) |
||
99 | |||
100 | /** |
||
101 | * Get reflection from an action |
||
102 | * @param string $method |
||
103 | * @param string|null $class |
||
104 | * @return callable |
||
105 | */ |
||
106 | public function getActionReflection($method, $class = null) |
||
114 | |||
115 | /** |
||
116 | * Find object and set classname alias on argument list |
||
117 | * @param array $args |
||
118 | * @return array |
||
119 | */ |
||
120 | public function getParametersDictionary(array $args = []) |
||
131 | |||
132 | /** |
||
133 | * Get reflection parameters |
||
134 | * @param ReflectionFunctionAbstract $reflection |
||
135 | * @param array $args |
||
136 | * @return array |
||
137 | */ |
||
138 | public function getParameters(ReflectionFunctionAbstract $reflection, array $args = []) |
||
149 | |||
150 | /** |
||
151 | * Get paremeter value |
||
152 | * @param ReflectionParameter $parameter |
||
153 | * @param array $args |
||
154 | * @return mixed |
||
155 | */ |
||
156 | public function getParameter(ReflectionParameter $parameter, array $args = []) |
||
174 | |||
175 | /** |
||
176 | * Create a new container for asked class |
||
177 | * @param string $class |
||
178 | * @return Container |
||
179 | */ |
||
180 | public function build ($class) |
||
191 | } |