改名
This commit is contained in:
+9
-18
@@ -71,7 +71,7 @@ class Container extends BaseObject
|
|||||||
public function get($class, $constrict = [], $config = []): mixed
|
public function get($class, $constrict = [], $config = []): mixed
|
||||||
{
|
{
|
||||||
if (isset($this->_singletons[$class])) {
|
if (isset($this->_singletons[$class])) {
|
||||||
return clone $this->_singletons[$class];
|
return $this->_singletons[$class];
|
||||||
} else if (!isset($this->_constructs[$class])) {
|
} else if (!isset($this->_constructs[$class])) {
|
||||||
return $this->resolve($class, $constrict, $config);
|
return $this->resolve($class, $constrict, $config);
|
||||||
}
|
}
|
||||||
@@ -230,26 +230,17 @@ class Container extends BaseObject
|
|||||||
*/
|
*/
|
||||||
private function resolveDependencies($class): ?array
|
private function resolveDependencies($class): ?array
|
||||||
{
|
{
|
||||||
if (!isset($this->_constructs[$class])) {
|
if (!isset($this->_reflection[$class])) {
|
||||||
$this->_constructs[$class] = ['class' => $class];
|
$this->_reflection[$class] = new ReflectionClass($class);
|
||||||
}
|
if (!$this->_reflection[$class]->isInstantiable()) {
|
||||||
if (isset($this->_reflection[$class])) {
|
|
||||||
return [$this->_reflection[$class], $this->_constructs[$class] ?? []];
|
|
||||||
}
|
|
||||||
|
|
||||||
$reflection = new ReflectionClass($class);
|
|
||||||
if (!$reflection->isInstantiable()) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$this->scanProperty($reflection);
|
$this->scanProperty($this->_reflection[$class]);
|
||||||
|
|
||||||
$this->_reflection[$class] = $reflection;
|
|
||||||
if (!is_null($construct = $reflection->getConstructor())) {
|
|
||||||
$this->_constructs[$class] = array_merge($this->_constructs[$class],
|
|
||||||
$this->resolveMethodParam($construct)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return [$reflection, $this->_constructs[$class] ?? []];
|
if (!is_null($constructs = $this->_reflection[$class]->getConstructor())) {
|
||||||
|
$constructs = $this->resolveMethodParam($constructs);
|
||||||
|
}
|
||||||
|
return [$this->_reflection[$class], $constructs];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user