xref: /PHP-7.2/ext/spl/tests/spl_003.phpt (revision 162aa1a5)
1--TEST--
2SPL: class_parents() and class_implements()
3--FILE--
4<?php
5
6spl_autoload_register(function ($cname) {
7    var_dump($cname);
8});
9
10class a{}
11class b extends a{}
12class c extends b{}
13class d{}
14var_dump(class_parents(new c),
15         class_parents("c"),
16         class_parents(new b),
17         class_parents("b"),
18         class_parents("d"),
19         class_parents("foo", 0),
20         class_parents("foo", 1)
21);
22
23interface iface1{}
24interface iface2{}
25class f implements iface1, iface2{}
26var_dump(class_implements(new a),
27         class_implements("a"),
28         class_implements("aaa"),
29         class_implements("bbb", 0)
30);
31
32?>
33===DONE===
34<?php exit(0); ?>
35--EXPECTF--
36Warning: class_parents(): Class foo does not exist in %sspl_003.php on line %d
37string(3) "foo"
38
39Warning: class_parents(): Class foo does not exist and could not be loaded in %sspl_003.php on line %d
40array(2) {
41  ["b"]=>
42  string(1) "b"
43  ["a"]=>
44  string(1) "a"
45}
46array(2) {
47  ["b"]=>
48  string(1) "b"
49  ["a"]=>
50  string(1) "a"
51}
52array(1) {
53  ["a"]=>
54  string(1) "a"
55}
56array(1) {
57  ["a"]=>
58  string(1) "a"
59}
60array(0) {
61}
62bool(false)
63bool(false)
64string(3) "aaa"
65
66Warning: class_implements(): Class aaa does not exist and could not be loaded in %sspl_003.php on line %d
67
68Warning: class_implements(): Class bbb does not exist in %sspl_003.php on line %d
69array(0) {
70}
71array(0) {
72}
73bool(false)
74bool(false)
75===DONE===
76