1--TEST--
2ReflectionObject::isSubclassOf() - basic function test
3--FILE--
4<?php
5class A {}
6class B extends A {}
7class C extends B {}
8
9interface I {}
10class X implements I {}
11
12$classNames = array('A', 'B', 'C', 'I', 'X');
13
14//Create ReflectionClasses
15foreach ($classNames as $className) {
16	$rcs[$className] = new ReflectionClass($className);
17}
18
19//Create ReflectionObjects
20foreach ($classNames as $className) {
21	if ($rcs[$className]->isInstantiable()) {
22		$ros[$className] = new ReflectionObject(new $className);
23	}
24}
25
26foreach ($ros as $childName => $child) {
27	foreach ($rcs as $parentName => $parent) {
28		echo "Is " . $childName . " a subclass of " . $parentName . "? \n";
29		echo "   - Using ReflectionClass object argument: ";
30		var_dump($child->isSubclassOf($parent));
31		if ($parent->isInstantiable()) {
32			echo "   - Using ReflectionObject object argument: ";
33			var_dump($child->isSubclassOf($ros[$parentName]));
34		}
35		echo "   - Using string argument: ";
36		var_dump($child->isSubclassOf($parentName));
37	}
38}
39?>
40--EXPECT--
41Is A a subclass of A?
42   - Using ReflectionClass object argument: bool(false)
43   - Using ReflectionObject object argument: bool(false)
44   - Using string argument: bool(false)
45Is A a subclass of B?
46   - Using ReflectionClass object argument: bool(false)
47   - Using ReflectionObject object argument: bool(false)
48   - Using string argument: bool(false)
49Is A a subclass of C?
50   - Using ReflectionClass object argument: bool(false)
51   - Using ReflectionObject object argument: bool(false)
52   - Using string argument: bool(false)
53Is A a subclass of I?
54   - Using ReflectionClass object argument: bool(false)
55   - Using string argument: bool(false)
56Is A a subclass of X?
57   - Using ReflectionClass object argument: bool(false)
58   - Using ReflectionObject object argument: bool(false)
59   - Using string argument: bool(false)
60Is B a subclass of A?
61   - Using ReflectionClass object argument: bool(true)
62   - Using ReflectionObject object argument: bool(true)
63   - Using string argument: bool(true)
64Is B a subclass of B?
65   - Using ReflectionClass object argument: bool(false)
66   - Using ReflectionObject object argument: bool(false)
67   - Using string argument: bool(false)
68Is B a subclass of C?
69   - Using ReflectionClass object argument: bool(false)
70   - Using ReflectionObject object argument: bool(false)
71   - Using string argument: bool(false)
72Is B a subclass of I?
73   - Using ReflectionClass object argument: bool(false)
74   - Using string argument: bool(false)
75Is B a subclass of X?
76   - Using ReflectionClass object argument: bool(false)
77   - Using ReflectionObject object argument: bool(false)
78   - Using string argument: bool(false)
79Is C a subclass of A?
80   - Using ReflectionClass object argument: bool(true)
81   - Using ReflectionObject object argument: bool(true)
82   - Using string argument: bool(true)
83Is C a subclass of B?
84   - Using ReflectionClass object argument: bool(true)
85   - Using ReflectionObject object argument: bool(true)
86   - Using string argument: bool(true)
87Is C a subclass of C?
88   - Using ReflectionClass object argument: bool(false)
89   - Using ReflectionObject object argument: bool(false)
90   - Using string argument: bool(false)
91Is C a subclass of I?
92   - Using ReflectionClass object argument: bool(false)
93   - Using string argument: bool(false)
94Is C a subclass of X?
95   - Using ReflectionClass object argument: bool(false)
96   - Using ReflectionObject object argument: bool(false)
97   - Using string argument: bool(false)
98Is X a subclass of A?
99   - Using ReflectionClass object argument: bool(false)
100   - Using ReflectionObject object argument: bool(false)
101   - Using string argument: bool(false)
102Is X a subclass of B?
103   - Using ReflectionClass object argument: bool(false)
104   - Using ReflectionObject object argument: bool(false)
105   - Using string argument: bool(false)
106Is X a subclass of C?
107   - Using ReflectionClass object argument: bool(false)
108   - Using ReflectionObject object argument: bool(false)
109   - Using string argument: bool(false)
110Is X a subclass of I?
111   - Using ReflectionClass object argument: bool(true)
112   - Using string argument: bool(true)
113Is X a subclass of X?
114   - Using ReflectionClass object argument: bool(false)
115   - Using ReflectionObject object argument: bool(false)
116   - Using string argument: bool(false)
117