From 791f9722f527f193fe26b889fe001c5e71012c00 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Tue, 4 May 2021 03:45:23 +0800 Subject: [PATCH] modify --- Annotation/Loader.php | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/Annotation/Loader.php b/Annotation/Loader.php index a7e42c8c..33acc451 100644 --- a/Annotation/Loader.php +++ b/Annotation/Loader.php @@ -169,7 +169,7 @@ class Loader extends BaseObject } $this->appendFileToDirectory($path->getRealPath(), $replace->getName()); - $_array['handler'] = $replace->getName(); + $_array['handler'] = $replace->newInstance(); $_array['target'] = []; $_array['methods'] = []; $_array['property'] = []; @@ -349,38 +349,24 @@ class Loader extends BaseObject continue; } - $class = $this->newInstance($annotations['handler']); /** @var \Annotation\Attribute $value */ foreach ($annotations['target'] ?? [] as $value) { - $value->execute($class); + $value->execute($annotations['handler']); } foreach ($annotations['methods'] as $name => $attribute) { foreach ($attribute as $value) { if ($value instanceof Relation) { - $annotation->addRelate($class::class, $value->name, $name); + $annotation->addRelate($className, $value->name, $name); } else if ($value instanceof Get) { - $annotation->addGets($class::class, $value->name, $name); + $annotation->addGets($className, $value->name, $name); } else if ($value instanceof Set) { - $annotation->addSets($class::class, $value->name, $name); + $annotation->addSets($className, $value->name, $name); } else { - $value->execute($class, $name); + $value->execute($annotations['handler'], $name); } } } } } - - /** - * @param $class - * @return object - * @throws \ReflectionException - * @throws \Snowflake\Exception\NotFindClassException - */ - private function newInstance($class) - { - $reflection = Snowflake::getDi()->getReflect($class); - return $reflection?->newInstance(); - } - }