Container.php 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. public function alias($abstract, $alias);
  22. /**
  23. * Assign a set of tags to a given binding.
  24. *
  25. * @param array|string $abstracts
  26. * @param array|mixed ...$tags
  27. * @return void
  28. */
  29. public function tag($abstracts, $tags);
  30. /**
  31. * Resolve all of the bindings for a given tag.
  32. *
  33. * @param string $tag
  34. * @return array
  35. */
  36. public function tagged($tag);
  37. /**
  38. * Register a binding with the container.
  39. *
  40. * @param string $abstract
  41. * @param \Closure|string|null $concrete
  42. * @param bool $shared
  43. * @return void
  44. */
  45. public function bind($abstract, $concrete = null, $shared = false);
  46. /**
  47. * Register a binding if it hasn't already been registered.
  48. *
  49. * @param string $abstract
  50. * @param \Closure|string|null $concrete
  51. * @param bool $shared
  52. * @return void
  53. */
  54. public function bindIf($abstract, $concrete = null, $shared = false);
  55. /**
  56. * Register a shared binding in the container.
  57. *
  58. * @param string $abstract
  59. * @param \Closure|string|null $concrete
  60. * @return void
  61. */
  62. public function singleton($abstract, $concrete = null);
  63. /**
  64. * "Extend" an abstract type in the container.
  65. *
  66. * @param string $abstract
  67. * @param \Closure $closure
  68. * @return void
  69. *
  70. * @throws \InvalidArgumentException
  71. */
  72. public function extend($abstract, Closure $closure);
  73. /**
  74. * Register an existing instance as shared in the container.
  75. *
  76. * @param string $abstract
  77. * @param mixed $instance
  78. * @return mixed
  79. */
  80. public function instance($abstract, $instance);
  81. /**
  82. * Define a contextual binding.
  83. *
  84. * @param string $concrete
  85. * @return \Illuminate\Contracts\Container\ContextualBindingBuilder
  86. */
  87. public function when($concrete);
  88. /**
  89. * Get a closure to resolve the given type from the container.
  90. *
  91. * @param string $abstract
  92. * @return \Closure
  93. */
  94. public function factory($abstract);
  95. /**
  96. * Resolve the given type from the container.
  97. *
  98. * @param string $abstract
  99. * @param array $parameters
  100. * @return mixed
  101. */
  102. public function make($abstract, array $parameters = []);
  103. /**
  104. * Call the given Closure / class@method and inject its dependencies.
  105. *
  106. * @param callable|string $callback
  107. * @param array $parameters
  108. * @param string|null $defaultMethod
  109. * @return mixed
  110. */
  111. public function call($callback, array $parameters = [], $defaultMethod = null);
  112. /**
  113. * Determine if the given abstract type has been resolved.
  114. *
  115. * @param string $abstract
  116. * @return bool
  117. */
  118. public function resolved($abstract);
  119. /**
  120. * Register a new resolving callback.
  121. *
  122. * @param \Closure|string $abstract
  123. * @param \Closure|null $callback
  124. * @return void
  125. */
  126. public function resolving($abstract, Closure $callback = null);
  127. /**
  128. * Register a new after resolving callback.
  129. *
  130. * @param \Closure|string $abstract
  131. * @param \Closure|null $callback
  132. * @return void
  133. */
  134. public function afterResolving($abstract, Closure $callback = null);
  135. }