xref: /PHP-7.2/ext/reflection/tests/traits001.phpt (revision b515bfbd)
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--EXPECTF--
23bool(true)
24bool(false)
25Trait [ <user> trait Foo ] {
26  @@ %straits001.php 2-4
27
28  - Constants [0] {
29  }
30
31  - Static properties [0] {
32  }
33
34  - Static methods [0] {
35  }
36
37  - Properties [0] {
38  }
39
40  - Methods [1] {
41    Method [ <user> public method someMethod ] {
42      @@ %straits001.php 3 - 3
43    }
44  }
45}
46Class [ <user> class Bar ] {
47  @@ %straits001.php 6-10
48
49  - Constants [0] {
50  }
51
52  - Static properties [0] {
53  }
54
55  - Static methods [0] {
56  }
57
58  - Properties [0] {
59  }
60
61  - Methods [2] {
62    Method [ <user> public method someOtherMethod ] {
63      @@ %straits001.php 9 - 9
64    }
65
66    Method [ <user> public method someMethod ] {
67      @@ %straits001.php 3 - 3
68    }
69  }
70}
71