File tree 3 files changed +60
-0
lines changed
3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 22
22
use HyperfTest \Di \Stub \Ast \BarInterface ;
23
23
use HyperfTest \Di \Stub \Ast \Foo ;
24
24
use HyperfTest \Di \Stub \Ast \FooTrait ;
25
+ use HyperfTest \Di \Stub \FooEnumStruct ;
25
26
use PHPUnit \Framework \TestCase ;
26
27
27
28
/**
@@ -66,6 +67,29 @@ function __construct()
66
67
} ' , $ code );
67
68
}
68
69
70
+ public function testAstProxyForEnum ()
71
+ {
72
+ if (PHP_VERSION_ID < 80100 ) {
73
+ $ this ->markTestSkipped ('The version below 8.1 does not support enum. ' );
74
+ }
75
+
76
+ $ ast = new Ast ();
77
+ $ code = $ ast ->proxy (FooEnumStruct::class);
78
+
79
+ $ this ->assertEquals ($ this ->license . '
80
+ namespace HyperfTest\Di\Stub;
81
+
82
+ class FooEnumStruct
83
+ {
84
+ use \Hyperf\Di\Aop\ProxyTrait;
85
+ use \Hyperf\Di\Aop\PropertyHandlerTrait;
86
+ public function __construct(public FooEnum $enum = FooEnum::DEFAULT)
87
+ {
88
+ $this->__handlePropertyHandler(__CLASS__);
89
+ }
90
+ } ' , $ code );
91
+ }
92
+
69
93
public function testParentMethods ()
70
94
{
71
95
$ ast = new Ast ();
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://hyperf.wiki
9
+
10
+ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11
+ */
12
+ namespace HyperfTest \Di \Stub ;
13
+
14
+ enum FooEnum: int
15
+ {
16
+ case DEFAULT = 1 ;
17
+ }
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://hyperf.wiki
9
+
10
+ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11
+ */
12
+ namespace HyperfTest \Di \Stub ;
13
+
14
+ class FooEnumStruct
15
+ {
16
+ public function __construct (public FooEnum $ enum = FooEnum::DEFAULT )
17
+ {
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments