Skip to content

Commit

Permalink
Merge pull request #285 from assert6/patch-6
Browse files Browse the repository at this point in the history
Anonymous class should not rewrite in proxy class
  • Loading branch information
limingxinleo committed Jul 29, 2019
2 parents b30d20c + ba729f7 commit 56b1c2f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/di/src/Aop/ProxyCallVistor.php
Expand Up @@ -92,7 +92,7 @@ public function beforeTraverse(array $nodes)
$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;
Expand Down Expand Up @@ -124,7 +124,7 @@ public function leaveNode(Node $node)
// 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());
Expand Down
2 changes: 1 addition & 1 deletion src/di/src/Aop/ProxyClassNameVistor.php
Expand Up @@ -34,7 +34,7 @@ public function __construct(string $proxyClassName)
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;
Expand Down

0 comments on commit 56b1c2f

Please sign in to comment.