xref: /PHP-8.2/ext/reflection/tests/traits001.phpt (revision 7aacc705)
1--TEST--
2ReflectionClass and Traits
3--FILE--
4<?php
5trait Foo {
6    public function someMethod() { }
7}
8
9class Bar {
10    use Foo;
11
12    public function someOtherMethod() { }
13}
14
15$rFoo = new ReflectionClass('Foo');
16$rBar = new ReflectionClass('Bar');
17
18var_dump($rFoo->isTrait());
19var_dump($rBar->isTrait());
20echo $rFoo;
21echo $rBar;
22?>
23--EXPECTF--
24bool(true)
25bool(false)
26Trait [ <user> trait Foo ] {
27  @@ %straits001.php 2-4
28
29  - Constants [0] {
30  }
31
32  - Static properties [0] {
33  }
34
35  - Static methods [0] {
36  }
37
38  - Properties [0] {
39  }
40
41  - Methods [1] {
42    Method [ <user> public method someMethod ] {
43      @@ %straits001.php 3 - 3
44    }
45  }
46}
47Class [ <user> class Bar ] {
48  @@ %straits001.php 6-10
49
50  - Constants [0] {
51  }
52
53  - Static properties [0] {
54  }
55
56  - Static methods [0] {
57  }
58
59  - Properties [0] {
60  }
61
62  - Methods [2] {
63    Method [ <user> public method someOtherMethod ] {
64      @@ %straits001.php 9 - 9
65    }
66
67    Method [ <user> public method someMethod ] {
68      @@ %straits001.php 3 - 3
69    }
70  }
71}
72