diff --git a/src/di/src/Aop/Ast.php b/src/di/src/Aop/Ast.php index 14e24eacf..f82fb9579 100644 --- a/src/di/src/Aop/Ast.php +++ b/src/di/src/Aop/Ast.php @@ -15,7 +15,6 @@ use Hyperf\Utils\Composer; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Namespace_; use PhpParser\NodeTraverser; -use PhpParser\NodeVisitor\NameResolver; use PhpParser\ParserFactory; use PhpParser\PrettyPrinter\Standard; use PhpParser\PrettyPrinterAbstract; diff --git a/src/di/src/Aop/AstVisitorRegistry.php b/src/di/src/Aop/AstVisitorRegistry.php index cb7f5a8b1..703ec0e4c 100644 --- a/src/di/src/Aop/AstVisitorRegistry.php +++ b/src/di/src/Aop/AstVisitorRegistry.php @@ -11,8 +11,6 @@ declare(strict_types=1); */ namespace Hyperf\Di\Aop; -use Hyperf\Utils\Traits\Container; - /** * @mixin \SplPriorityQueue */ @@ -23,6 +21,15 @@ class AstVisitorRegistry */ protected static $queue; + public static function __callStatic($name, $arguments) + { + $queue = static::getQueue(); + if (method_exists($queue, $name)) { + return $queue->{$name}(...$arguments); + } + throw new \InvalidArgumentException('Invalid method for ' . __CLASS__); + } + public static function getQueue(): \SplPriorityQueue { if (! static::$queue instanceof \SplPriorityQueue) { @@ -30,15 +37,4 @@ class AstVisitorRegistry } return static::$queue; } - - public static function __callStatic($name, $arguments) - { - $queue = static::getQueue(); - if (method_exists($queue, $name)) { - return $queue->$name(...$arguments); - } - throw new \InvalidArgumentException('Invalid method for ' . __CLASS__); - } - - } diff --git a/src/di/src/Aop/PropertyHandlerTrait.php b/src/di/src/Aop/PropertyHandlerTrait.php index 39e6709bb..44e5bc3ca 100644 --- a/src/di/src/Aop/PropertyHandlerTrait.php +++ b/src/di/src/Aop/PropertyHandlerTrait.php @@ -1,15 +1,22 @@ [ - new Node\Stmt\Expression(new Node\Expr\StaticCall(new Name('parent'), '__construct'), [ - new Node\Arg(new Node\Expr\FuncCall('func_get_args', [], [ + new Node\Stmt\Expression(new Node\Expr\StaticCall(new Name('parent'), '__construct', [ + new Node\Arg(new Node\Expr\FuncCall(new Name('func_get_args'), [], [ 'unpack' => true, ])), - ]), + ])), ], ]); - return new Node\Stmt\If_(new Node\Expr\BinaryOp\BooleanAnd($left, $right)); } protected function buildStaticCallStatement(): Node\Stmt\Expression diff --git a/src/di/src/Aop/ProxyCallVisitor.php b/src/di/src/Aop/ProxyCallVisitor.php index 39f49fdd9..b52b82dee 100644 --- a/src/di/src/Aop/ProxyCallVisitor.php +++ b/src/di/src/Aop/ProxyCallVisitor.php @@ -30,6 +30,11 @@ use PhpParser\NodeVisitorAbstract; class ProxyCallVisitor extends NodeVisitorAbstract { + /** + * @var \Hyperf\Di\Aop\VisitorMetadata + */ + protected $visitorMetadata; + /** * Determine if the class used proxy trait. * @@ -57,11 +62,6 @@ class ProxyCallVisitor extends NodeVisitorAbstract */ private $extends; - /** - * @var \Hyperf\Di\Aop\VisitorMetadata - */ - protected $visitorMetadata; - public function __construct(VisitorMetadata $visitorMetadata) { $this->visitorMetadata = $visitorMetadata; diff --git a/src/di/src/Aop/VisitorMetadata.php b/src/di/src/Aop/VisitorMetadata.php index 0b61d5a8c..1225db6dc 100644 --- a/src/di/src/Aop/VisitorMetadata.php +++ b/src/di/src/Aop/VisitorMetadata.php @@ -1,28 +1,35 @@ $name ?? null; + return $this->{$name} ?? null; } public function __set($name, $value) { - $this->$name = $value; + $this->{$name} = $value; } public function __isset($name) { - return isset($this->$name); + return isset($this->{$name}); } public function __unset($name) { - unset($this->$name); + unset($this->{$name}); } - -} \ No newline at end of file +} diff --git a/src/di/src/ConfigProvider.php b/src/di/src/ConfigProvider.php index 6e394c3ef..37bfebc21 100644 --- a/src/di/src/ConfigProvider.php +++ b/src/di/src/ConfigProvider.php @@ -13,12 +13,11 @@ namespace Hyperf\Di; use Hyperf\Di\Annotation\AnnotationCollector; use Hyperf\Di\Annotation\AspectCollector; +use Hyperf\Di\Annotation\InjectAspect; use Hyperf\Di\Aop\AstVisitorRegistry; use Hyperf\Di\Aop\PropertyHandlerVisitor; use Hyperf\Di\Aop\ProxyCallVisitor; use Hyperf\Di\Aop\RegisterInjectPropertyHandler; -use Hyperf\Di\Annotation\InjectAspect; -use Hyperf\Di\Inject\InjectVisitor; use Hyperf\Di\Listener\BootApplicationListener; class ConfigProvider diff --git a/src/di/src/Definition/DefinitionInterface.php b/src/di/src/Definition/DefinitionInterface.php index 59e29b95d..27ba57ae5 100644 --- a/src/di/src/Definition/DefinitionInterface.php +++ b/src/di/src/Definition/DefinitionInterface.php @@ -27,5 +27,4 @@ interface DefinitionInterface * Set the name of the entry in the container. */ public function setName(string $name); - } diff --git a/src/di/src/Definition/DefinitionSource.php b/src/di/src/Definition/DefinitionSource.php index 4ae21b1cc..e4dd77e62 100644 --- a/src/di/src/Definition/DefinitionSource.php +++ b/src/di/src/Definition/DefinitionSource.php @@ -11,7 +11,6 @@ declare(strict_types=1); */ namespace Hyperf\Di\Definition; -use Hyperf\Di\Annotation\AnnotationCollector; use Hyperf\Di\ReflectionManager; use ReflectionFunctionAbstract; use function class_exists; diff --git a/src/di/src/Resolver/ObjectResolver.php b/src/di/src/Resolver/ObjectResolver.php index dcd137222..914c3e85b 100644 --- a/src/di/src/Resolver/ObjectResolver.php +++ b/src/di/src/Resolver/ObjectResolver.php @@ -104,5 +104,4 @@ class ObjectResolver implements ResolverInterface } return $object; } - }