This commit is contained in:
as2252258@163.com
2021-08-29 05:53:47 +08:00
parent 1cb1b0b9cb
commit c06f25fcf5
16 changed files with 152 additions and 205 deletions
+3 -33
View File
@@ -33,7 +33,7 @@ trait Attributes
continue;
}
$instance = $this->format_annotation($attribute);
$instance = $attribute->newInstance();
$this->_classTarget[$className][] = $instance;
@@ -120,7 +120,7 @@ trait Attributes
if (!class_exists($attribute->getName())) {
continue;
}
$instance = $this->format_annotation($attribute);
$instance = $attribute->newInstance();
$this->_classMethodNote[$className][$ReflectionMethod->getName()][] = $instance;
@@ -166,7 +166,7 @@ trait Attributes
continue;
}
$instance = $this->format_annotation($attribute);
$instance = $attribute->newInstance();
$this->_classPropertyNote[$className][$ReflectionMethod->getName()] = $instance;
@@ -176,36 +176,6 @@ trait Attributes
}
/**
* @param \ReflectionAttribute $attribute
* @return array
* @throws \ReflectionException
*/
private function format_annotation(ReflectionAttribute $attribute)
{
$reflection_class = new ReflectionClass($attribute->getName());
$argument = $attribute->getArguments();
$array = ['class' => $attribute->getName(), 'params' => []];
foreach ($reflection_class->getConstructor()->getParameters() as $key => $parameter) {
if (isset($argument[$parameter->getName()])) {
$array['params'][$parameter->getName()] = $argument[$parameter->getName()];
} else {
if (!isset($argument[$key])) {
$array['params'][$parameter->getName()] = $parameter->getDefaultValue();
} else {
$array['params'][$parameter->getName()] = $argument[$key];
}
}
}
unset($reflection_class);
return $array;
}
/**
* @param string $attribute
* @param string|null $class