ServiceProviderInterface.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Contracts\Service;
  11. use Psr\Container\ContainerInterface;
  12. /**
  13. * A ServiceProviderInterface exposes the identifiers and the types of services provided by a container.
  14. *
  15. * @author Nicolas Grekas <p@tchwork.com>
  16. * @author Mateusz Sip <mateusz.sip@gmail.com>
  17. *
  18. * @template-covariant T of mixed
  19. */
  20. interface ServiceProviderInterface extends ContainerInterface
  21. {
  22. /**
  23. * @return T
  24. * @param string $id
  25. */
  26. public function get($id);
  27. /**
  28. * @param string $id
  29. */
  30. public function has($id);
  31. /**
  32. * Returns an associative array of service types keyed by the identifiers provided by the current container.
  33. *
  34. * Examples:
  35. *
  36. * * ['logger' => 'Psr\Log\LoggerInterface'] means the object provides a service named "logger" that implements Psr\Log\LoggerInterface
  37. * * ['foo' => '?'] means the container provides service name "foo" of unspecified type
  38. * * ['bar' => '?Bar\Baz'] means the container provides a service "bar" of type Bar\Baz|null
  39. *
  40. * @return string[] The provided service types, keyed by service names
  41. */
  42. public function getProvidedServices();
  43. }