This commit is contained in:
2021-04-25 12:03:03 +08:00
parent a1bb3974cb
commit 355c02490b
+6 -4
View File
@@ -215,6 +215,9 @@ class Container extends BaseObject
*/ */
private function resolveDependencies($class): ?array private function resolveDependencies($class): ?array
{ {
if (!isset($this->_constructs[$class])) {
$this->_constructs[$class] = ['class' => $class];
}
if (isset($this->_reflection[$class])) { if (isset($this->_reflection[$class])) {
return [$this->_reflection[$class], $this->_constructs[$class] ?? []]; return [$this->_reflection[$class], $this->_constructs[$class] ?? []];
} }
@@ -223,15 +226,14 @@ class Container extends BaseObject
if (!$reflection->isInstantiable()) { if (!$reflection->isInstantiable()) {
return null; return null;
} }
$this->scanProperty($reflection); $this->scanProperty($reflection);
$this->_reflection[$class] = $reflection; $this->_reflection[$class] = $reflection;
if (!is_null($construct = $reflection->getConstructor())) { if (!is_null($construct = $reflection->getConstructor())) {
$this->_constructs[$class] = $this->resolveMethodParam($construct); $this->_constructs[$class] = array_merge($this->_constructs[$class],
$this->resolveMethodParam($construct)
);
} }
return [$reflection, $this->_constructs[$class] ?? []]; return [$reflection, $this->_constructs[$class] ?? []];
} }