blob: 1b8bb6407934ac0e5424a62e462b921e085e0986 [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3namespace Illuminate\Contracts\Container;
4
5use Closure;
6use Psr\Container\ContainerInterface;
7
8interface Container extends ContainerInterface
9{
10 /**
11 * Determine if the given abstract type has been bound.
12 *
13 * @param string $abstract
14 * @return bool
15 */
16 public function bound($abstract);
17
18 /**
19 * Alias a type to a different name.
20 *
21 * @param string $abstract
22 * @param string $alias
23 * @return void
24 *
25 * @throws \LogicException
26 */
27 public function alias($abstract, $alias);
28
29 /**
30 * Assign a set of tags to a given binding.
31 *
32 * @param array|string $abstracts
33 * @param array|mixed ...$tags
34 * @return void
35 */
36 public function tag($abstracts, $tags);
37
38 /**
39 * Resolve all of the bindings for a given tag.
40 *
41 * @param string $tag
42 * @return iterable
43 */
44 public function tagged($tag);
45
46 /**
47 * Register a binding with the container.
48 *
49 * @param string $abstract
50 * @param \Closure|string|null $concrete
51 * @param bool $shared
52 * @return void
53 */
54 public function bind($abstract, $concrete = null, $shared = false);
55
56 /**
57 * Register a binding if it hasn't already been registered.
58 *
59 * @param string $abstract
60 * @param \Closure|string|null $concrete
61 * @param bool $shared
62 * @return void
63 */
64 public function bindIf($abstract, $concrete = null, $shared = false);
65
66 /**
67 * Register a shared binding in the container.
68 *
69 * @param string $abstract
70 * @param \Closure|string|null $concrete
71 * @return void
72 */
73 public function singleton($abstract, $concrete = null);
74
75 /**
76 * Register a shared binding if it hasn't already been registered.
77 *
78 * @param string $abstract
79 * @param \Closure|string|null $concrete
80 * @return void
81 */
82 public function singletonIf($abstract, $concrete = null);
83
84 /**
85 * "Extend" an abstract type in the container.
86 *
87 * @param string $abstract
88 * @param \Closure $closure
89 * @return void
90 *
91 * @throws \InvalidArgumentException
92 */
93 public function extend($abstract, Closure $closure);
94
95 /**
96 * Register an existing instance as shared in the container.
97 *
98 * @param string $abstract
99 * @param mixed $instance
100 * @return mixed
101 */
102 public function instance($abstract, $instance);
103
104 /**
105 * Add a contextual binding to the container.
106 *
107 * @param string $concrete
108 * @param string $abstract
109 * @param \Closure|string $implementation
110 * @return void
111 */
112 public function addContextualBinding($concrete, $abstract, $implementation);
113
114 /**
115 * Define a contextual binding.
116 *
117 * @param string|array $concrete
118 * @return \Illuminate\Contracts\Container\ContextualBindingBuilder
119 */
120 public function when($concrete);
121
122 /**
123 * Get a closure to resolve the given type from the container.
124 *
125 * @param string $abstract
126 * @return \Closure
127 */
128 public function factory($abstract);
129
130 /**
131 * Flush the container of all bindings and resolved instances.
132 *
133 * @return void
134 */
135 public function flush();
136
137 /**
138 * Resolve the given type from the container.
139 *
140 * @param string $abstract
141 * @param array $parameters
142 * @return mixed
143 *
144 * @throws \Illuminate\Contracts\Container\BindingResolutionException
145 */
146 public function make($abstract, array $parameters = []);
147
148 /**
149 * Call the given Closure / class@method and inject its dependencies.
150 *
151 * @param callable|string $callback
152 * @param array $parameters
153 * @param string|null $defaultMethod
154 * @return mixed
155 */
156 public function call($callback, array $parameters = [], $defaultMethod = null);
157
158 /**
159 * Determine if the given abstract type has been resolved.
160 *
161 * @param string $abstract
162 * @return bool
163 */
164 public function resolved($abstract);
165
166 /**
167 * Register a new resolving callback.
168 *
169 * @param \Closure|string $abstract
170 * @param \Closure|null $callback
171 * @return void
172 */
173 public function resolving($abstract, Closure $callback = null);
174
175 /**
176 * Register a new after resolving callback.
177 *
178 * @param \Closure|string $abstract
179 * @param \Closure|null $callback
180 * @return void
181 */
182 public function afterResolving($abstract, Closure $callback = null);
183}