Container.php 4.2 KB

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