From 99ec84d7b56c57341cbfde0011bb6d564e08c467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=9F=8E=E9=93=AD?= <767036228@qq.com> Date: Mon, 29 Jul 2019 15:11:17 +0800 Subject: [PATCH 1/5] Update ProxyCallVistor.php --- src/di/src/Aop/ProxyCallVistor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/di/src/Aop/ProxyCallVistor.php b/src/di/src/Aop/ProxyCallVistor.php index f17597bbd..1b3cd7876 100644 --- a/src/di/src/Aop/ProxyCallVistor.php +++ b/src/di/src/Aop/ProxyCallVistor.php @@ -92,7 +92,7 @@ class ProxyCallVistor extends NodeVisitorAbstract $usedNamespace[] = $classUse->name->toCodeString(); } break; - case $class instanceof Class_: + case $class instanceof Class_ && !$class->isAnonymous(): $this->class = $class->name; if ($class->extends) { $this->extends = $class->extends; @@ -124,7 +124,7 @@ class ProxyCallVistor extends NodeVisitorAbstract // Rewrite the method to proxy call method. return $this->rewriteMethod($node); break; - case $node instanceof Class_: + case $node instanceof Class_ && !$node->isAnonymous(): // Add use proxy traits. $stmts = $node->stmts; array_unshift($stmts, $this->buildProxyCallTraitUseStatement()); From b81cf6735c31f8e21d6913b7d0736a242dec14ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=9F=8E=E9=93=AD?= <767036228@qq.com> Date: Mon, 29 Jul 2019 15:14:29 +0800 Subject: [PATCH 2/5] Update ProxyClassNameVistor.php --- src/di/src/Aop/ProxyClassNameVistor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/di/src/Aop/ProxyClassNameVistor.php b/src/di/src/Aop/ProxyClassNameVistor.php index 8e8674c9b..be45a9cfb 100644 --- a/src/di/src/Aop/ProxyClassNameVistor.php +++ b/src/di/src/Aop/ProxyClassNameVistor.php @@ -34,7 +34,7 @@ class ProxyClassNameVistor extends NodeVisitorAbstract public function leaveNode(Node $node) { // Rewirte the class name and extends the original class. - if ($node instanceof Node\Stmt\Class_) { + if ($node instanceof Node\Stmt\Class_ && !$node->isAnonymous()) { $node->extends = $node->name; $node->name = new Node\Identifier($this->proxyClassName); return $node; From 41c07365ccc7e5af3bbdfe8c73c9701f169a9693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=9C=9D=E6=99=96?= Date: Mon, 29 Jul 2019 16:03:39 +0800 Subject: [PATCH 3/5] Update ProxyCallVistor.php --- src/di/src/Aop/ProxyCallVistor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/di/src/Aop/ProxyCallVistor.php b/src/di/src/Aop/ProxyCallVistor.php index 1b3cd7876..87e3f587e 100644 --- a/src/di/src/Aop/ProxyCallVistor.php +++ b/src/di/src/Aop/ProxyCallVistor.php @@ -92,7 +92,7 @@ class ProxyCallVistor extends NodeVisitorAbstract $usedNamespace[] = $classUse->name->toCodeString(); } break; - case $class instanceof Class_ && !$class->isAnonymous(): + case $class instanceof Class_ && ! $class->isAnonymous(): $this->class = $class->name; if ($class->extends) { $this->extends = $class->extends; @@ -124,7 +124,7 @@ class ProxyCallVistor extends NodeVisitorAbstract // Rewrite the method to proxy call method. return $this->rewriteMethod($node); break; - case $node instanceof Class_ && !$node->isAnonymous(): + case $node instanceof Class_ && ! $node->isAnonymous(): // Add use proxy traits. $stmts = $node->stmts; array_unshift($stmts, $this->buildProxyCallTraitUseStatement()); From 5cebb346646fb7622cc952ee0fc40e043e7a3978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=9C=9D=E6=99=96?= Date: Mon, 29 Jul 2019 16:03:52 +0800 Subject: [PATCH 4/5] Update ProxyClassNameVistor.php --- src/di/src/Aop/ProxyClassNameVistor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/di/src/Aop/ProxyClassNameVistor.php b/src/di/src/Aop/ProxyClassNameVistor.php index be45a9cfb..4d8ca5fa6 100644 --- a/src/di/src/Aop/ProxyClassNameVistor.php +++ b/src/di/src/Aop/ProxyClassNameVistor.php @@ -34,7 +34,7 @@ class ProxyClassNameVistor extends NodeVisitorAbstract public function leaveNode(Node $node) { // Rewirte the class name and extends the original class. - if ($node instanceof Node\Stmt\Class_ && !$node->isAnonymous()) { + if ($node instanceof Node\Stmt\Class_ && ! $node->isAnonymous()) { $node->extends = $node->name; $node->name = new Node\Identifier($this->proxyClassName); return $node; From ba729f78f71f5bd86f01abef5aedc4f976e0adf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=9F=8E=E9=93=AD?= <767036228@qq.com> Date: Mon, 29 Jul 2019 16:06:35 +0800 Subject: [PATCH 5/5] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a2aff459..dd423583a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ # Fixed - [#271](https://github.com/hyperf-cloud/hyperf/pull/271) Fixed aop only rewrite the first method in classes and method patten is not work. +- [#285](https://github.com/hyperf-cloud/hyperf/pull/285) Fixed anonymous class should not rewrite in proxy class. # v1.0.7 - 2019-07-26