改名
This commit is contained in:
@@ -119,6 +119,9 @@ class Annotation extends Component
|
||||
private function getReflect(string $class, string $alias): array
|
||||
{
|
||||
$reflect = $this->reflectClass($class);
|
||||
if (empty($reflect)) {
|
||||
return [];
|
||||
}
|
||||
if (!$reflect->isInstantiable()) {
|
||||
return $this->targets($reflect);
|
||||
}
|
||||
@@ -190,10 +193,10 @@ class Annotation extends Component
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @return ReflectionClass
|
||||
* @return ReflectionClass|null
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
private function reflectClass(string $class): ReflectionClass
|
||||
private function reflectClass(string $class): ?ReflectionClass
|
||||
{
|
||||
return Snowflake::getDi()->getReflect($class);
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ class Node extends HttpService
|
||||
{
|
||||
try {
|
||||
$reflect = Snowflake::getDi()->getReflect($controller);
|
||||
if (!$reflect->isInstantiable()) {
|
||||
if (empty($reflect)) {
|
||||
throw new Exception($controller . ' Class is con\'t Instantiable.');
|
||||
}
|
||||
if (!empty($action) && !$reflect->hasMethod($action)) {
|
||||
@@ -446,7 +446,6 @@ class Node extends HttpService
|
||||
*/
|
||||
private function restructure(): static
|
||||
{
|
||||
var_dump($this, 'restructure');
|
||||
if (empty($this->handler)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
+6
-23
@@ -168,6 +168,9 @@ class Container extends BaseObject
|
||||
$reflection = $this->_reflection[$class];
|
||||
} else {
|
||||
$reflection = new ReflectionClass($class);
|
||||
if (!$reflection->isInstantiable()) {
|
||||
return [];
|
||||
}
|
||||
$this->_reflection[$class] = $reflection;
|
||||
}
|
||||
$constructs = $reflection->getConstructor();
|
||||
@@ -191,37 +194,17 @@ class Container extends BaseObject
|
||||
|
||||
/**
|
||||
* @param $class
|
||||
* @return mixed
|
||||
* @return ReflectionClass|null
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function getReflect($class): ReflectionClass
|
||||
public function getReflect($class): ?ReflectionClass
|
||||
{
|
||||
if (!isset($this->_reflection[$class])) {
|
||||
$this->resolveDependencies($class);
|
||||
}
|
||||
return $this->_reflection[$class];
|
||||
return $this->_reflection[$class] ?? null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @return array
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function getAttributes(string $class): array
|
||||
{
|
||||
$reflection = $this->getReflect($class);
|
||||
$methods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
|
||||
|
||||
$classAttribute = $reflection->getAttributes();
|
||||
|
||||
foreach ($methods as $method) {
|
||||
$this->_attributes[$reflection->getName()][$method->getName()] = $method->getAttributes();
|
||||
}
|
||||
return $this->_attributes[$reflection->getName()];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $class
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user