|
14 | 14 | use Hyperf\Di\Aop\Ast;
|
15 | 15 | use Hyperf\Di\ReflectionManager;
|
16 | 16 | use HyperfTest\Di\Stub\AspectCollector;
|
| 17 | +use HyperfTest\Di\Stub\Ast\Abs; |
| 18 | +use HyperfTest\Di\Stub\Ast\AbsAspect; |
17 | 19 | use HyperfTest\Di\Stub\Ast\Bar2;
|
18 | 20 | use HyperfTest\Di\Stub\Ast\Bar3;
|
19 | 21 | use HyperfTest\Di\Stub\Ast\Bar4;
|
20 | 22 | use HyperfTest\Di\Stub\Ast\Bar5;
|
21 | 23 | use HyperfTest\Di\Stub\Ast\BarAspect;
|
22 | 24 | use HyperfTest\Di\Stub\Ast\BarInterface;
|
| 25 | +use HyperfTest\Di\Stub\Ast\Chi; |
23 | 26 | use HyperfTest\Di\Stub\Ast\Foo;
|
24 | 27 | use HyperfTest\Di\Stub\Ast\FooTrait;
|
25 | 28 | use HyperfTest\Di\Stub\FooEnumStruct;
|
@@ -113,6 +116,65 @@ public function __construct(public FooEnum $enum = FooEnum::DEFAULT)
|
113 | 116 | }', $code);
|
114 | 117 | }
|
115 | 118 |
|
| 119 | + public function testAbstractMethod() |
| 120 | + { |
| 121 | + $aspect = AbsAspect::class; |
| 122 | + AspectCollector::setAround($aspect, [ |
| 123 | + Chi::class, |
| 124 | + Abs::class, |
| 125 | + ], []); |
| 126 | + |
| 127 | + $ast = new Ast(); |
| 128 | + $code = $ast->proxy(Abs::class); |
| 129 | + |
| 130 | + $this->assertSame($this->license . " |
| 131 | +namespace HyperfTest\\Di\\Stub\\Ast; |
| 132 | +
|
| 133 | +abstract class Abs |
| 134 | +{ |
| 135 | + use \\Hyperf\\Di\\Aop\\ProxyTrait; |
| 136 | + use \\Hyperf\\Di\\Aop\\PropertyHandlerTrait; |
| 137 | + function __construct() |
| 138 | + { |
| 139 | + \$this->__handlePropertyHandler(__CLASS__); |
| 140 | + } |
| 141 | + public function abs() : string |
| 142 | + { |
| 143 | + \$__function__ = __FUNCTION__; |
| 144 | + \$__method__ = __METHOD__; |
| 145 | + return self::__proxyCall(__CLASS__, __FUNCTION__, self::__getParamsMap(__CLASS__, __FUNCTION__, func_get_args()), function () use(\$__function__, \$__method__) { |
| 146 | + return 'abs'; |
| 147 | + }); |
| 148 | + } |
| 149 | + public abstract function absabs() : string; |
| 150 | +}", $code); |
| 151 | + |
| 152 | + $code = $ast->proxy(Chi::class); |
| 153 | + $this->assertSame($this->license . ' |
| 154 | +namespace HyperfTest\Di\Stub\Ast; |
| 155 | +
|
| 156 | +class Chi extends Abs |
| 157 | +{ |
| 158 | + use \Hyperf\Di\Aop\ProxyTrait; |
| 159 | + use \Hyperf\Di\Aop\PropertyHandlerTrait; |
| 160 | + function __construct() |
| 161 | + { |
| 162 | + if (method_exists(parent::class, \'__construct\')) { |
| 163 | + parent::__construct(...func_get_args()); |
| 164 | + } |
| 165 | + $this->__handlePropertyHandler(__CLASS__); |
| 166 | + } |
| 167 | + public function absabs() : string |
| 168 | + { |
| 169 | + $__function__ = __FUNCTION__; |
| 170 | + $__method__ = __METHOD__; |
| 171 | + return self::__proxyCall(__CLASS__, __FUNCTION__, self::__getParamsMap(__CLASS__, __FUNCTION__, func_get_args()), function () use($__function__, $__method__) { |
| 172 | + return \'chi\'; |
| 173 | + }); |
| 174 | + } |
| 175 | +}', $code); |
| 176 | + } |
| 177 | + |
116 | 178 | public function testParentMethods()
|
117 | 179 | {
|
118 | 180 | $ast = new Ast();
|
|
0 commit comments