File tree 2 files changed +82
-0
lines changed
2 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 15
15
use HyperfTest \Di \Stub \AspectCollector ;
16
16
use HyperfTest \Di \Stub \Ast \Bar2 ;
17
17
use HyperfTest \Di \Stub \Ast \Bar3 ;
18
+ use HyperfTest \Di \Stub \Ast \Bar4 ;
18
19
use HyperfTest \Di \Stub \Ast \BarAspect ;
19
20
use HyperfTest \Di \Stub \Ast \Foo ;
20
21
use PHPUnit \Framework \TestCase ;
@@ -119,6 +120,49 @@ public function getId() : int
119
120
return Bar::getId();
120
121
});
121
122
}
123
+ } ' , $ code );
124
+ }
125
+
126
+ public function testRewriteParent ()
127
+ {
128
+ $ ast = new Ast ();
129
+ $ proxyClass = Bar4::class . 'Proxy ' ;
130
+ $ code = $ ast ->proxy (Bar4::class, $ proxyClass );
131
+
132
+ $ this ->assertEquals ('<?php
133
+
134
+ declare (strict_types=1);
135
+ /**
136
+ * This file is part of Hyperf.
137
+ *
138
+ * @link https://www.hyperf.io
139
+ * @document https://doc.hyperf.io
140
+
141
+ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
142
+ */
143
+ namespace HyperfTest\Di\Stub\Ast;
144
+
145
+ class Bar4Proxy extends Bar4
146
+ {
147
+ use \Hyperf\Di\Aop\ProxyTrait;
148
+ public function __construct(int $id)
149
+ {
150
+ Bar::__construct($id);
151
+ }
152
+ public function getId() : int
153
+ {
154
+ return Bar::getId();
155
+ }
156
+ public static function getItems()
157
+ {
158
+ return Bar::$items;
159
+ }
160
+ public function closure()
161
+ {
162
+ value(function () {
163
+ Bar::getId();
164
+ });
165
+ }
122
166
} ' , $ code );
123
167
}
124
168
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+ /**
5
+ * This file is part of Hyperf.
6
+ *
7
+ * @link https://www.hyperf.io
8
+ * @document https://doc.hyperf.io
9
+
10
+ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11
+ */
12
+
13
+ namespace HyperfTest \Di \Stub \Ast ;
14
+
15
+ class Bar4 extends Bar
16
+ {
17
+ public function __construct (int $ id )
18
+ {
19
+ parent ::__construct ($ id );
20
+ }
21
+
22
+ public function getId (): int
23
+ {
24
+ return parent ::getId ();
25
+ }
26
+
27
+ public static function getItems ()
28
+ {
29
+ return parent ::$ items ;
30
+ }
31
+
32
+ public function closure ()
33
+ {
34
+ value (function () {
35
+ parent ::getId ();
36
+ });
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments