xref: /php-src/ext/reflection/tests/traits005.phpt (revision d8696f92)
1--TEST--
2ReflectionClass::getTraitAlias
3--FILE--
4<?php
5trait T1 { function m1() { } function m2() { } }
6
7class C1 { }
8class C2 { use T1; }
9class C3 { use T1 { m1 as a1; } }
10class C4 { use T1 { m1 as a1; m2 as a2; } }
11
12$classes  = ['C1', 'C2', 'C3', 'C4'];
13foreach ($classes as $c) {
14    echo "class $c:\n";
15    $r = new ReflectionClass($c);
16    var_dump($r->getTraitAliases());
17    echo "\n";
18}
19?>
20--EXPECT--
21class C1:
22array(0) {
23}
24
25class C2:
26array(0) {
27}
28
29class C3:
30array(1) {
31  ["a1"]=>
32  string(6) "T1::m1"
33}
34
35class C4:
36array(2) {
37  ["a1"]=>
38  string(6) "T1::m1"
39  ["a2"]=>
40  string(6) "T1::m2"
41}
42