summaryrefslogtreecommitdiff
path: root/ext/reflection/tests/traits004.phpt
blob: d975a52726709b09b160f6d83604c4136b9247bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--TEST--
ReflectionClass::getTraits() and ReflectionClass::getTraitNames
--FILE--
<?php
trait T1 { }
trait T2 { }

class C1 { }
class C2 { use T1; }
class C3 { use T1; use T2; }

for ($c = "C1"; $c <= "C3"; $c++) {
    echo "class $c:\n";
    $r = new ReflectionClass($c);
    var_dump($r->getTraitNames());
    var_dump($r->getTraits());
    echo "\n";
}
--EXPECT--
class C1:
array(0) {
}
array(0) {
}

class C2:
array(1) {
  [0]=>
  string(2) "T1"
}
array(1) {
  ["T1"]=>
  object(ReflectionClass)#1 (1) {
    ["name"]=>
    string(2) "T1"
  }
}

class C3:
array(2) {
  [0]=>
  string(2) "T1"
  [1]=>
  string(2) "T2"
}
array(2) {
  ["T1"]=>
  object(ReflectionClass)#2 (1) {
    ["name"]=>
    string(2) "T1"
  }
  ["T2"]=>
  object(ReflectionClass)#3 (1) {
    ["name"]=>
    string(2) "T2"
  }
}