Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | namespace Illuminate\Contracts\Container; |
| 4 | |
| 5 | use Closure; |
| 6 | use Psr\Container\ContainerInterface; |
| 7 | |
| 8 | interface 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 | /** |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame^] | 85 | * Register a scoped binding in the container. |
| 86 | * |
| 87 | * @param string $abstract |
| 88 | * @param \Closure|string|null $concrete |
| 89 | * @return void |
| 90 | */ |
| 91 | public function scoped($abstract, $concrete = null); |
| 92 | |
| 93 | /** |
| 94 | * Register a scoped binding if it hasn't already been registered. |
| 95 | * |
| 96 | * @param string $abstract |
| 97 | * @param \Closure|string|null $concrete |
| 98 | * @return void |
| 99 | */ |
| 100 | public function scopedIf($abstract, $concrete = null); |
| 101 | |
| 102 | /** |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 103 | * "Extend" an abstract type in the container. |
| 104 | * |
| 105 | * @param string $abstract |
| 106 | * @param \Closure $closure |
| 107 | * @return void |
| 108 | * |
| 109 | * @throws \InvalidArgumentException |
| 110 | */ |
| 111 | public function extend($abstract, Closure $closure); |
| 112 | |
| 113 | /** |
| 114 | * Register an existing instance as shared in the container. |
| 115 | * |
| 116 | * @param string $abstract |
| 117 | * @param mixed $instance |
| 118 | * @return mixed |
| 119 | */ |
| 120 | public function instance($abstract, $instance); |
| 121 | |
| 122 | /** |
| 123 | * Add a contextual binding to the container. |
| 124 | * |
| 125 | * @param string $concrete |
| 126 | * @param string $abstract |
| 127 | * @param \Closure|string $implementation |
| 128 | * @return void |
| 129 | */ |
| 130 | public function addContextualBinding($concrete, $abstract, $implementation); |
| 131 | |
| 132 | /** |
| 133 | * Define a contextual binding. |
| 134 | * |
| 135 | * @param string|array $concrete |
| 136 | * @return \Illuminate\Contracts\Container\ContextualBindingBuilder |
| 137 | */ |
| 138 | public function when($concrete); |
| 139 | |
| 140 | /** |
| 141 | * Get a closure to resolve the given type from the container. |
| 142 | * |
| 143 | * @param string $abstract |
| 144 | * @return \Closure |
| 145 | */ |
| 146 | public function factory($abstract); |
| 147 | |
| 148 | /** |
| 149 | * Flush the container of all bindings and resolved instances. |
| 150 | * |
| 151 | * @return void |
| 152 | */ |
| 153 | public function flush(); |
| 154 | |
| 155 | /** |
| 156 | * Resolve the given type from the container. |
| 157 | * |
| 158 | * @param string $abstract |
| 159 | * @param array $parameters |
| 160 | * @return mixed |
| 161 | * |
| 162 | * @throws \Illuminate\Contracts\Container\BindingResolutionException |
| 163 | */ |
| 164 | public function make($abstract, array $parameters = []); |
| 165 | |
| 166 | /** |
| 167 | * Call the given Closure / class@method and inject its dependencies. |
| 168 | * |
| 169 | * @param callable|string $callback |
| 170 | * @param array $parameters |
| 171 | * @param string|null $defaultMethod |
| 172 | * @return mixed |
| 173 | */ |
| 174 | public function call($callback, array $parameters = [], $defaultMethod = null); |
| 175 | |
| 176 | /** |
| 177 | * Determine if the given abstract type has been resolved. |
| 178 | * |
| 179 | * @param string $abstract |
| 180 | * @return bool |
| 181 | */ |
| 182 | public function resolved($abstract); |
| 183 | |
| 184 | /** |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame^] | 185 | * Register a new before resolving callback. |
| 186 | * |
| 187 | * @param \Closure|string $abstract |
| 188 | * @param \Closure|null $callback |
| 189 | * @return void |
| 190 | */ |
| 191 | public function beforeResolving($abstract, Closure $callback = null); |
| 192 | |
| 193 | /** |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 194 | * Register a new resolving callback. |
| 195 | * |
| 196 | * @param \Closure|string $abstract |
| 197 | * @param \Closure|null $callback |
| 198 | * @return void |
| 199 | */ |
| 200 | public function resolving($abstract, Closure $callback = null); |
| 201 | |
| 202 | /** |
| 203 | * Register a new after resolving callback. |
| 204 | * |
| 205 | * @param \Closure|string $abstract |
| 206 | * @param \Closure|null $callback |
| 207 | * @return void |
| 208 | */ |
| 209 | public function afterResolving($abstract, Closure $callback = null); |
| 210 | } |