This commit is contained in:
2020-12-15 17:08:35 +08:00
parent c36c0e05ad
commit 2f6f9a640a
+5 -8
View File
@@ -82,11 +82,7 @@ class Annotation extends Component
$explode_pop = array_pop($explode); $explode_pop = array_pop($explode);
if (is_file($path)) { if (is_file($path)) {
$explode_pop = str_replace('.php', '', $explode_pop); $explode_pop = str_replace('.php', '', $explode_pop);
$annotation = $this->getReflect($namespace . '\\' . $explode_pop); $this->getReflect($namespace . '\\' . $explode_pop, $alias);
if (count($annotation) < 1) {
continue;
}
$this->_annotations[$alias][] = $annotation;
} else { } else {
$this->scanDir(glob($path . '/*'), $namespace . '\\' . $explode_pop, $alias); $this->scanDir(glob($path . '/*'), $namespace . '\\' . $explode_pop, $alias);
} }
@@ -96,11 +92,12 @@ class Annotation extends Component
/** /**
* @param $class * @param string $class
* @param string $alias
* @return array * @return array
* @throws ReflectionException * @throws ReflectionException
*/ */
private function getReflect($class): array private function getReflect(string $class, string $alias): array
{ {
$reflect = Snowflake::getDi()->getReflect($class); $reflect = Snowflake::getDi()->getReflect($class);
if (!$reflect->isInstantiable()) { if (!$reflect->isInstantiable()) {
@@ -124,7 +121,7 @@ class Annotation extends Component
$tmp['handler'] = [$object, $method->getName()]; $tmp['handler'] = [$object, $method->getName()];
$tmp['attributes'] = $names; $tmp['attributes'] = $names;
$annotations[] = $tmp; $this->_annotations[$alias][] = $tmp;
} }
return $annotations; return $annotations;
} }