-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 支持在 PointCut 中指定优先级 * 增加测试
- Loading branch information
Showing
6 changed files
with
99 additions
and
15 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
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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Imi\Test\Component\Aop\Aop; | ||
|
||
use Imi\Aop\Annotation\Around; | ||
use Imi\Aop\Annotation\Aspect; | ||
use Imi\Aop\Annotation\PointCut; | ||
use Imi\Aop\AroundJoinPoint; | ||
|
||
#[Aspect(1000)] | ||
class PriorityAop | ||
{ | ||
#[Around] | ||
#[PointCut(allow: ['Imi\\Test\\Component\\Aop\\Classes\\TestPriorityClass::test'])] | ||
public function aop1(AroundJoinPoint $joinPoint): mixed | ||
{ | ||
$args = $joinPoint->getArgs(); | ||
$args[0][] = 1; | ||
$joinPoint->proceed(); | ||
|
||
return 1; | ||
} | ||
|
||
#[Around] | ||
#[PointCut(allow: ['Imi\\Test\\Component\\Aop\\Classes\\TestPriorityClass::test'], priority: 500)] | ||
public function aop2(AroundJoinPoint $joinPoint): mixed | ||
{ | ||
$args = $joinPoint->getArgs(); | ||
$args[0][] = 2; | ||
$joinPoint->proceed(); | ||
|
||
return 2; | ||
} | ||
|
||
#[Around] | ||
#[PointCut(allow: ['Imi\\Test\\Component\\Aop\\Classes\\TestPriorityClass::test'], priority: 1500)] | ||
public function aop3(AroundJoinPoint $joinPoint): mixed | ||
{ | ||
$args = $joinPoint->getArgs(); | ||
$args[0][] = 3; | ||
$joinPoint->proceed(); | ||
|
||
return 3; | ||
} | ||
} |
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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Imi\Test\Component\Aop\Classes; | ||
|
||
class TestPriorityClass | ||
{ | ||
public function test(array &$list): int | ||
{ | ||
$list[] = 0; | ||
|
||
return 0; | ||
} | ||
} |
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