|
| 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 | + /** |
| 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 | + /** |
| 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 | + * @template T |
| 159 | + * @param class-string<T> $abstract |
| 160 | + * @param array $parameters |
| 161 | + * @return T |
| 162 | + * |
| 163 | + * @throws \Illuminate\Contracts\Container\BindingResolutionException |
| 164 | + */ |
| 165 | + public function make($abstract, array $parameters = []); |
| 166 | + |
| 167 | + /** |
| 168 | + * Call the given Closure / class@method and inject its dependencies. |
| 169 | + * |
| 170 | + * @param callable|string $callback |
| 171 | + * @param array $parameters |
| 172 | + * @param string|null $defaultMethod |
| 173 | + * @return mixed |
| 174 | + */ |
| 175 | + public function call($callback, array $parameters = [], $defaultMethod = null); |
| 176 | + |
| 177 | + /** |
| 178 | + * Determine if the given abstract type has been resolved. |
| 179 | + * |
| 180 | + * @param string $abstract |
| 181 | + * @return bool |
| 182 | + */ |
| 183 | + public function resolved($abstract); |
| 184 | + |
| 185 | + /** |
| 186 | + * Register a new before resolving callback. |
| 187 | + * |
| 188 | + * @param \Closure|string $abstract |
| 189 | + * @param \Closure|null $callback |
| 190 | + * @return void |
| 191 | + */ |
| 192 | + public function beforeResolving($abstract, Closure $callback = null); |
| 193 | + |
| 194 | + /** |
| 195 | + * Register a new resolving callback. |
| 196 | + * |
| 197 | + * @param \Closure|string $abstract |
| 198 | + * @param \Closure|null $callback |
| 199 | + * @return void |
| 200 | + */ |
| 201 | + public function resolving($abstract, Closure $callback = null); |
| 202 | + |
| 203 | + /** |
| 204 | + * Register a new after resolving callback. |
| 205 | + * |
| 206 | + * @param \Closure|string $abstract |
| 207 | + * @param \Closure|null $callback |
| 208 | + * @return void |
| 209 | + */ |
| 210 | + public function afterResolving($abstract, Closure $callback = null); |
| 211 | +} |
0 commit comments