From 291ad9870df5ff3a2811f6f238bab43dbb7375db Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Sun, 2 May 2021 04:18:06 +0800 Subject: [PATCH] modify --- Annotation/Loader.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Annotation/Loader.php b/Annotation/Loader.php index 1d696581..6224f36e 100644 --- a/Annotation/Loader.php +++ b/Annotation/Loader.php @@ -179,7 +179,7 @@ class Loader extends BaseObject } $this->appendFileToDirectory($path->getRealPath(), $replace->getName()); - $_array = ['handler' => $replace->getName(), 'target' => [], 'methods' => [], 'property' => []]; + $_array = ['handler' => $replace->newInstance(), 'target' => [], 'methods' => [], 'property' => []]; foreach ($replace->getAttributes() as $attribute) { if ($attribute->getName() == Attribute::class) { continue; @@ -401,22 +401,21 @@ class Loader extends BaseObject if ($annotations === null) { continue; } - - $target = new $annotations['handler'](); foreach ($annotations['target'] ?? [] as $value) { - $value->execute([$target]); + $value->execute([$annotations['handler']]); } + $_className = $annotations['handler']::class; foreach ($annotations['methods'] as $name => $attribute) { foreach ($attribute as $value) { if ($value instanceof Relation) { - $annotation->addRelate($target::class, $value->name, $name); + $annotation->addRelate($_className, $value->name, $name); } else if ($value instanceof Get) { - $annotation->addGets($target::class, $value->name, $name); + $annotation->addGets($_className, $value->name, $name); } else if ($value instanceof Set) { - $annotation->addSets($target::class, $value->name, $name); + $annotation->addSets($_className, $value->name, $name); } else { - $value->execute([$target, $name]); + $value->execute([$annotations['handler'], $name]); } } }