This commit is contained in:
as2252258@163.com
2021-02-23 01:44:40 +08:00
parent b62d25e112
commit 1b2504883f
+7 -8
View File
@@ -95,20 +95,19 @@ class Container extends BaseObject
if (!$reflect->isInstantiable()) { if (!$reflect->isInstantiable()) {
throw new NotFindClassException($reflect->getName()); throw new NotFindClassException($reflect->getName());
} }
if (empty($config)) {
return $reflect->newInstanceArgs($dependencies ?? []);
}
$dependencies = $this->_constructs[$class] ?? null; $dependencies = $this->_constructs[$class] ?? [];
if (empty($config)) {
return $reflect->newInstanceArgs($dependencies);
}
$this->_param[$class] = $config;
if (!empty($dependencies) && $reflect->implementsInterface('Snowflake\Abstracts\Configure')) { if (!empty($dependencies) && $reflect->implementsInterface('Snowflake\Abstracts\Configure')) {
$dependencies[count($dependencies) - 1] = $config; $dependencies[count($dependencies) - 1] = $config;
return $reflect->newInstanceArgs($dependencies); return $reflect->newInstanceArgs($dependencies);
} }
$this->_param[$class] = $config; return $this->onAfterInit($reflect->newInstanceArgs($dependencies), $config);
$object = !is_null($dependencies) ? $reflect->newInstanceArgs($dependencies) : $reflect->newInstance();
return $this->onAfterInit($object, $config);
} }
/** /**