From e787bb235188a4a42e5752a29cd330ceabf86f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 3 Aug 2021 18:26:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Abstracts/BaseObject.php | 2 -- System/Di/Container.php | 21 ++++----------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/System/Abstracts/BaseObject.php b/System/Abstracts/BaseObject.php index f90770e7..96a33a1e 100644 --- a/System/Abstracts/BaseObject.php +++ b/System/Abstracts/BaseObject.php @@ -18,7 +18,6 @@ use Swoole\Coroutine; /** * Class BaseObject * @package Snowflake\Snowflake\Base - * @method afterInit */ class BaseObject implements Configure { @@ -34,7 +33,6 @@ class BaseObject implements Configure if (!empty($config) && is_array($config)) { Snowflake::configure($this, $config); } - $this->init(); } diff --git a/System/Di/Container.php b/System/Di/Container.php index 3628dac3..d54680a3 100644 --- a/System/Di/Container.php +++ b/System/Di/Container.php @@ -11,7 +11,6 @@ namespace Snowflake\Di; use Annotation\Inject; use Exception; -use JetBrains\PhpStorm\Pure; use ReflectionClass; use ReflectionException; use ReflectionFunction; @@ -109,22 +108,10 @@ class Container extends BaseObject { $reflect = $this->resolveDependencies($class); - $object = $this->setConfig($config, $reflect, $constrict); + $object = $this->newInstance($reflect, $constrict); - return $this->propertyInject($reflect, $object); - } + $this->propertyInject($reflect, $object); - /** - * @param $config - * @param $reflect - * @param $dependencies - * @return object - * @throws NotFindClassException - * @throws ReflectionException - */ - private function setConfig($config, $reflect, $dependencies): object - { - $object = $this->newInstance($reflect, $dependencies); return $this->onAfterInit($object, $config); } @@ -213,8 +200,8 @@ class Container extends BaseObject private function onAfterInit($object, $config): mixed { Snowflake::configure($object, $config); - if (method_exists($object, 'afterInit')) { - call_user_func([$object, 'afterInit']); + if (method_exists($object, 'init')) { + call_user_func([$object, 'init']); } return $object; }