File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
test/php/lang/ast/unittest/emit Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -375,6 +375,10 @@ protected function emitTrait($node) {
375
375
$ this ->out ->write ('} ' );
376
376
}
377
377
378
+ protected function emitUse ($ node ) {
379
+ $ this ->out ->write ('use ' .$ node ->value .'; ' );
380
+ }
381
+
378
382
protected function emitConst ($ node ) {
379
383
$ this ->out ->write (implode (' ' , $ node ->value [1 ]).' const ' .$ node ->value [0 ].'= ' );
380
384
$ this ->emit ($ node ->value [2 ]);
Original file line number Diff line number Diff line change
1
+ <?php namespace lang \ast \unittest \emit ;
2
+
3
+ trait Loading {
4
+
5
+ public function loaded () { }
6
+
7
+ }
Original file line number Diff line number Diff line change
1
+ <?php namespace lang \ast \unittest \emit ;
2
+
3
+ use lang \XPClass ;
4
+
5
+ /**
6
+ * Traits
7
+ *
8
+ * @see https://wiki.php.net/rfc/horizontalreuse
9
+ */
10
+ class TraitsTest extends EmittingTest {
11
+
12
+ #[@test]
13
+ public function trait_is_included () {
14
+ $ t = $ this ->type ('class <T> { use \lang\ast\unittest\emit\Loading; } ' );
15
+ $ this ->assertEquals ([new XPClass (Loading::class)], $ t ->getTraits ());
16
+ }
17
+
18
+ #[@test]
19
+ public function trait_method_is_part_of_type () {
20
+ $ t = $ this ->type ('class <T> { use \lang\ast\unittest\emit\Loading; } ' );
21
+ $ this ->assertTrue ($ t ->hasMethod ('loaded ' ));
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments