Skip to content

Commit

Permalink
update: 修复注解类被跳过问题
Browse files Browse the repository at this point in the history
  • Loading branch information
NHZEX committed Oct 30, 2023
1 parent 7268758 commit e0eea3e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/Visitor/RewriteVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ public function enterNode(Node $node)
$this->logger->debug("> Enter block class: $class");
}
$reflection = new \ReflectionClass($class);
if ($reflection->isSubclassOf(ImiAnnotationBase::class)) {
return;
}
// 设置顶级类
$this->topClassReflection = $reflection;
break;
Expand Down
29 changes: 29 additions & 0 deletions tests/CodeRewriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,34 @@ class TestScheduler
PHP,
];

yield [
__DIR__ . '/Stub/TestBaseInjectValue.php',
<<<PHP
<?php
declare(strict_types=1);
namespace Imiphp\Tests\Stub;
use Imi\Bean\Annotation\Base;
use Imi\Bean\Annotation\Parser;
/**
* 注入值注解基类.
*/
#[Parser(className: \Imi\Bean\Parser\BeanParser::class)]
abstract class TestBaseInjectValue extends Base
{
/**
* 获取注入值的真实值
*
* @return mixed
*/
abstract public function getRealValue();
}
PHP,
];
}
}
23 changes: 23 additions & 0 deletions tests/Stub/TestBaseInjectValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Imiphp\Tests\Stub;

use Imi\Bean\Annotation\Base;
use Imi\Bean\Annotation\Parser;

/**
* 注入值注解基类.
*
* @Parser("\Imi\Bean\Parser\BeanParser")
*/
abstract class TestBaseInjectValue extends Base
{
/**
* 获取注入值的真实值
*
* @return mixed
*/
abstract public function getRealValue();
}

0 comments on commit e0eea3e

Please sign in to comment.