1 | <?php |
||
10 | class Container |
||
11 | { |
||
12 | private static $instance; |
||
13 | |||
14 | /** |
||
15 | * Resolved types |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $definitions = []; |
||
19 | |||
20 | /** |
||
21 | * Globally available container |
||
22 | * |
||
23 | * @return static |
||
24 | */ |
||
25 | public static function getInstance() |
||
33 | |||
34 | /** |
||
35 | * Add item to the container |
||
36 | * @param string $alias |
||
37 | * @param mixed|null $concrete |
||
38 | */ |
||
39 | public function add($alias, $concrete = null) |
||
51 | |||
52 | /** |
||
53 | * Check if item is available in container |
||
54 | * @param string $alias |
||
55 | * @return boolean |
||
56 | */ |
||
57 | public function has($alias) |
||
65 | |||
66 | /** |
||
67 | * Get an item of the container |
||
68 | * @param string $alias |
||
69 | * @return mixed |
||
70 | */ |
||
71 | public function get($alias) |
||
75 | |||
76 | /** |
||
77 | * Call method with given parameters |
||
78 | * @param string|callable $action |
||
79 | * @param array $args |
||
80 | * @return mixed |
||
81 | */ |
||
82 | public function call ($action, array $args = []) |
||
102 | |||
103 | /** |
||
104 | * Get reflection from an action |
||
105 | * @param string $method |
||
106 | * @param string|null $class |
||
107 | * @return callable |
||
108 | */ |
||
109 | public function getActionReflection($method, $class = null) |
||
117 | |||
118 | /** |
||
119 | * Find object and set classname alias on argument list |
||
120 | * @param array $args |
||
121 | * @return array |
||
122 | */ |
||
123 | public function getParametersDictionary(array $args) |
||
134 | |||
135 | /** |
||
136 | * Get reflection parameters |
||
137 | * @param ReflectionFunctionAbstract $reflection |
||
138 | * @param array $args |
||
139 | * @return array |
||
140 | */ |
||
141 | public function getParameters(ReflectionFunctionAbstract $reflection, $args = []) |
||
166 | |||
167 | /** |
||
168 | * Create a new container for asked class |
||
169 | * @param string $class |
||
170 | * @return Container |
||
171 | */ |
||
172 | public function build ($class) |
||
183 | } |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.