This commit is contained in:
as2252258@163.com
2021-09-04 17:06:05 +08:00
parent 8f919ffa1b
commit 7d26617092
6 changed files with 27 additions and 30 deletions
+5 -19
View File
@@ -68,13 +68,6 @@ class Container extends BaseObject implements ContainerInterface
];
/**
* @var array
*
* The construct parameter
*/
private array $_param = [];
/**
* @param $class
* @param array $constrict
@@ -270,10 +263,7 @@ class Container extends BaseObject implements ContainerInterface
if ($reflect->isAbstract() || $reflect->isTrait() || $reflect->isInterface()) {
return $this->_reflection[$class] = $reflect;
}
NoteManager::setPropertyNote($reflect);
NoteManager::setTargetNote($reflect);
NoteManager::setMethodNote($reflect);
$construct = $reflect->getConstructor();
$construct = NoteManager::resolveTarget($reflect);
if (!empty($construct) && $construct->getNumberOfParameters() > 0) {
$this->_constructs[$class] = $construct;
}
@@ -313,14 +303,12 @@ class Container extends BaseObject implements ContainerInterface
* @return array|null
* @throws ReflectionException
*/
public function getMethodParameters(ReflectionClass|string $class, string $method): ?array
public function getMethodParameters(string $className, string $method): ?array
{
$className = $class;
if (is_object($class)) $className = $class->getName();
if (isset($this->_parameters[$className]) && isset($this->_parameters[$className][$method])) {
return $this->_parameters[$className][$method];
}
$reflectMethod = $this->getReflectMethod($class, $method);
$reflectMethod = $this->getReflectMethod($this->getReflect($className), $method);
if (!($reflectMethod instanceof ReflectionMethod)) {
throw new ReflectionException("Class does not have a function $className::$method");
}
@@ -355,7 +343,7 @@ class Container extends BaseObject implements ContainerInterface
* @return array
* @throws ReflectionException
*/
public function resolveFunctionParameters(Closure $reflectionMethod): array
public function getFunctionParameters(Closure $reflectionMethod): array
{
return $this->resolveMethodParameters(new ReflectionFunction($reflectionMethod));
}
@@ -419,8 +407,7 @@ class Container extends BaseObject implements ContainerInterface
$class = $class::class;
}
unset(
$this->_reflection[$class], $this->_singletons[$class],
$this->_param[$class], $this->_constructs[$class]
$this->_reflection[$class], $this->_singletons[$class], $this->_constructs[$class]
);
}
@@ -431,7 +418,6 @@ class Container extends BaseObject implements ContainerInterface
{
$this->_reflection = [];
$this->_singletons = [];
$this->_param = [];
$this->_constructs = [];
return $this;
}