ApplicationContext.php 829 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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\Context;
  12. use Psr\Container\ContainerInterface;
  13. use TypeError;
  14. class ApplicationContext
  15. {
  16. protected static ?ContainerInterface $container = null;
  17. /**
  18. * @throws TypeError
  19. */
  20. public static function getContainer(): ContainerInterface
  21. {
  22. return self::$container;
  23. }
  24. public static function hasContainer(): bool
  25. {
  26. return isset(self::$container);
  27. }
  28. public static function setContainer(ContainerInterface $container): ContainerInterface
  29. {
  30. self::$container = $container;
  31. return $container;
  32. }
  33. }