Annotation of embedaddon/php/ext/spl/tests/class_uses_basic2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: SPL: 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:
11: echo "*** Testing class_uses() : basic ***\n";
12:
13:
14: trait foo { }
15: class fooUser { use foo; }
16:
17: trait bar { }
18: class barUser { use bar; }
19:
20: class 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. */
25: class fooViaBarUser extends barUser { use foo; }
26:
27: class fooExtended extends fooUser {}
28:
29: s_var_dump(class_uses(new foobarUser));
30: s_var_dump(class_uses('foobarUser'));
31: s_var_dump(class_uses(new fooViaBarUser));
32: s_var_dump(class_uses('fooViaBarUser'));
33: s_var_dump(class_uses(new fooExtended));
34: s_var_dump(class_uses('fooExtended'));
35:
36:
37: function s_var_dump($arr) {
38: krsort($arr);
39: var_dump($arr);
40: }
41: ?>
42: ===DONE===
43: --EXPECT--
44: *** Testing class_uses() : basic ***
45: array(2) {
46: ["foo"]=>
47: string(3) "foo"
48: ["bar"]=>
49: string(3) "bar"
50: }
51: array(2) {
52: ["foo"]=>
53: string(3) "foo"
54: ["bar"]=>
55: string(3) "bar"
56: }
57: array(1) {
58: ["foo"]=>
59: string(3) "foo"
60: }
61: array(1) {
62: ["foo"]=>
63: string(3) "foo"
64: }
65: array(0) {
66: }
67: array(0) {
68: }
69: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>