From ffd1d9e6b379fe8e357777a80c8d7b57a7fbb0ef Mon Sep 17 00:00:00 2001 From: ichynul Date: Fri, 17 Oct 2025 11:01:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20Container=20=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.php | 1 - src/Container.php | 3 +-- src/ContainerInterface.php | 39 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 src/ContainerInterface.php diff --git a/src/App.php b/src/App.php index cef71b1..3a01f64 100644 --- a/src/App.php +++ b/src/App.php @@ -27,7 +27,6 @@ use think\Model as ThinkModel; use InvalidArgumentException; use Psr\Container\ContainerExceptionInterface; -use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; use ReflectionClass; use ReflectionException; diff --git a/src/Container.php b/src/Container.php index ef39377..f722a88 100644 --- a/src/Container.php +++ b/src/Container.php @@ -2,7 +2,6 @@ namespace Webman; -use Psr\Container\ContainerInterface; use Webman\Exception\NotFoundException; use function array_key_exists; use function class_exists; @@ -75,7 +74,7 @@ public function make(string $name, array $constructor = []) * @param array $definitions * @return $this */ - public function addDefinitions(array $definitions): Container + public function addDefinitions(array $definitions): static { $this->definitions = array_merge($this->definitions, $definitions); return $this; diff --git a/src/ContainerInterface.php b/src/ContainerInterface.php new file mode 100644 index 0000000..94eaaa6 --- /dev/null +++ b/src/ContainerInterface.php @@ -0,0 +1,39 @@ + + * @copyright walkor + * @link http://www.workerman.net/ + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ + +namespace Webman; + +use Webman\Exception\NotFoundException; +use Psr\Container\ContainerInterface as PsrInterface; + +interface ContainerInterface extends PsrInterface +{ + /** + * Make. + * @param string $name + * @param array $constructor + * @return mixed + * @throws NotFoundException + */ + public function make(string $name, array $constructor = []); + + + /** + * AddDefinitions. + * @param array $definitions + * @return $this + */ + public function addDefinitions(array $definitions): static; + +}