ApplicationContext.php 835 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Utils;
  12. use Psr\Container\ContainerInterface;
  13. class ApplicationContext
  14. {
  15. /**
  16. * @var null|ContainerInterface
  17. */
  18. private static $container;
  19. /**
  20. * @throws \TypeError
  21. */
  22. public static function getContainer(): ContainerInterface
  23. {
  24. return self::$container;
  25. }
  26. public static function hasContainer(): bool
  27. {
  28. return isset(self::$container);
  29. }
  30. public static function setContainer(ContainerInterface $container): ContainerInterface
  31. {
  32. self::$container = $container;
  33. return $container;
  34. }
  35. }