1--TEST-- 2ReflectionClass::isSubclassOf() 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 14foreach ($classNames as $className) { 15 $rcs[$className] = new ReflectionClass($className); 16} 17 18foreach ($rcs as $childName => $child) { 19 foreach ($rcs as $parentName => $parent) { 20 echo "Is " . $childName . " a subclass of " . $parentName . "? \n"; 21 echo " - Using object argument: "; 22 var_dump($child->isSubclassOf($parent)); 23 echo " - Using string argument: "; 24 var_dump($child->isSubclassOf($parentName)); 25 } 26} 27?> 28--EXPECTF-- 29Is A a subclass of A? 30 - Using object argument: bool(false) 31 - Using string argument: bool(false) 32Is A a subclass of B? 33 - Using object argument: bool(false) 34 - Using string argument: bool(false) 35Is A a subclass of C? 36 - Using object argument: bool(false) 37 - Using string argument: bool(false) 38Is A a subclass of I? 39 - Using object argument: bool(false) 40 - Using string argument: bool(false) 41Is A a subclass of X? 42 - Using object argument: bool(false) 43 - Using string argument: bool(false) 44Is B a subclass of A? 45 - Using object argument: bool(true) 46 - Using string argument: bool(true) 47Is B a subclass of B? 48 - Using object argument: bool(false) 49 - Using string argument: bool(false) 50Is B a subclass of C? 51 - Using object argument: bool(false) 52 - Using string argument: bool(false) 53Is B a subclass of I? 54 - Using object argument: bool(false) 55 - Using string argument: bool(false) 56Is B a subclass of X? 57 - Using object argument: bool(false) 58 - Using string argument: bool(false) 59Is C a subclass of A? 60 - Using object argument: bool(true) 61 - Using string argument: bool(true) 62Is C a subclass of B? 63 - Using object argument: bool(true) 64 - Using string argument: bool(true) 65Is C a subclass of C? 66 - Using object argument: bool(false) 67 - Using string argument: bool(false) 68Is C a subclass of I? 69 - Using object argument: bool(false) 70 - Using string argument: bool(false) 71Is C a subclass of X? 72 - Using object argument: bool(false) 73 - Using string argument: bool(false) 74Is I a subclass of A? 75 - Using object argument: bool(false) 76 - Using string argument: bool(false) 77Is I a subclass of B? 78 - Using object argument: bool(false) 79 - Using string argument: bool(false) 80Is I a subclass of C? 81 - Using object argument: bool(false) 82 - Using string argument: bool(false) 83Is I a subclass of I? 84 - Using object argument: bool(false) 85 - Using string argument: bool(false) 86Is I a subclass of X? 87 - Using object argument: bool(false) 88 - Using string argument: bool(false) 89Is X a subclass of A? 90 - Using object argument: bool(false) 91 - Using string argument: bool(false) 92Is X a subclass of B? 93 - Using object argument: bool(false) 94 - Using string argument: bool(false) 95Is X a subclass of C? 96 - Using object argument: bool(false) 97 - Using string argument: bool(false) 98Is X a subclass of I? 99 - Using object argument: bool(true) 100 - Using string argument: bool(true) 101Is X a subclass of X? 102 - Using object argument: bool(false) 103 - Using string argument: bool(false) 104