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