1--TEST--
2SPL: Test class_uses() function : basic
3--FILE--
4<?php
5/* Prototype  : array class_uses(mixed what [, bool autoload ])
6 * Description: Return all traits used by a class
7 * Source code: ext/spl/php_spl.c
8 * Alias to functions:
9 */
10
11echo "*** Testing class_uses() : basic ***\n";
12
13
14trait foo { }
15class fooUser { use foo; }
16
17trait bar { }
18class barUser { use bar; }
19
20class foobarUser { use foo, bar; }
21
22/** There is no semantics for traits in the inheritance chain.
23    Traits are flattend into a class, and that semantics is nothing
24    like a type, or interface, and thus, not propergated. */
25class fooViaBarUser extends barUser { use foo; }
26
27class fooExtended extends fooUser {}
28
29s_var_dump(class_uses(new foobarUser));
30s_var_dump(class_uses('foobarUser'));
31s_var_dump(class_uses(new fooViaBarUser));
32s_var_dump(class_uses('fooViaBarUser'));
33s_var_dump(class_uses(new fooExtended));
34s_var_dump(class_uses('fooExtended'));
35
36
37function s_var_dump($arr) {
38   krsort($arr);
39   var_dump($arr);
40}
41?>
42===DONE===
43--EXPECT--
44*** Testing class_uses() : basic ***
45array(2) {
46  ["foo"]=>
47  string(3) "foo"
48  ["bar"]=>
49  string(3) "bar"
50}
51array(2) {
52  ["foo"]=>
53  string(3) "foo"
54  ["bar"]=>
55  string(3) "bar"
56}
57array(1) {
58  ["foo"]=>
59  string(3) "foo"
60}
61array(1) {
62  ["foo"]=>
63  string(3) "foo"
64}
65array(0) {
66}
67array(0) {
68}
69===DONE===
70