-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
修复自定义注解无法使用Aop切面编程的BUG (swoft-cloud/swoft-component#139)
* 增加自定义Aop注解测试 * 增加自定义方法注解,支持PointAnnotation * 完善单测 * 删除CustomMethod注解 * 通过自定义Parser收集注解测试 * 删除CustomMethod注解
- Loading branch information
1 parent
1093497
commit 522c97a
Showing
8 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace SwoftTest\Aop\Annotation; | ||
|
||
/** | ||
* Class DemoAnnotation | ||
* @Annotation | ||
* @Target("METHOD") | ||
* @package SwoftTest\Aop\Annotation | ||
*/ | ||
class DemoAnnotation | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
public function __construct(array $values) | ||
{ | ||
if (isset($values['name'])) { | ||
$this->name = $values['name']; | ||
} | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
namespace SwoftTest\Aop\Collector; | ||
|
||
class DemoCollector | ||
{ | ||
/** | ||
* The annotations of method | ||
* | ||
* @var array | ||
*/ | ||
public static $methodAnnotations = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace SwoftTest\Aop\Parser; | ||
|
||
use Swoft\Bean\Collector; | ||
use SwoftTest\Aop\Collector\DemoCollector; | ||
|
||
class DemoAnnotationParser | ||
{ | ||
public function parser(string $className, $objectAnnotation = null, string $propertyName = "", string $methodName = "", $propertyValue = null) | ||
{ | ||
Collector::$methodAnnotations[$className][$methodName][] = get_class($objectAnnotation); | ||
DemoCollector::$methodAnnotations[$className][$methodName] = $objectAnnotation; | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters