--- /dev/null
+--TEST--
+ReflectionClass::getName()
+--FILE--
+<?php
+class TrickClass {
+ function __toString() {
+ //Return the name of another class
+ return "Exception";
+ }
+}
+
+$r1 = new ReflectionClass("stdClass");
+
+$myInstance = new stdClass;
+$r2 = new ReflectionClass($myInstance);
+
+$r3 = new ReflectionClass("TrickClass");
+
+var_dump($r1->getName(), $r2->getName(), $r3->getName());
+
+?>
+--EXPECTF--
+string(8) "stdClass"
+string(8) "stdClass"
+string(10) "TrickClass"
+--UEXPECTF--
+unicode(8) "stdClass"
+unicode(8) "stdClass"
+unicode(10) "TrickClass"
--- /dev/null
+--TEST--
+ReflectionClass::getName() - invalid params
+--FILE--
+<?php
+
+$r1 = new ReflectionClass("stdClass");
+
+var_dump($r1->getName('X'));
+var_dump($r1->getName('X', true));
+?>
+--EXPECTF--
+Warning: Wrong parameter count for ReflectionClass::getName() in %s on line 5
+NULL
+
+Warning: Wrong parameter count for ReflectionClass::getName() in %s on line 6
+NULL
+--UEXPECTF--
+Warning: Wrong parameter count for ReflectionClass::getName() in %s on line 5
+NULL
+
+Warning: Wrong parameter count for ReflectionClass::getName() in %s on line 6
+NULL
+
--- /dev/null
+--TEST--
+ReflectionClass::getName - forbid static invocation
+--FILE--
+<?php
+ReflectionClass::getName();
+?>
+--EXPECTF--
+Fatal error: Non-static method ReflectionClass::getName() cannot be called statically in %s on line 2
+--UEXPECTF--
+Fatal error: Non-static method ReflectionClass::getName() cannot be called statically in %s on line 2
--- /dev/null
+--TEST--
+ReflectionClass::isInstance()
+--FILE--
+<?php
+class A {}
+class B extends A {}
+
+interface I {}
+class C implements I {}
+
+class X {}
+
+$classes = array("A", "B", "C", "I", "X");
+
+$instances = array( "myA" => new A,
+ "myB" => new B,
+ "myC" => new C,
+ "myX" => new X );
+
+foreach ($classes as $class) {
+ $rc = new ReflectionClass($class);
+
+ foreach ($instances as $name => $instance) {
+ echo "is $name a $class? ";
+ var_dump($rc->isInstance($instance));
+ }
+
+}
+
+?>
+--EXPECTF--
+is myA a A? bool(true)
+is myB a A? bool(false)
+is myC a A? bool(false)
+is myX a A? bool(false)
+is myA a B? bool(false)
+is myB a B? bool(true)
+is myC a B? bool(false)
+is myX a B? bool(false)
+is myA a C? bool(false)
+is myB a C? bool(false)
+is myC a C? bool(true)
+is myX a C? bool(false)
+is myA a I? bool(false)
+is myB a I? bool(false)
+is myC a I? bool(false)
+is myX a I? bool(false)
+is myA a X? bool(false)
+is myB a X? bool(false)
+is myC a X? bool(false)
+is myX a X? bool(true)
+--UEXPECTF--
+is myA a A? bool(true)
+is myB a A? bool(false)
+is myC a A? bool(false)
+is myX a A? bool(false)
+is myA a B? bool(false)
+is myB a B? bool(true)
+is myC a B? bool(false)
+is myX a B? bool(false)
+is myA a C? bool(false)
+is myB a C? bool(false)
+is myC a C? bool(true)
+is myX a C? bool(false)
+is myA a I? bool(false)
+is myB a I? bool(false)
+is myC a I? bool(false)
+is myX a I? bool(false)
+is myA a X? bool(false)
+is myB a X? bool(false)
+is myC a X? bool(false)
+is myX a X? bool(true)
--- /dev/null
+--TEST--
+ReflectionClass::isInstance() - invalid params
+--FILE--
+<?php
+class X {}
+
+$rc = new ReflectionClass("X");
+$instance = new X;
+
+var_dump($rc->isInstance());
+var_dump($rc->isInstance($instance, $instance));
+var_dump($rc->isInstance(1));
+var_dump($rc->isInstance(1.5));
+var_dump($rc->isInstance(true));
+var_dump($rc->isInstance('X'));
+var_dump($rc->isInstance(null));
+
+?>
+--EXPECTF--
+Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 0 given in %s on line 7
+NULL
+
+Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 2 given in %s on line 8
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, %s given in %s on line 9
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, double given in %s on line 10
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, boolean given in %s on line 11
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, string given in %s on line 12
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, null given in %s on line 13
+NULL
+--UEXPECTF--
+Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 0 given in %s on line 7
+NULL
+
+Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 2 given in %s on line 8
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, %s given in %s on line 9
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, double given in %s on line 10
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, boolean given in %s on line 11
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, Unicode string given in %s on line 12
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, null given in %s on line 13
+NULL
--- /dev/null
+--TEST--
+ReflectionClass::IsInstantiable()
+--FILE--
+<?php
+class C {
+}
+
+interface iface {
+ function f1();
+}
+
+class ifaceImpl implements iface {
+ function f1() {}
+}
+
+abstract class abstractClass {
+ function f1() {}
+ abstract function f2();
+}
+
+class D extends abstractClass {
+ function f2() {}
+}
+
+$classes = array("C", "iface", "ifaceImpl", "abstractClass", "D");
+
+foreach($classes as $class ) {
+ $reflectionClass = new ReflectionClass($class);
+ echo "Is $class instantiable? ";
+ var_dump($reflectionClass->IsInstantiable());
+
+}
+
+?>
+--EXPECTF--
+Is C instantiable? bool(true)
+Is iface instantiable? bool(false)
+Is ifaceImpl instantiable? bool(true)
+Is abstractClass instantiable? bool(false)
+Is D instantiable? bool(true)
+--UEXPECTF--
+Is C instantiable? bool(true)
+Is iface instantiable? bool(false)
+Is ifaceImpl instantiable? bool(true)
+Is abstractClass instantiable? bool(false)
+Is D instantiable? bool(true)
--- /dev/null
+--TEST--
+ReflectionClass::IsInstantiable()
+--FILE--
+<?php
+class privateCtorOld {
+ private function privateCtorOld() {}
+}
+$reflectionClass = new ReflectionClass("privateCtorOld");
+
+var_dump($reflectionClass->IsInstantiable('X'));
+var_dump($reflectionClass->IsInstantiable(0, null));
+
+?>
+--EXPECTF--
+Warning: Wrong parameter count for ReflectionClass::isInstantiable() in %s on line 7
+NULL
+
+Warning: Wrong parameter count for ReflectionClass::isInstantiable() in %s on line 8
+NULL
+--UEXPECTF--
+Warning: Wrong parameter count for ReflectionClass::isInstantiable() in %s on line 7
+NULL
+
+Warning: Wrong parameter count for ReflectionClass::isInstantiable() in %s on line 8
+NULL
--- /dev/null
+--TEST--
+ReflectionClass::IsInstantiable()
+--FILE--
+<?php
+class noCtor {
+}
+
+class publicCtorNew {
+ public function __construct() {}
+}
+
+class protectedCtorNew {
+ protected function __construct() {}
+}
+
+class privateCtorNew {
+ private function __construct() {}
+}
+
+class publicCtorOld {
+ public function publicCtorOld() {}
+}
+
+class protectedCtorOld {
+ protected function protectedCtorOld() {}
+}
+
+class privateCtorOld {
+ private function privateCtorOld() {}
+}
+
+
+$classes = array("noCtor", "publicCtorNew", "protectedCtorNew", "privateCtorNew",
+ "publicCtorOld", "protectedCtorOld", "privateCtorOld");
+
+foreach($classes as $class ) {
+ $reflectionClass = new ReflectionClass($class);
+ echo "Is $class instantiable? ";
+ var_dump($reflectionClass->IsInstantiable());
+}
+
+?>
+--EXPECTF--
+Is noCtor instantiable? bool(true)
+Is publicCtorNew instantiable? bool(true)
+Is protectedCtorNew instantiable? bool(false)
+Is privateCtorNew instantiable? bool(false)
+Is publicCtorOld instantiable? bool(true)
+Is protectedCtorOld instantiable? bool(false)
+Is privateCtorOld instantiable? bool(false)
+--UEXPECTF--
+Is noCtor instantiable? bool(true)
+Is publicCtorNew instantiable? bool(true)
+Is protectedCtorNew instantiable? bool(false)
+Is privateCtorNew instantiable? bool(false)
+Is publicCtorOld instantiable? bool(true)
+Is protectedCtorOld instantiable? bool(false)
+Is privateCtorOld instantiable? bool(false)
--- /dev/null
+--TEST--
+ReflectionClass::isInternal()
+--FILE--
+<?php
+class C {
+}
+
+$r1 = new ReflectionClass("stdClass");
+$r2 = new ReflectionClass("ReflectionClass");
+$r3 = new ReflectionClass("ReflectionProperty");
+$r4 = new ReflectionClass("Exception");
+$r5 = new ReflectionClass("C");
+
+var_dump($r1->isInternal(), $r2->isInternal(), $r3->isInternal(),
+ $r4->isInternal(), $r5->isInternal());
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+--UEXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
--- /dev/null
+--TEST--
+ReflectionClass::isInternal() - invalid params
+--FILE--
+<?php
+$r1 = new ReflectionClass("stdClass");
+var_dump($r1->isInternal('X'));
+var_dump($r1->isInternal('X', true));
+?>
+--EXPECTF--
+Warning: Wrong parameter count for ReflectionClass::isInternal() in %s on line 3
+NULL
+
+Warning: Wrong parameter count for ReflectionClass::isInternal() in %s on line 4
+NULL
+--UEXPECTF--
+Warning: Wrong parameter count for ReflectionClass::isInternal() in %s on line 3
+NULL
+
+Warning: Wrong parameter count for ReflectionClass::isInternal() in %s on line 4
+NULL
--- /dev/null
+--TEST--
+ReflectionClass::isSubclassOf()
+--FILE--
+<?php
+class A {}
+class B extends A {}
+class C extends B {}
+
+interface I {}
+class X implements I {}
+
+$classNames = array('A', 'B', 'C', 'I', 'X');
+
+foreach ($classNames as $className) {
+ $rcs[$className] = new ReflectionClass($className);
+}
+
+foreach ($rcs as $childName => $child) {
+ foreach ($rcs as $parentName => $parent) {
+ echo "Is " . $childName . " a subclass of " . $parentName . "? \n";
+ echo " - Using object argument: ";
+ var_dump($child->isSubclassOf($parent));
+ echo " - Using string argument: ";
+ var_dump($child->isSubclassOf($parentName));
+ }
+}
+?>
+--EXPECTF--
+Is A a subclass of A?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is A a subclass of B?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is A a subclass of C?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is A a subclass of I?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is A a subclass of X?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is B a subclass of A?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Is B a subclass of B?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is B a subclass of C?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is B a subclass of I?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is B a subclass of X?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is C a subclass of A?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Is C a subclass of B?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Is C a subclass of C?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is C a subclass of I?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is C a subclass of X?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is I a subclass of A?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is I a subclass of B?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is I a subclass of C?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is I a subclass of I?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is I a subclass of X?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is X a subclass of A?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is X a subclass of B?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is X a subclass of C?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is X a subclass of I?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Is X a subclass of X?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+--UEXPECTF--
+Is A a subclass of A?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is A a subclass of B?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is A a subclass of C?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is A a subclass of I?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is A a subclass of X?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is B a subclass of A?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Is B a subclass of B?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is B a subclass of C?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is B a subclass of I?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is B a subclass of X?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is C a subclass of A?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Is C a subclass of B?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Is C a subclass of C?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is C a subclass of I?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is C a subclass of X?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is I a subclass of A?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is I a subclass of B?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is I a subclass of C?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is I a subclass of I?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is I a subclass of X?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is X a subclass of A?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is X a subclass of B?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is X a subclass of C?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Is X a subclass of I?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Is X a subclass of X?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
--- /dev/null
+--TEST--
+ReflectionClass::isSubclassOf() - invalid number of parameters
+--FILE--
+<?php
+class A {}
+$rc = new ReflectionClass('A');
+
+var_dump($rc->isSubclassOf());
+var_dump($rc->isSubclassOf('A',5));
+
+?>
+--EXPECTF--
+Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 0 given in %s on line 5
+NULL
+
+Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 2 given in %s on line 6
+NULL
+--UEXPECTF--
+Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 0 given in %s on line 5
+NULL
+
+Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 2 given in %s on line 6
+NULL
--- /dev/null
+--TEST--
+ReflectionClass::isSubclassOf() - non-existent class error
+--FILE--
+<?php
+class A {}
+$rc = new ReflectionClass('A');
+
+var_dump($rc->isSubclassOf('X'));
+
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'ReflectionException' with message 'Class X does not exist' in %s:5
+Stack trace:
+#0 %s(5): ReflectionClass->isSubclassOf('X')
+#1 {main}
+ thrown in %s on line 5
+--UEXPECTF--
+Fatal error: Uncaught exception 'ReflectionException' with message 'Class X does not exist' in %s:5
+Stack trace:
+#0 %s(5): ReflectionClass->isSubclassOf('X')
+#1 {main}
+ thrown in %s on line 5
--- /dev/null
+--TEST--
+ReflectionClass::isUserDefined()
+--FILE--
+<?php
+class C {
+}
+
+$r1 = new ReflectionClass("stdClass");
+$r2 = new ReflectionClass("ReflectionClass");
+$r3 = new ReflectionClass("ReflectionProperty");
+$r4 = new ReflectionClass("Exception");
+$r5 = new ReflectionClass("C");
+
+var_dump($r1->isUserDefined(), $r2->isUserDefined(), $r3->isUserDefined(),
+ $r4->isUserDefined(), $r5->isUserDefined());
+?>
+--EXPECTF--
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+--UEXPECTF--
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
--- /dev/null
+--TEST--
+ReflectionClass::isUserDefined() - invalid params.
+--FILE--
+<?php
+$r1 = new ReflectionClass("stdClass");
+var_dump($r1->isUserDefined('X'));
+var_dump($r1->isUserDefined('X', true));
+?>
+--EXPECTF--
+Warning: Wrong parameter count for ReflectionClass::isUserDefined() in %s on line 3
+NULL
+
+Warning: Wrong parameter count for ReflectionClass::isUserDefined() in %s on line 4
+NULL
+--UEXPECTF--
+Warning: Wrong parameter count for ReflectionClass::isUserDefined() in %s on line 3
+NULL
+
+Warning: Wrong parameter count for ReflectionClass::isUserDefined() in %s on line 4
+NULL