xref: /PHP-7.4/ext/reflection/tests/traits005.phpt (revision d679f022)
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
12for ($c = "C1"; $c <= "C4"; $c++) {
13    echo "class $c:\n";
14    $r = new ReflectionClass($c);
15    var_dump($r->getTraitAliases());
16    echo "\n";
17}
18?>
19--EXPECT--
20class C1:
21array(0) {
22}
23
24class C2:
25array(0) {
26}
27
28class C3:
29array(1) {
30  ["a1"]=>
31  string(6) "T1::m1"
32}
33
34class C4:
35array(2) {
36  ["a1"]=>
37  string(6) "T1::m1"
38  ["a2"]=>
39  string(6) "T1::m2"
40}
41