This commit is contained in:
2020-09-01 00:32:48 +08:00
parent 34cd277c25
commit e979332f01
3 changed files with 54 additions and 15 deletions
+9 -5
View File
@@ -49,11 +49,12 @@ abstract class BaseAnnotation extends Component
/**
* @param ReflectionClass $reflect
* @param string $method
* @param array $rules
* @return array
* @throws Exception
*/
public function instance($reflect, $rules = [])
public function instance($reflect, $method = '', $rules = [])
{
$annotations = $this->getPrivates($reflect);
@@ -62,11 +63,14 @@ abstract class BaseAnnotation extends Component
throw new Exception('Class ' . $reflect->getName() . ' cannot be instantiated.');
}
$object = $reflect->newInstance();
$array = [];
foreach ($classMethods as $classMethod) {
$array = $this->resolveDocComment($classMethod, $object, $annotations, $array);
$object = $reflect->newInstance();
if (!empty($method)) {
$array = $this->resolveDocComment($reflect->getMethod($method), $object, $annotations, $array);
} else {
foreach ($classMethods as $classMethod) {
$array = $this->resolveDocComment($classMethod, $object, $annotations, $array);
}
}
return $array;
}