From 8a4dcd847514020c39a577884831bc61be6e6c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Thu, 8 Sep 2022 11:31:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Container.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Container.php b/Container.php index 641b47f..fdffa5a 100644 --- a/Container.php +++ b/Container.php @@ -56,6 +56,14 @@ class Container implements ContainerInterface private array $_interfaces = []; + private static ?ContainerInterface $container = null; + + + private function __construct() + { + } + + /** * @param string $id * @return mixed @@ -70,6 +78,18 @@ class Container implements ContainerInterface } + /** + * @return static + */ + public static function getInstance(): static + { + if (static::$container == null) { + static::$container = new static(); + } + return static::$container; + } + + /** * @param $class * @param array $constrict