This commit is contained in:
2021-02-22 17:57:56 +08:00
parent feb3262436
commit 55cc450185
+14 -3
View File
@@ -162,16 +162,27 @@ class Annotation extends Component
{ {
$property = $reflectionClass->getProperties(); $property = $reflectionClass->getProperties();
foreach ($property as $value) { foreach ($property as $value) {
if ($value->isStatic()) continue;
$attributes = $value->getAttributes(); $attributes = $value->getAttributes();
if (count($attributes) < 1) { if (count($attributes) < 1) {
continue; continue;
} }
foreach ($attributes as $attribute) { foreach ($attributes as $attribute) {
$attribute = $this->instance($attribute); /** @var IAnnotation $annotation */
if (empty($attribute)) { $annotation = $this->instance($attribute);
if (empty($annotation)) {
continue; continue;
} }
$value->setValue($attribute->execute([$object, $value->getName()])); $annotation = $annotation->execute([$object, $value->getName()]);
if ($value->isPublic()) {
$object->{$value->getName()} = $annotation;
} else {
$name = 'set' . ucfirst($value->getName());
if (!method_exists($object, $name)) {
throw new NotFindPropertyException('set property need method ' . $name);
}
$object->$name($annotation);
}
} }
} }
} }