cvs: php-src(PHP_5_3) /ext/reflection/tests ReflectionClass_FileInfo_basic.phpt ReflectionClass_FileInfo_error.phpt
ReflectionClass_constructor_001.phpt ReflectionClass_constructor_002.phpt ReflectionClass_export_basic1.phpt ReflectionClass_export_basic2.phpt
ReflectionClass_getConstant_basic.phpt ReflectionClass_getConstant_error.phpt ReflectionClass_getConstants_basic.phpt
ReflectionClass_getConstants_error.phpt ReflectionClass_getConstructor_basic.phpt ReflectionClass_getConstructor_error.phpt
ReflectionClass_getExtensionName_basic.phpt ReflectionClass_getExtensionName_variation.phpt ReflectionClass_getExtension_basic.phpt
ReflectionClass_getExtension_variation.phpt ReflectionClass_getInterfaceNames_basic.phpt ReflectionClass_getModifierNames_basic.phpt
ReflectionClass_getModifiers_basic.phpt ReflectionClass_getName_basic.phpt ReflectionClass_getName_error.phpt ReflectionClass_getName_error1.phpt
ReflectionClass_getNamespaceName.phpt ReflectionClass_getParentClas! s.phpt ReflectionClass_hasConstant_basic.phpt
ReflectionClass_hasMethod_basic.phpt ReflectionClass_hasProperty_basic.phpt ReflectionClass_isAbstract_basic.phpt ReflectionClass_isFinal_basic.phpt
ReflectionClass_isInstance_basic.phpt ReflectionClass_isInstance_error.phpt ReflectionClass_isInstantiable_basic.phpt
ReflectionClass_isInstantiable_error.phpt ReflectionClass_isInstantiable_variation.phpt ReflectionClass_isInterface_basic.phpt
ReflectionClass_isInternal_basic.phpt ReflectionClass_isInternal_error.phpt ReflectionClass_isIterateable_basic.phpt
ReflectionClass_isIterateable_variation1.phpt ReflectionClass_isSubclassOf_basic.phpt ReflectionClass_isSubclassOf_error.phpt
ReflectionClass_isSubclassOf_error1.phpt ReflectionClass_isUserDefined_basic.phpt ReflectionClass_isUserDefined_error.phpt
ReflectionExtension_constructor_basic.phpt ReflectionExtension_constructor_error.phpt ReflectionExtension_export_basic.phpt
ReflectionExtension_getClassNames_basic.phpt ReflectionExt! ension_getClassNames_variation1.phpt ReflectionExtension_getClasses_basic.phpt
ReflectionExtension_getDependencies_basic.phpt ReflectionExtension_getDependencies_variation2.phpt ReflectionExtension_getName_basic.phpt
ReflectionExtension_getVersion_basic.phpt ReflectionExtension_info_basic.phpt ReflectionObject_FileInfo_basic
| From: | Sebastian Bergmann | Date: | Wed, 08 Apr 2009 16:09:16 +0000 |
| Subject: | cvs: php-src(PHP_5_3) /ext/reflection/tests ReflectionClass_FileInfo_basic.phpt ReflectionClass_FileInfo_error.phpt ReflectionClass_constructor_001.phpt ReflectionClass_constructor_002.phpt ReflectionClass_export_basic1.phpt ReflectionClass_export_basic2.phpt ReflectionClass_getConstant_basic.phpt ReflectionClass_getConstant_error.phpt ReflectionClass_getConstants_basic.phpt ReflectionClass_getConstants_error.phpt ReflectionClass_getConstructor_basic.phpt ReflectionClass_getConstructor_error.phpt ReflectionClass_getExtensionName_basic.phpt ReflectionClass_getExtensionName_variation.phpt ReflectionClass_getExtension_basic.phpt ReflectionClass_getExtension_variation.phpt ReflectionClass_getInterfaceNames_basic.phpt ReflectionClass_getModifierNames_basic.phpt ReflectionClass_getModifiers_basic.phpt ReflectionClass_getName_basic.phpt ReflectionClass_getName_error.phpt ReflectionClass_getName_error1.phpt ReflectionClass_getNamespaceName.phpt ReflectionClass_getParentClas! s.phpt ReflectionClass_hasConstant_basic.phpt ReflectionClass_hasMethod_basic.phpt ReflectionClass_hasProperty_basic.phpt ReflectionClass_isAbstract_basic.phpt ReflectionClass_isFinal_basic.phpt ReflectionClass_isInstance_basic.phpt ReflectionClass_isInstance_error.phpt ReflectionClass_isInstantiable_basic.phpt ReflectionClass_isInstantiable_error.phpt ReflectionClass_isInstantiable_variation.phpt ReflectionClass_isInterface_basic.phpt ReflectionClass_isInternal_basic.phpt ReflectionClass_isInternal_error.phpt ReflectionClass_isIterateable_basic.phpt ReflectionClass_isIterateable_variation1.phpt ReflectionClass_isSubclassOf_basic.phpt ReflectionClass_isSubclassOf_error.phpt ReflectionClass_isSubclassOf_error1.phpt ReflectionClass_isUserDefined_basic.phpt ReflectionClass_isUserDefined_error.phpt ReflectionExtension_constructor_basic.phpt ReflectionExtension_constructor_error.phpt ReflectionExtension_export_basic.phpt ReflectionExtension_getClassNames_basic.phpt ReflectionExt! ension_getClassNames_variation1.phpt ReflectionExtension_getClasses_basic.phpt ReflectionExtension_getDependencies_basic.phpt ReflectionExtension_getDependencies_variation2.phpt ReflectionExtension_getName_basic.phpt ReflectionExtension_getVersion_basic.phpt ReflectionExtension_info_basic.phpt ReflectionObject_FileInfo_basic |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-56957@lists.php.net to get a copy of this message | ||
sebastian Wed Apr 8 16:09:16 2009 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/reflection/tests ReflectionClass_FileInfo_basic.phpt
ReflectionClass_FileInfo_error.phpt
ReflectionClass_constructor_001.phpt
ReflectionClass_constructor_002.phpt
ReflectionClass_export_basic1.phpt
ReflectionClass_export_basic2.phpt
ReflectionClass_getConstant_basic.phpt
ReflectionClass_getConstant_error.phpt
ReflectionClass_getConstants_basic.phpt
ReflectionClass_getConstants_error.phpt
ReflectionClass_getConstructor_basic.phpt
ReflectionClass_getConstructor_error.phpt
ReflectionClass_getExtensionName_basic.phpt
ReflectionClass_getExtensionName_variation.phpt
ReflectionClass_getExtension_basic.phpt
ReflectionClass_getExtension_variation.phpt
ReflectionClass_getInterfaceNames_basic.phpt
ReflectionClass_getModifierNames_basic.phpt
ReflectionClass_getModifiers_basic.phpt
ReflectionClass_getName_basic.phpt
ReflectionClass_getName_error.phpt
ReflectionClass_getName_error1.phpt
ReflectionClass_getNamespaceName.phpt
ReflectionClass_getParentClass.phpt
ReflectionClass_hasConstant_basic.phpt
ReflectionClass_hasMethod_basic.phpt
ReflectionClass_hasProperty_basic.phpt
ReflectionClass_isAbstract_basic.phpt
ReflectionClass_isFinal_basic.phpt
ReflectionClass_isInstance_basic.phpt
ReflectionClass_isInstance_error.phpt
ReflectionClass_isInstantiable_basic.phpt
ReflectionClass_isInstantiable_error.phpt
ReflectionClass_isInstantiable_variation.phpt
ReflectionClass_isInterface_basic.phpt
ReflectionClass_isInternal_basic.phpt
ReflectionClass_isInternal_error.phpt
ReflectionClass_isIterateable_basic.phpt
ReflectionClass_isIterateable_variation1.phpt
ReflectionClass_isSubclassOf_basic.phpt
ReflectionClass_isSubclassOf_error.phpt
ReflectionClass_isSubclassOf_error1.phpt
ReflectionClass_isUserDefined_basic.phpt
ReflectionClass_isUserDefined_error.phpt
ReflectionExtension_constructor_basic.phpt
ReflectionExtension_constructor_error.phpt
ReflectionExtension_export_basic.phpt
ReflectionExtension_getClassNames_basic.phpt
ReflectionExtension_getClassNames_variation1.phpt
ReflectionExtension_getClasses_basic.phpt
ReflectionExtension_getDependencies_basic.phpt
ReflectionExtension_getDependencies_variation2.phpt
ReflectionExtension_getName_basic.phpt
ReflectionExtension_getVersion_basic.phpt
ReflectionExtension_info_basic.phpt
ReflectionObject_FileInfo_basic.phpt
ReflectionObject_FileInfo_error.phpt
ReflectionObject___toString_basic1.phpt
ReflectionObject___toString_basic2.phpt
ReflectionObject_constructor_basic.phpt
ReflectionObject_constructor_error.phpt
ReflectionObject_export_basic1.phpt
ReflectionObject_export_basic2.phpt
ReflectionObject_export_basic3.phpt
ReflectionObject_getConstant_basic.phpt
ReflectionObject_getConstant_error.phpt
ReflectionObject_getConstants_basic.phpt
ReflectionObject_getConstants_error.phpt
ReflectionObject_getConstructor_basic.phpt
ReflectionObject_getConstructor_error.phpt
ReflectionObject_getName_basic.phpt
ReflectionObject_getName_error.phpt
ReflectionObject_getName_error1.phpt
ReflectionObject_isInstance_basic.phpt
ReflectionObject_isInstance_error.phpt
ReflectionObject_isInstantiable_basic.phpt
ReflectionObject_isInstantiable_error.phpt
ReflectionObject_isInstantiable_variation.phpt
ReflectionObject_isInternal_basic.phpt
ReflectionObject_isInternal_error.phpt
ReflectionObject_isSubclassOf_basic.phpt
ReflectionObject_isSubclassOf_error.phpt
ReflectionObject_isUserDefined_basic.phpt
ReflectionObject_isUserDefined_error.phpt
ReflectionParameter_export_basic.phpt
ReflectionParameter_export_error.phpt
ReflectionParameter_export_error2.phpt
ReflectionParameter_export_error3.phpt
ReflectionParameter_getDeclaringFunction_basic.phpt
ReflectionParameter_getPosition_basic.phpt
ReflectionParameter_invalidMethodInConstructor.phpt
ReflectionParameter_toString_basic.phpt
ReflectionProperty_basic1.phpt
ReflectionProperty_basic2.phpt
ReflectionProperty_constructor_error.phpt
ReflectionProperty_constructor_variation1.phpt
ReflectionProperty_error.phpt
ReflectionProperty_export_basic.phpt
ReflectionProperty_export_error.phpt
ReflectionProperty_getDeclaringClass_variation1.phpt
ReflectionProperty_getDocComment_basic.phpt
ReflectionProperty_getDocComment_error.phpt
ReflectionProperty_getModifiers_basic.phpt
ReflectionProperty_getValue_error.phpt
ReflectionProperty_isDefault_basic.phpt
ReflectionProperty_setAccessible.phpt
ReflectionProperty_setValue_error.phpt
Removed files:
/php-src/ext/reflection/tests reflectionClass_FileInfo_basic.phpt
reflectionClass_FileInfo_error.phpt
reflectionClass_constructor_001.phpt
reflectionClass_constructor_002.phpt
reflectionClass_export_basic1.phpt
reflectionClass_export_basic2.phpt
reflectionClass_getConstant_basic.phpt
reflectionClass_getConstant_error.phpt
reflectionClass_getConstants_basic.phpt
reflectionClass_getConstants_error.phpt
reflectionClass_getConstructor_basic.phpt
reflectionClass_getConstructor_error.phpt
reflectionClass_getExtensionName_basic.phpt
reflectionClass_getExtensionName_variation.phpt
reflectionClass_getExtension_basic.phpt
reflectionClass_getExtension_variation.phpt
reflectionClass_getInterfaceNames_basic.phpt
reflectionClass_getModifierNames_basic.phpt
reflectionClass_getModifiers_basic.phpt
reflectionClass_getName_basic.phpt
reflectionClass_getName_error.phpt
reflectionClass_getName_error1.phpt
reflectionClass_getNamespaceName.phpt
reflectionClass_getParentClass.phpt
reflectionClass_hasConstant_basic.phpt
reflectionClass_hasMethod_basic.phpt
reflectionClass_hasProperty_basic.phpt
reflectionClass_isAbstract_basic.phpt
reflectionClass_isFinal_basic.phpt
reflectionClass_isInstance_basic.phpt
reflectionClass_isInstance_error.phpt
reflectionClass_isInstantiable_basic.phpt
reflectionClass_isInstantiable_error.phpt
reflectionClass_isInstantiable_variation.phpt
reflectionClass_isInterface_basic.phpt
reflectionClass_isInternal_basic.phpt
reflectionClass_isInternal_error.phpt
reflectionClass_isIterateable_basic.phpt
reflectionClass_isIterateable_variation1.phpt
reflectionClass_isSubclassOf_basic.phpt
reflectionClass_isSubclassOf_error.phpt
reflectionClass_isSubclassOf_error1.phpt
reflectionClass_isUserDefined_basic.phpt
reflectionClass_isUserDefined_error.phpt
reflectionExtension_constructor_basic.phpt
reflectionExtension_constructor_error.phpt
reflectionExtension_export_basic.phpt
reflectionExtension_getClassNames_basic.phpt
reflectionExtension_getClassNames_variation1.phpt
reflectionExtension_getClasses_basic.phpt
reflectionExtension_getDependencies_basic.phpt
reflectionExtension_getDependencies_variation2.phpt
reflectionExtension_getName_basic.phpt
reflectionExtension_getVersion_basic.phpt
reflectionExtension_info_basic.phpt
reflectionObject_FileInfo_basic.phpt
reflectionObject_FileInfo_error.phpt
reflectionObject___toString_basic1.phpt
reflectionObject___toString_basic2.phpt
reflectionObject_constructor_basic.phpt
reflectionObject_constructor_error.phpt
reflectionObject_export_basic1.phpt
reflectionObject_export_basic2.phpt
reflectionObject_export_basic3.phpt
reflectionObject_getConstant_basic.phpt
reflectionObject_getConstant_error.phpt
reflectionObject_getConstants_basic.phpt
reflectionObject_getConstants_error.phpt
reflectionObject_getConstructor_basic.phpt
reflectionObject_getConstructor_error.phpt
reflectionObject_getName_basic.phpt
reflectionObject_getName_error.phpt
reflectionObject_getName_error1.phpt
reflectionObject_isInstance_basic.phpt
reflectionObject_isInstance_error.phpt
reflectionObject_isInstantiable_basic.phpt
reflectionObject_isInstantiable_error.phpt
reflectionObject_isInstantiable_variation.phpt
reflectionObject_isInternal_basic.phpt
reflectionObject_isInternal_error.phpt
reflectionObject_isSubclassOf_basic.phpt
reflectionObject_isSubclassOf_error.phpt
reflectionObject_isUserDefined_basic.phpt
reflectionObject_isUserDefined_error.phpt
reflectionParameter_export_basic.phpt
reflectionParameter_export_error.phpt
reflectionParameter_export_error2.phpt
reflectionParameter_export_error3.phpt
reflectionParameter_getDeclaringFunction_basic.phpt
reflectionParameter_getPosition_basic.phpt
reflectionParameter_invalidMethodInConstructor.phpt
reflectionParameter_toString_basic.phpt
reflectionProperty_basic1.phpt
reflectionProperty_basic2.phpt
reflectionProperty_constructor_error.phpt
reflectionProperty_constructor_variation1.phpt
reflectionProperty_error.phpt
reflectionProperty_export_basic.phpt
reflectionProperty_export_error.phpt
reflectionProperty_getDeclaringClass_variation1.phpt
reflectionProperty_getDocComment_basic.phpt
reflectionProperty_getDocComment_error.phpt
reflectionProperty_getModifiers_basic.phpt
reflectionProperty_getValue_error.phpt
reflectionProperty_isDefault_basic.phpt
reflectionProperty_setAccessible.phpt
reflectionProperty_setValue_error.phpt
Log:
MFH: Rename reflection*.phpt to Reflection*.phpt for consistency.
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt --TEST-- ReflectionClass::getFileName(), ReflectionClass::getStartLine(), ReflectionClass::getEndLine() --FILE-- <?php //New instance of class C - defined below $rc = new ReflectionClass("C"); //Get the file name of the PHP script in which C is defined var_dump($rc->getFileName()); //Get the line number at the start of the definition of class C var_dump($rc->getStartLine()); //Get the line number at the end of the definition of class C var_dump($rc->getEndLine()); //Same tests as above but stdclass is internal - so all results should be false. $rc = new ReflectionClass("stdClass"); var_dump($rc->getFileName()); var_dump($rc->getStartLine()); var_dump($rc->getEndLine()); Class C { } ?> --EXPECTF-- unicode(%d) "%sReflectionClass_FileInfo_basic.php" int(20) int(22) bool(false) bool(false) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_FileInfo_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_FileInfo_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_FileInfo_error.phpt --TEST-- ReflectionClass::getFileName(), ReflectionClass::getStartLine(), ReflectionClass::getEndLine() - bad params --FILE-- <?php Class C { } $rc = new ReflectionClass("C"); $methods = array("getFileName", "getStartLine", "getEndLine"); foreach ($methods as $method) { var_dump($rc->$method()); var_dump($rc->$method(null)); var_dump($rc->$method('X', 0)); } ?> --EXPECTF-- unicode(%s) "%s" Warning: ReflectionClass::getFileName() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getFileName() expects exactly 0 parameters, 2 given in %s on line %d NULL int(2) Warning: ReflectionClass::getStartLine() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getStartLine() expects exactly 0 parameters, 2 given in %s on line %d NULL int(2) Warning: ReflectionClass::getEndLine() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getEndLine() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_constructor_001.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_constructor_001.phpt +++ php-src/ext/reflection/tests/ReflectionClass_constructor_001.phpt --TEST-- ReflectionClass::__constructor() --FILE-- <?php $r1 = new ReflectionClass("stdClass"); $myInstance = new stdClass; $r2 = new ReflectionClass($myInstance); class TrickClass { function __toString() { //Return the name of another class return "Exception"; } } $myTrickClass = new TrickClass; $r3 = new ReflectionClass($myTrickClass); var_dump($r1, $r2, $r3); ?> --EXPECTF-- object(ReflectionClass)#%d (1) { [u"name"]=> unicode(8) "stdClass" } object(ReflectionClass)#%d (1) { [u"name"]=> unicode(8) "stdClass" } object(ReflectionClass)#%d (1) { [u"name"]=> unicode(10) "TrickClass" } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_constructor_002.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_constructor_002.phpt +++ php-src/ext/reflection/tests/ReflectionClass_constructor_002.phpt --TEST-- ReflectionClass::__constructor() - bad arguments --FILE-- <?php try { var_dump(new ReflectionClass()); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { var_dump(new ReflectionClass(null)); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { var_dump(new ReflectionClass(true)); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { var_dump(new ReflectionClass(1)); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { var_dump(new ReflectionClass(array(1,2,3))); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { var_dump(new ReflectionClass("stdClass", 1)); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { var_dump(new ReflectionClass("X")); } catch (Exception $e) { echo $e->getMessage() . "\n"; } ?> --EXPECTF-- Warning: ReflectionClass::__construct() expects exactly 1 parameter, 0 given in %s on line 3 object(ReflectionClass)#%d (1) { [u"name"]=> unicode(0) "" } Class does not exist Class 1 does not exist Class 1 does not exist Warning: ReflectionClass::__construct() expects parameter 1 to be string (Unicode or binary), array given in %s on line 27 object(ReflectionClass)#3 (1) { [u"name"]=> unicode(0) "" } Warning: ReflectionClass::__construct() expects exactly 1 parameter, 2 given in %s on line 33 object(ReflectionClass)#%d (1) { [u"name"]=> unicode(0) "" } Class X does not exist http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_export_basic1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_export_basic1.phpt +++ php-src/ext/reflection/tests/ReflectionClass_export_basic1.phpt --TEST-- ReflectionClass::export() - various parameters --FILE-- <?php Class A { public function privf(Exception $a) {} public function pubf(A $a, $b, C $c = null, $d = K, $e = "15 chars long -", $f = null, $g = false, array $h = null) {} } Class C extends A { } define('K', "16 chars long --"); ReflectionClass::export("C"); ?> --EXPECTF-- Class [ <user> class C extends A ] { @@ %s 14-14 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Methods [2] { Method [ <user, inherits A> public method privf ] { @@ %s 3 - 3 - Parameters [1] { Parameter #0 [ <required> Exception $a ] } } Method [ <user, inherits A> public method pubf ] { @@ %s 4 - 11 - Parameters [8] { Parameter #0 [ <required> A $a ] Parameter #1 [ <required> $b ] Parameter #2 [ <optional> C or NULL $c = NULL ] Parameter #3 [ <optional> $d = '16 chars long -...' ] Parameter #4 [ <optional> $e = '15 chars long -' ] Parameter #5 [ <optional> $f = NULL ] Parameter #6 [ <optional> $g = false ] Parameter #7 [ <optional> array or NULL $h = NULL ] } } } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_export_basic2.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_export_basic2.phpt +++ php-src/ext/reflection/tests/ReflectionClass_export_basic2.phpt --TEST-- ReflectionClass::export() - ensure inherited private props are hidden. --FILE-- <?php Class c { private $a; static private $b; } class d extends c {} ReflectionClass::export("c"); ReflectionClass::export("d"); ?> --EXPECTF-- Class [ <user> class c ] { @@ %s 2-5 - Constants [0] { } - Static properties [1] { Property [ private static $b ] } - Static methods [0] { } - Properties [1] { Property [ <default> private $a ] } - Methods [0] { } } Class [ <user> class d extends c ] { @@ %s 7-7 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Methods [0] { } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt --TEST-- ReflectionClass::getConstants() --FILE-- <?php class C { const a = 'hello from C'; } class D extends C { } class E extends D { } class F extends E { const a = 'hello from F'; } class X { } $classes = array("C", "D", "E", "F", "X"); foreach($classes as $class) { echo "Reflecting on class $class: \n"; $rc = new ReflectionClass($class); var_dump($rc->getConstant('a')); var_dump($rc->getConstant('doesntexist')); } ?> --EXPECTF-- Reflecting on class C: unicode(12) "hello from C" bool(false) Reflecting on class D: unicode(12) "hello from C" bool(false) Reflecting on class E: unicode(12) "hello from C" bool(false) Reflecting on class F: unicode(12) "hello from F" bool(false) Reflecting on class X: bool(false) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getConstant_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getConstant_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getConstant_error.phpt --TEST-- ReflectionClass::getConstant() - bad params --FILE-- <?php class C { const myConst = 1; } $rc = new ReflectionClass("C"); echo "Check invalid params:\n"; var_dump($rc->getConstant()); var_dump($rc->getConstant("myConst", "myConst")); var_dump($rc->getConstant(null)); var_dump($rc->getConstant(1)); var_dump($rc->getConstant(1.5)); var_dump($rc->getConstant(true)); var_dump($rc->getConstant(array(1,2,3))); var_dump($rc->getConstant(new C)); ?> --EXPECTF-- Check invalid params: Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 0 given in %s on line 8 NULL Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 2 given in %s on line 9 NULL bool(false) bool(false) bool(false) bool(false) Warning: ReflectionClass::getConstant() expects parameter 1 to be string (Unicode or binary), array given in %s on line 14 NULL Warning: ReflectionClass::getConstant() expects parameter 1 to be string (Unicode or binary), object given in %s on line 15 NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt --TEST-- ReflectionClass::getConstants() --FILE-- <?php class C { const a = 'hello from C'; } class D extends C { } class E extends D { } class F extends E { const a = 'hello from F'; } class X { } $classes = array('C', 'D', 'E', 'F', 'X'); foreach($classes as $class) { echo "Constants from class $class: \n"; $rc = new ReflectionClass($class); var_dump($rc->getConstants()); } ?> --EXPECTF-- Constants from class C: array(1) { [u"a"]=> unicode(12) "hello from C" } Constants from class D: array(1) { [u"a"]=> unicode(12) "hello from C" } Constants from class E: array(1) { [u"a"]=> unicode(12) "hello from C" } Constants from class F: array(1) { [u"a"]=> unicode(12) "hello from F" } Constants from class X: array(0) { } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getConstants_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getConstants_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getConstants_error.phpt --TEST-- ReflectionClass::getConstants() --FILE-- <?php class X { } $rc = new reflectionClass('X'); //Test invalid arguments $rc->getConstants('X'); $rc->getConstants(true); $rc->getConstants(null); $rc->getConstants('A', 'B'); ?> --EXPECTF-- Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 2 given in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt --TEST-- ReflectionClass::getConstructor() --SKIPIF-- <?php extension_loaded('reflection') or die('skip - reflection extension not loaded'); ?> --CREDITS-- Michelangelo van Dam <dragonbe@gmail.com> #testfest roosendaal on 2008-05-10 --FILE-- <?php class NewCtor { function __construct() {} } class ExtendsNewCtor extends NewCtor { } class OldCtor { function OldCtor() {} } class ExtendsOldCtor extends OldCtor { } class X { function Y() {} } class Y extends X { } class OldAndNewCtor { function OldAndNewCtor() {} function __construct() {} } class NewAndOldCtor { function __construct() {} function NewAndOldCtor() {} } class B { function B() {} } class C extends B { function C() {} } class D1 extends C { function __construct() {} } class D2 extends C { } $classes = array('NewCtor', 'ExtendsNewCtor', 'OldCtor', 'ExtendsOldCtor', 'OldAndNewCtor', 'NewAndOldCtor', 'B', 'C', 'D1', 'D2', 'X', 'Y'); foreach ($classes as $class) { $rc = new ReflectionClass($class); $rm = $rc->getConstructor(); if ($rm != null) { echo "Constructor of $class: " . $rm->getName() . "\n"; } else { echo "No constructor for $class\n"; } } ?> --EXPECTF-- Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line 26 Strict Standards: %s for class NewAndOldCtor in %s on line 31 Constructor of NewCtor: __construct Constructor of ExtendsNewCtor: __construct Constructor of OldCtor: OldCtor Constructor of ExtendsOldCtor: OldCtor Constructor of OldAndNewCtor: __construct Constructor of NewAndOldCtor: __construct Constructor of B: B Constructor of C: C Constructor of D1: __construct Constructor of D2: C No constructor for X No constructor for Y http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getConstructor_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getConstructor_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getConstructor_error.phpt --TEST-- ReflectionClass::getConstructor() - bad params --FILE-- <?php class C {} $rc = new ReflectionClass('C'); var_dump($rc->getConstructor(null)); var_dump($rc->getConstructor('X')); var_dump($rc->getConstructor(true)); var_dump($rc->getConstructor(array(1,2,3))); ?> --EXPECTF-- Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt --TEST-- ReflectionClass::getExtensionName() method - basic test for getExtensionName() method --SKIPIF-- <?php extension_loaded('dom') or die('skip - dom extension not loaded'); ?> --CREDITS-- Rein Velt <rein@velt.org> #testFest Roosendaal 2008-05-10 --FILE-- <?php $rc=new reflectionClass('domDocument'); var_dump( $rc->getExtensionName()) ; ?> --EXPECT-- unicode(3) "dom" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt --TEST-- ReflectionClass::getExtensionName() method - variation test for getExtensionName() --CREDITS-- Rein Velt <rein@velt.org> #testFest Roosendaal 2008-05-10 --FILE-- <?php class myClass { public $varX; public $varY; } $rc=new reflectionClass('myClass'); var_dump( $rc->getExtensionName()) ; ?> --EXPECT-- bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt --TEST-- ReflectionClass::getExtension() method - basic test for getExtension() method --SKIPIF-- <?php extension_loaded('dom') or die('skip - dom extension not loaded'); ?> --CREDITS-- Rein Velt <rein@velt.org> #testFest Roosendaal 2008-05-10 --FILE-- <?php $rc=new reflectionClass('domDocument'); var_dump($rc->getExtension()) ; ?> --EXPECTF-- object(ReflectionExtension)#%d (1) { [u"name"]=> unicode(3) "dom" } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt --TEST-- ReflectionClass::getExtension() method - variation test for getExtension() --CREDITS-- Rein Velt <rein@velt.org> #testFest Roosendaal 2008-05-10 --FILE-- <?php class myClass { public $varX; public $varY; } $rc=new reflectionClass('myClass'); var_dump( $rc->getExtension()) ; ?> --EXPECT-- NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getInterfaceNames_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getInterfaceNames_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getInterfaceNames_basic.phpt --TEST-- ReflectionClass::getInterfaceNames() --CREDITS-- Michelangelo van Dam <dragonbe@gmail.com> #testfest roosendaal on 2008-05-10 --FILE-- <?php interface Foo { } interface Bar { } class Baz implements Foo, Bar { } $rc1 = new ReflectionClass("Baz"); var_dump($rc1->getInterfaceNames()); ?> --EXPECT-- array(2) { [0]=> unicode(3) "Foo" [1]=> unicode(3) "Bar" } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt --TEST-- ReflectionClass::getModifierNames() basic tests --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --FILE-- <?php class a {} abstract class b {} final class c {} class x { function __construct() {} function __destruct() {} private function a() {} private static function b() {} protected function c() {} protected static function d() {} public function e() {} public static function f() {} final function g() {} function h() {} } abstract class y { abstract function a(); abstract protected function b(); } function dump_modifierNames($class) { $obj = new ReflectionClass($class); var_dump($obj->getName(), Reflection::getModifierNames($obj->getModifiers())); } function dump_methodModifierNames($class) { $obj = new ReflectionClass($class); foreach($obj->getMethods() as $method) { var_dump($obj->getName() . "::" . $method->getName(), Reflection::getModifierNames($method->getModifiers())); } } dump_modifierNames('a'); dump_modifierNames('b'); dump_modifierNames('c'); dump_methodModifierNames('x'); dump_methodModifierNames('y'); ?> ==DONE== --EXPECT-- unicode(1) "a" array(0) { } unicode(1) "b" array(1) { [0]=> unicode(8) "abstract" } unicode(1) "c" array(1) { [0]=> unicode(5) "final" } unicode(14) "x::__construct" array(1) { [0]=> unicode(6) "public" } unicode(13) "x::__destruct" array(1) { [0]=> unicode(6) "public" } unicode(4) "x::a" array(1) { [0]=> unicode(7) "private" } unicode(4) "x::b" array(2) { [0]=> unicode(7) "private" [1]=> unicode(6) "static" } unicode(4) "x::c" array(1) { [0]=> unicode(9) "protected" } unicode(4) "x::d" array(2) { [0]=> unicode(9) "protected" [1]=> unicode(6) "static" } unicode(4) "x::e" array(1) { [0]=> unicode(6) "public" } unicode(4) "x::f" array(2) { [0]=> unicode(6) "public" [1]=> unicode(6) "static" } unicode(4) "x::g" array(2) { [0]=> unicode(5) "final" [1]=> unicode(6) "public" } unicode(4) "x::h" array(1) { [0]=> unicode(6) "public" } unicode(4) "y::a" array(2) { [0]=> unicode(8) "abstract" [1]=> unicode(6) "public" } unicode(4) "y::b" array(2) { [0]=> unicode(8) "abstract" [1]=> unicode(9) "protected" } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt --TEST-- ReflectionClass::getModifiers() --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --FILE-- <?php class a {} abstract class b {} final class c {} interface d {} class e implements d {} interface f extends d {} class g extends b {} function dump_modifiers($class) { $obj = new ReflectionClass($class); var_dump($obj->getModifiers()); } dump_modifiers('a'); dump_modifiers('b'); dump_modifiers('c'); dump_modifiers('d'); dump_modifiers('e'); dump_modifiers('f'); dump_modifiers('g'); ?> --EXPECT-- int(0) int(32) int(64) int(128) int(524288) int(524416) int(0) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getName_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getName_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getName_basic.phpt --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-- unicode(8) "stdClass" unicode(8) "stdClass" unicode(10) "TrickClass" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getName_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getName_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getName_error.phpt --TEST-- ReflectionClass::getName() - invalid params --FILE-- <?php $r1 = new ReflectionClass("stdClass"); var_dump($r1->getName('X')); var_dump($r1->getName('X', true)); ?> --EXPECTF-- Warning: ReflectionClass::getName() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getName() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getName_error1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getName_error1.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getName_error1.phpt --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 http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getNamespaceName.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getNamespaceName.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getNamespaceName.phpt --TEST-- ReflectionClass::getNamespaceName() --FILE-- <?php namespace A\B; class Foo { } $function = new \ReflectionClass('stdClass'); var_dump($function->inNamespace()); var_dump($function->getName()); var_dump($function->getNamespaceName()); var_dump($function->getShortName()); $function = new \ReflectionClass('A\\B\\Foo'); var_dump($function->inNamespace()); var_dump($function->getName()); var_dump($function->getNamespaceName()); var_dump($function->getShortName()); ?> --EXPECT-- bool(false) unicode(8) "stdClass" unicode(0) "" unicode(8) "stdClass" bool(true) unicode(7) "A\B\Foo" unicode(3) "A\B" unicode(3) "Foo" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getParentClass.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getParentClass.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getParentClass.phpt --TEST-- ReflectionClass::getParentClass() --CREDITS-- Michelangelo van Dam <dragonbe@gmail.com> #testfest roosendaal on 2008-05-10 --FILE-- <?php class Foo {} class Bar extends Foo {} $rc1 = new ReflectionClass("Bar"); var_dump($rc1->getParentClass()); ?> --EXPECTF-- object(ReflectionClass)#%d (1) { [u"name"]=> unicode(3) "Foo" } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_hasConstant_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_hasConstant_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_hasConstant_basic.phpt --TEST-- ReflectionClass::hasConstant() --CREDITS-- Marc Veldman <marc@ibuildings.nl> #testfest roosendaal on 2008-05-10 --FILE-- <?php //New instance of class C - defined below $rc = new ReflectionClass("C"); //Check if C has constant foo var_dump($rc->hasConstant('foo')); //C should not have constant bar var_dump($rc->hasConstant('bar')); Class C { const foo=1; } ?> --EXPECTF-- bool(true) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_hasMethod_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_hasMethod_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_hasMethod_basic.phpt --TEST-- ReflectionClass::hasMethod() --CREDITS-- Marc Veldman <marc@ibuildings.nl> #testfest roosendaal on 2008-05-10 --FILE-- <?php //New instance of class C - defined below $rc = new ReflectionClass("C"); //Check if C has public method publicFoo var_dump($rc->hasMethod('publicFoo')); //Check if C has protected method protectedFoo var_dump($rc->hasMethod('protectedFoo')); //Check if C has private method privateFoo var_dump($rc->hasMethod('privateFoo')); //Check if C has static method staticFoo var_dump($rc->hasMethod('staticFoo')); //C should not have method bar var_dump($rc->hasMethod('bar')); //Method names are case insensitive var_dump($rc->hasMethod('PUBLICfOO')); Class C { public function publicFoo() { return true; } protected function protectedFoo() { return true; } private function privateFoo() { return true; } static function staticFoo() { return true; } } ?> --EXPECTF-- bool(true) bool(true) bool(true) bool(true) bool(false) bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_hasProperty_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_hasProperty_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_hasProperty_basic.phpt --TEST-- ReflectionClass::hasProperty() --CREDITS-- Marc Veldman <marc@ibuildings.nl> #testfest roosendaal on 2008-05-10 --FILE-- <?php //New instance of class C - defined below $rc = new ReflectionClass("C"); //Check if C has public property publicFoo var_dump($rc->hasProperty('publicFoo')); //Check if C has protected property protectedFoo var_dump($rc->hasProperty('protectedFoo')); //Check if C has private property privateFoo var_dump($rc->hasProperty('privateFoo')); //Check if C has static property staticFoo var_dump($rc->hasProperty('staticFoo')); //C should not have property bar var_dump($rc->hasProperty('bar')); Class C { public $publicFoo; protected $protectedFoo; private $privateFoo; public static $staticFoo; } ?> --EXPECTF-- bool(true) bool(true) bool(true) bool(true) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isAbstract_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isAbstract_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isAbstract_basic.phpt --TEST-- ReflectionClass::isAbstract() method --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> #testfest roosendaal on 2008-05-10 --FILE-- <?php class TestClass {} abstract class TestAbstractClass {} $testClass = new ReflectionClass('TestClass'); $abstractClass = new ReflectionClass('TestAbstractClass'); var_dump($testClass->isAbstract()); var_dump($abstractClass->isAbstract()); ?> --EXPECT-- bool(false) bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isFinal_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isFinal_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isFinal_basic.phpt --TEST-- ReflectionClass::isFinal() method --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> #testfest roosendaal on 2008-05-10 --FILE-- <?php class TestClass {} final class TestFinalClass {} $normalClass = new ReflectionClass('TestClass'); $finalClass = new ReflectionClass('TestFinalClass'); var_dump($normalClass->isFinal()); var_dump($finalClass->isFinal()); ?> --EXPECT-- bool(false) bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt --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(true) 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(true) 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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInstance_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInstance_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInstance_error.phpt --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, 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 http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt --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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt --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: ReflectionClass::isInstantiable() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt --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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInterface_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInterface_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInterface_basic.phpt --TEST-- ReflectionClass::isInterface() method --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> #testfest roosendaal on 2008-05-10 --FILE-- <?php interface TestInterface {} class TestClass {} interface DerivedInterface extends TestInterface {} $reflectionClass = new ReflectionClass('TestInterface'); $reflectionClass2 = new ReflectionClass('TestClass'); $reflectionClass3 = new ReflectionClass('DerivedInterface'); var_dump($reflectionClass->isInterface()); var_dump($reflectionClass2->isInterface()); var_dump($reflectionClass3->isInterface()); ?> --EXPECT-- bool(true) bool(false) bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt --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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInternal_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInternal_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInternal_error.phpt --TEST-- ReflectionClass::isInternal() - invalid params --FILE-- <?php $r1 = new ReflectionClass("stdClass"); var_dump($r1->isInternal('X')); var_dump($r1->isInternal('X', true)); ?> --EXPECTF-- Warning: ReflectionClass::isInternal() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::isInternal() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt --TEST-- ReflectionClass::isIterateable() basic --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com>, Marc Veldman <marc@ibuildings.nl> --FILE-- <?php class IteratorClass implements Iterator { public function __construct() { } public function key() {} public function current() {} function next() {} function valid() {} function rewind() {} } class DerivedClass extends IteratorClass {} class NonIterator {} function dump_iterateable($class) { $reflection = new ReflectionClass($class); var_dump($reflection->isIterateable()); } $classes = array("ArrayObject", "IteratorClass", "DerivedClass", "NonIterator"); foreach ($classes as $class) { echo "Is $class iterateable? "; dump_iterateable($class); } ?> --EXPECT-- Is ArrayObject iterateable? bool(true) Is IteratorClass iterateable? bool(true) Is DerivedClass iterateable? bool(true) Is NonIterator iterateable? bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt --TEST-- ReflectionClass::isIterateable() variations --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --FILE-- <?php class BasicClass {} function dump_iterateable($obj) { $reflection = new ReflectionClass($obj); var_dump($reflection->isIterateable()); } $basicClass = new BasicClass(); $stdClass = new StdClass(); dump_iterateable($basicClass); dump_iterateable($stdClass); ?> --EXPECT-- bool(false) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt --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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt --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 http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt --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 http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt --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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt --TEST-- ReflectionClass::isUserDefined() - invalid params. --FILE-- <?php $r1 = new ReflectionClass("stdClass"); var_dump($r1->isUserDefined('X')); var_dump($r1->isUserDefined('X', true)); ?> --EXPECTF-- Warning: ReflectionClass::isUserDefined() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::isUserDefined() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt --TEST-- ReflectionExtension::__construct() --CREDITS-- Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php $obj = new ReflectionExtension('reflection'); $test = $obj instanceof ReflectionExtension; var_dump($test); ?> ==DONE== --EXPECT-- bool(true) ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_constructor_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_constructor_error.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_constructor_error.phpt --TEST-- ReflectionExtension::__construct() --CREDITS-- Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php $obj = new ReflectionExtension(); $test = $obj instanceof ReflectionExtension; var_dump($test); ?> ==DONE== --EXPECTF-- Warning: ReflectionExtension::__construct() expects exactly %d parameter, %d given in %s.php on line %d bool(true) ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_export_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_export_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_export_basic.phpt --TEST-- ReflectionExtension::export() --CREDITS-- Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php ob_start(); ReflectionExtension::export("reflection", true); $test = ob_get_clean(); var_dump(empty($test)); unset($test); ob_start(); ReflectionExtension::export("reflection", false); $test = ob_get_clean(); var_dump(empty($test)); ?> ==DONE== --EXPECT-- bool(true) bool(false) ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt --TEST-- ReflectionExtension::getClassNames() method on an extension which acually returns some information --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --FILE-- <?php $standard = new ReflectionExtension('standard'); var_dump($standard->getClassNames()); ?> ==DONE== --EXPECTF-- array(3) { [0]=> %s(22) "__PHP_Incomplete_Class" [1]=> %s(15) "php_user_filter" [2]=> %s(9) "Directory" } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt --TEST-- ReflectionExtension::getClassNames() method on an extension with no classes --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --FILE-- <?php $ereg = new ReflectionExtension('ereg'); var_dump($ereg->getClassNames()); ?> ==DONE== --EXPECT-- array(0) { } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt --TEST-- ReflectionExtension::getClasses(); --CREDITS-- Thijs Lensselink <tl@lenss.nl> --FILE-- <?php $ext = new ReflectionExtension('reflection'); var_dump($ext->getClasses()); ?> ==DONE== --EXPECTF-- array(11) { [%s"ReflectionException"]=> &object(ReflectionClass)#2 (1) { [%s"name"]=> unicode(19) "ReflectionException" } [%s"Reflection"]=> &object(ReflectionClass)#3 (1) { [%s"name"]=> unicode(10) "Reflection" } [%s"Reflector"]=> &object(ReflectionClass)#4 (1) { [%s"name"]=> unicode(9) "Reflector" } [%s"ReflectionFunctionAbstract"]=> &object(ReflectionClass)#5 (1) { [%s"name"]=> unicode(26) "ReflectionFunctionAbstract" } [%s"ReflectionFunction"]=> &object(ReflectionClass)#6 (1) { [%s"name"]=> unicode(18) "ReflectionFunction" } [%s"ReflectionParameter"]=> &object(ReflectionClass)#7 (1) { [%s"name"]=> unicode(19) "ReflectionParameter" } [%s"ReflectionMethod"]=> &object(ReflectionClass)#8 (1) { [%s"name"]=> unicode(16) "ReflectionMethod" } [%s"ReflectionClass"]=> &object(ReflectionClass)#9 (1) { [%s"name"]=> unicode(15) "ReflectionClass" } [%s"ReflectionObject"]=> &object(ReflectionClass)#10 (1) { [%s"name"]=> unicode(16) "ReflectionObject" } [%s"ReflectionProperty"]=> &object(ReflectionClass)#11 (1) { [%s"name"]=> unicode(18) "ReflectionProperty" } [%s"ReflectionExtension"]=> &object(ReflectionClass)#12 (1) { [%s"name"]=> unicode(19) "ReflectionExtension" } } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt --TEST-- ReflectionExtension::getDependencies() method on an extension with a required and conflicting dependency --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --SKIPIF-- <?php if (!extension_loaded("dom")) die("skip no dom extension"); ?> --FILE-- <?php $dom = new ReflectionExtension('dom'); var_dump($dom->getDependencies()); ?> ==DONE== --EXPECTF-- array(2) { [%s"libxml"]=> %s(8) "Required" [%s"domxml"]=> %s(9) "Conflicts" } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt --TEST-- ReflectionExtension::getDependencies() method on an extension with one optional dependency --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --FILE-- <?php $standard = new ReflectionExtension('standard'); var_dump($standard->getDependencies()); ?> ==DONE== --EXPECTF-- array(1) { [%s"session"]=> %s(8) "Optional" } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getName_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getName_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getName_basic.phpt --TEST-- ReflectionExtension::getName() --CREDITS-- Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php $obj = new ReflectionExtension('reflection'); var_dump($obj->getName()); ?> ==DONE== --EXPECTF-- %s(10) "Reflection" ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt --TEST-- ReflectionExtension::getVersion() --CREDITS-- Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php $obj = new ReflectionExtension('reflection'); $var = $obj->getVersion() ? $obj->getVersion() : null; $test = floatval($var) == $var ? true : false; var_dump($test); ?> ==DONE== --EXPECT-- bool(true) ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_info_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_info_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_info_basic.phpt --TEST-- ReflectionExtension::info() --CREDITS-- Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php $obj = new ReflectionExtension('reflection'); ob_start(); $testa = $obj->info(); $testb = ob_get_clean(); var_dump($testa); var_dump(strlen($testb) > 24); ?> ==DONE== --EXPECT-- NULL bool(true) ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_FileInfo_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_FileInfo_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_FileInfo_basic.phpt --TEST-- ReflectionObject::getFileName(), ReflectionObject::getStartLine(), ReflectionObject::getEndLine() - basic function --FILE-- <?php $rc = new ReflectionObject(new C); var_dump($rc->getFileName()); var_dump($rc->getStartLine()); var_dump($rc->getEndLine()); $rc = new ReflectionObject(new stdclass); var_dump($rc->getFileName()); var_dump($rc->getStartLine()); var_dump($rc->getEndLine()); Class C { } ?> --EXPECTF-- unicode(%d) "%sReflectionObject_FileInfo_basic.php" int(12) int(14) bool(false) bool(false) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt --TEST-- ReflectionObject::getFileName(), ReflectionObject::getStartLine(), ReflectionObject::getEndLine() -invalid aparams --FILE-- <?php Class C { } $rc = new ReflectionObject(new C); $methods = array("getFileName", "getStartLine", "getEndLine"); foreach ($methods as $method) { var_dump($rc->$method()); var_dump($rc->$method(null)); var_dump($rc->$method('X', 0)); } ?> --EXPECTF-- unicode(%d) "%s" Warning: ReflectionClass::getFileName() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getFileName() expects exactly 0 parameters, 2 given in %s on line %d NULL int(2) Warning: ReflectionClass::getStartLine() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getStartLine() expects exactly 0 parameters, 2 given in %s on line %d NULL int(2) Warning: ReflectionClass::getEndLine() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getEndLine() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject___toString_basic1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject___toString_basic1.phpt +++ php-src/ext/reflection/tests/ReflectionObject___toString_basic1.phpt --TEST-- ReflectionObject::__toString() : very basic test with no dynamic properties --FILE-- <?php class Foo { public $bar = 1; } $f = new foo; echo new ReflectionObject($f); ?> --EXPECTF-- Object of class [ <user> class Foo ] { @@ %s 3-5 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ <default> public $bar ] } - Dynamic properties [0] { } - Methods [0] { } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject___toString_basic2.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject___toString_basic2.phpt +++ php-src/ext/reflection/tests/ReflectionObject___toString_basic2.phpt --TEST-- ReflectionObject::__toString() : very basic test with dynamic properties --FILE-- <?php class Foo { public $bar = 1; } $f = new foo; $f->dynProp = 'hello'; $f->dynProp2 = 'hello again'; echo new ReflectionObject($f); ?> --EXPECTF-- Object of class [ <user> class Foo ] { @@ %s 3-5 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ <default> public $bar ] } - Dynamic properties [2] { Property [ <dynamic> public $dynProp ] Property [ <dynamic> public $dynProp2 ] } - Methods [0] { } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_constructor_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_constructor_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_constructor_basic.phpt --TEST-- ReflectionObject::__construct - basic function test --FILE-- <?php $r1 = new ReflectionObject(new stdClass); var_dump($r1); class C { } $myInstance = new C; $r2 = new ReflectionObject($myInstance); var_dump($r2); $r3 = new ReflectionObject($r2); var_dump($r3); ?> --EXPECTF-- object(ReflectionObject)#%d (1) { [u"name"]=> unicode(8) "stdClass" } object(ReflectionObject)#%d (1) { [u"name"]=> unicode(1) "C" } object(ReflectionObject)#%d (1) { [u"name"]=> unicode(16) "ReflectionObject" } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_constructor_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_constructor_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_constructor_error.phpt --TEST-- ReflectionObject::__construct - invalid arguments --FILE-- <?php var_dump(new ReflectionObject()); var_dump(new ReflectionObject('stdClass')); $myInstance = new stdClass; var_dump(new ReflectionObject($myInstance, $myInstance)); var_dump(new ReflectionObject(0)); var_dump(new ReflectionObject(null)); var_dump(new ReflectionObject(array(1,2))); ?> --EXPECTF-- Warning: ReflectionObject::__construct() expects exactly 1 parameter, 0 given in %s on line 3 object(ReflectionObject)#%d (1) { [u"name"]=> unicode(0) "" } Warning: ReflectionObject::__construct() expects parameter 1 to be object, Unicode string given in %s on line 4 object(ReflectionObject)#%d (1) { [u"name"]=> unicode(0) "" } Warning: ReflectionObject::__construct() expects exactly 1 parameter, 2 given in %s on line 6 object(ReflectionObject)#%d (1) { [u"name"]=> unicode(0) "" } Warning: ReflectionObject::__construct() expects parameter 1 to be object, integer given in %s on line 7 object(ReflectionObject)#%d (1) { [u"name"]=> unicode(0) "" } Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in %s on line 8 object(ReflectionObject)#%d (1) { [u"name"]=> unicode(0) "" } Warning: ReflectionObject::__construct() expects parameter 1 to be object, array given in %s on line 9 object(ReflectionObject)#%d (1) { [u"name"]=> unicode(0) "" } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_export_basic1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_export_basic1.phpt +++ php-src/ext/reflection/tests/ReflectionObject_export_basic1.phpt --TEST-- ReflectionObject::export() : very basic test with no dynamic properties --FILE-- <?php class Foo { public $bar = 1; } $f = new foo; ReflectionObject::export($f); ?> --EXPECTF-- Object of class [ <user> class Foo ] { @@ %s 3-5 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ <default> public $bar ] } - Dynamic properties [0] { } - Methods [0] { } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_export_basic2.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_export_basic2.phpt +++ php-src/ext/reflection/tests/ReflectionObject_export_basic2.phpt --TEST-- ReflectionObject::export() : very basic test with dynamic properties --FILE-- <?php class Foo { public $bar = 1; } $f = new foo; $f->dynProp = 'hello'; $f->dynProp2 = 'hello again'; ReflectionObject::export($f); ?> --EXPECTF-- Object of class [ <user> class Foo ] { @@ %s 3-5 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ <default> public $bar ] } - Dynamic properties [2] { Property [ <dynamic> public $dynProp ] Property [ <dynamic> public $dynProp2 ] } - Methods [0] { } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_export_basic3.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_export_basic3.phpt +++ php-src/ext/reflection/tests/ReflectionObject_export_basic3.phpt --TEST-- ReflectionObject::export() - ensure dynamic property with same name as inherited private property is shown. --FILE-- <?php class C { private $p = 1; } class D extends C{ } $Obj = new D; $Obj->p = 'value'; ReflectionObject::export($Obj) ?> --EXPECTF-- Object of class [ <user> class D extends C ] { @@ %s 6-7 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Dynamic properties [0] { } - Methods [0] { } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt --TEST-- ReflectionObject::getConstant() basic function test --FILE-- <?php class C { const a = 'hello from C'; } class D extends C { } class E extends D { } class F extends E { const a = 'hello from F'; } class X { } $classes = array("C", "D", "E", "F", "X"); foreach($classes as $class) { echo "Reflecting on instance of class $class: \n"; $rc = new ReflectionObject(new $class); var_dump($rc->getConstant('a')); var_dump($rc->getConstant('doesntexist')); } ?> --EXPECTF-- Reflecting on instance of class C: unicode(12) "hello from C" bool(false) Reflecting on instance of class D: unicode(12) "hello from C" bool(false) Reflecting on instance of class E: unicode(12) "hello from C" bool(false) Reflecting on instance of class F: unicode(12) "hello from F" bool(false) Reflecting on instance of class X: bool(false) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getConstant_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getConstant_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getConstant_error.phpt --TEST-- ReflectionObject::getConstant() - invalid params --FILE-- <?php class C { const myConst = 1; } $rc = new ReflectionObject(new C); var_dump($rc->getConstant()); var_dump($rc->getConstant("myConst", "myConst")); var_dump($rc->getConstant(null)); var_dump($rc->getConstant(1)); var_dump($rc->getConstant(1.5)); var_dump($rc->getConstant(true)); var_dump($rc->getConstant(array(1,2,3))); var_dump($rc->getConstant(new C)); ?> --EXPECTF-- Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 0 given in %s on line 7 NULL Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 2 given in %s on line 8 NULL bool(false) bool(false) bool(false) bool(false) Warning: ReflectionClass::getConstant() expects parameter 1 to be string (Unicode or binary), array given in %s on line 13 NULL Warning: ReflectionClass::getConstant() expects parameter 1 to be string (Unicode or binary), object given in %s on line 14 NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt --TEST-- ReflectionObject::getConstants() - basic function test --FILE-- <?php class C { const a = 'hello from C'; } class D extends C { } class E extends D { } class F extends E { const a = 'hello from F'; } class X { } $classes = array("C", "D", "E", "F", "X"); foreach($classes as $class) { echo "Reflecting on instance of class $class: \n"; $rc = new ReflectionObject(new $class); var_dump($rc->getConstants()); } ?> --EXPECTF-- Reflecting on instance of class C: array(1) { [u"a"]=> unicode(12) "hello from C" } Reflecting on instance of class D: array(1) { [u"a"]=> unicode(12) "hello from C" } Reflecting on instance of class E: array(1) { [u"a"]=> unicode(12) "hello from C" } Reflecting on instance of class F: array(1) { [u"a"]=> unicode(12) "hello from F" } Reflecting on instance of class X: array(0) { } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getConstants_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getConstants_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getConstants_error.phpt --TEST-- ReflectionObject::getConstants() - invalid params --FILE-- <?php class X { } $rc = new ReflectionObject(new X); $rc->getConstants('X'); $rc->getConstants(true); ?> --EXPECTF-- Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt --TEST-- ReflectionObject::getConstructor() - basic function test --FILE-- <?php class NewCtor { function __construct() {} } class ExtendsNewCtor extends NewCtor { } class OldCtor { function OldCtor() {} } class ExtendsOldCtor extends OldCtor { } class X { function Y() {} } class Y extends X { } class OldAndNewCtor { function OldAndNewCtor() {} function __construct() {} } class NewAndOldCtor { function __construct() {} function NewAndOldCtor() {} } class B { function B() {} } class C extends B { function C() {} } class D1 extends C { function __construct() {} } class D2 extends C { } $classes = array('NewCtor', 'ExtendsNewCtor', 'OldCtor', 'ExtendsOldCtor', 'OldAndNewCtor', 'NewAndOldCtor', 'B', 'C', 'D1', 'D2', 'X', 'Y'); foreach ($classes as $class) { $rc = new ReflectionObject(new $class); $rm = $rc->getConstructor(); if ($rm != null) { echo "Constructor of $class: " . $rm->getName() . "\n"; } else { echo "No constructor for $class\n"; } } ?> --EXPECTF-- Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line 26 Strict Standards: %s for class NewAndOldCtor in %s on line 31 Constructor of NewCtor: __construct Constructor of ExtendsNewCtor: __construct Constructor of OldCtor: OldCtor Constructor of ExtendsOldCtor: OldCtor Constructor of OldAndNewCtor: __construct Constructor of NewAndOldCtor: __construct Constructor of B: B Constructor of C: C Constructor of D1: __construct Constructor of D2: C No constructor for X No constructor for Y http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getConstructor_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getConstructor_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getConstructor_error.phpt --TEST-- ReflectionObject::getConstructor() - invalid params --FILE-- <?php class C {} $rc = new ReflectionObject(new C); var_dump($rc->getConstructor(null)); var_dump($rc->getConstructor('X')); var_dump($rc->getConstructor(true)); var_dump($rc->getConstructor(array(1,2,3))); ?> --EXPECTF-- Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getName_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getName_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getName_basic.phpt --TEST-- ReflectionObject::getName() - basic function test --FILE-- <?php $r0 = new ReflectionObject(); var_dump($r0->getName()); $r1 = new ReflectionObject(new stdClass); var_dump($r1->getName()); class C { } $myInstance = new C; $r2 = new ReflectionObject($myInstance); var_dump($r2->getName()); $r3 = new ReflectionObject($r2); var_dump($r3->getName()); ?> --EXPECTF-- Warning: ReflectionObject::__construct() expects exactly 1 parameter, 0 given in %s on line 2 unicode(0) "" unicode(8) "stdClass" unicode(1) "C" unicode(16) "ReflectionObject" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getName_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getName_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getName_error.phpt --TEST-- ReflectionObject::getname() - invalid params --FILE-- <?php class C { } $myInstance = new C; $r2 = new ReflectionObject($myInstance); $r3 = new ReflectionObject($r2); var_dump($r3->getName(null)); var_dump($r3->getName('x','y')); var_dump($r3->getName(0)); ?> --EXPECTF-- Warning: ReflectionClass::getName() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getName() expects exactly 0 parameters, 2 given in %s on line %d NULL Warning: ReflectionClass::getName() expects exactly 0 parameters, 1 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getName_error1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getName_error1.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getName_error1.phpt --TEST-- ReflectionObject::getName - forbid static invocation --FILE-- <?php ReflectionObject::getName(); ?> --EXPECTF-- Fatal error: Non-static method ReflectionClass::getName() cannot be called statically in %s on line 2 http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt --TEST-- ReflectionObject::isInstance() - basic function test --FILE-- <?php class A {} class B extends A {} class X {} $classes = array("A", "B", "X"); $instances = array( "myA" => new A, "myB" => new B, "myX" => new X ); foreach ($classes as $class) { $ro = new ReflectionObject(new $class); foreach ($instances as $name => $instance) { echo "is $name a $class? "; var_dump($ro->isInstance($instance)); } } ?> --EXPECTF-- is myA a A? bool(true) is myB a A? bool(true) is myX a A? bool(false) is myA a B? bool(false) is myB a B? bool(true) is myX a B? bool(false) is myA a X? bool(false) is myB a X? bool(false) is myX a X? bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInstance_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInstance_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInstance_error.phpt --TEST-- ReflectionObject::isInstance() - invalid params --FILE-- <?php class X {} $instance = new X; $ro = new ReflectionObject(new X); var_dump($ro->isInstance()); var_dump($ro->isInstance($instance, $instance)); var_dump($ro->isInstance(1)); var_dump($ro->isInstance(1.5)); var_dump($ro->isInstance(true)); var_dump($ro->isInstance('X')); var_dump($ro->isInstance(null)); ?> --EXPECTF-- Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 0 given in %s on line 6 NULL Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 2 given in %s on line 7 NULL Warning: ReflectionClass::isInstance() expects parameter 1 to be object, integer given in %s on line 8 NULL Warning: ReflectionClass::isInstance() expects parameter 1 to be object, double given in %s on line 9 NULL Warning: ReflectionClass::isInstance() expects parameter 1 to be object, boolean given in %s on line 10 NULL Warning: ReflectionClass::isInstance() expects parameter 1 to be object, Unicode string given in %s on line 11 NULL Warning: ReflectionClass::isInstance() expects parameter 1 to be object, null given in %s on line 12 NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt --TEST-- ReflectionObject::IsInstantiable() - basic function test --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", "ifaceImpl", "D"); foreach($classes as $class ) { $ro = new ReflectionObject(new $class); echo "Is $class instantiable? "; var_dump($ro->IsInstantiable()); } ?> --EXPECTF-- Is C instantiable? bool(true) Is ifaceImpl instantiable? bool(true) Is D instantiable? bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt --TEST-- ReflectionObject::IsInstantiable() - invalid params --FILE-- <?php class privateCtorOld { private function privateCtorOld() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } $reflectionObject = privateCtorOld::reflectionObjectFactory(); var_dump($reflectionObject->IsInstantiable('X')); var_dump($reflectionObject->IsInstantiable(0, null)); ?> --EXPECTF-- Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt --TEST-- ReflectionObject::IsInstantiable() - variation - constructors --FILE-- <?php class noCtor { public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } class publicCtorNew { public function __construct() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } class protectedCtorNew { protected function __construct() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } class privateCtorNew { private function __construct() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } class publicCtorOld { public function publicCtorOld() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } class protectedCtorOld { protected function protectedCtorOld() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } class privateCtorOld { private function privateCtorOld() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } $reflectionObjects = array( noCtor::reflectionObjectFactory(), publicCtorNew::reflectionObjectFactory(), protectedCtorNew::reflectionObjectFactory(), privateCtorNew::reflectionObjectFactory(), publicCtorOld::reflectionObjectFactory(), protectedCtorOld::reflectionObjectFactory(), privateCtorOld::reflectionObjectFactory() ); foreach($reflectionObjects as $reflectionObject ) { $name = $reflectionObject->getName(); echo "Is $name instantiable? "; var_dump($reflectionObject->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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt --TEST-- ReflectionObject::isInternal() - basic function test --FILE-- <?php class C { } $r1 = new ReflectionObject(new stdClass); $r2 = new ReflectionObject(new ReflectionClass('C')); $r3 = new ReflectionObject(new ReflectionProperty('Exception', 'message')); $r4 = new ReflectionObject(new Exception); $r5 = new ReflectionObject(new C); var_dump($r1->isInternal(), $r2->isInternal(), $r3->isInternal(), $r4->isInternal(), $r5->isInternal()); ?> --EXPECTF-- bool(true) bool(true) bool(true) bool(true) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInternal_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInternal_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInternal_error.phpt --TEST-- ReflectionObject::isInternal() - invalid params --FILE-- <?php $r1 = new ReflectionObject(new stdClass); var_dump($r1->isInternal('X')); var_dump($r1->isInternal('X', true)); ?> --EXPECTF-- Warning: ReflectionClass::isInternal() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::isInternal() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt --TEST-- ReflectionObject::isSubclassOf() - basic function test --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'); //Create ReflectionClasses foreach ($classNames as $className) { $rcs[$className] = new ReflectionClass($className); } //Create ReflectionObjects foreach ($classNames as $className) { if ($rcs[$className]->isInstantiable()) { $ros[$className] = new ReflectionObject(new $className); } } foreach ($ros as $childName => $child) { foreach ($rcs as $parentName => $parent) { echo "Is " . $childName . " a subclass of " . $parentName . "? \n"; echo " - Using ReflectionClass object argument: "; var_dump($child->isSubclassOf($parent)); if ($parent->isInstantiable()) { echo " - Using ReflectionObject object argument: "; var_dump($child->isSubclassOf($ros[$parentName])); } echo " - Using string argument: "; var_dump($child->isSubclassOf($parentName)); } } ?> --EXPECTF-- Is A a subclass of A? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is A a subclass of B? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is A a subclass of C? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is A a subclass of I? - Using ReflectionClass object argument: bool(false) - Using string argument: bool(false) Is A a subclass of X? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is B a subclass of A? - Using ReflectionClass object argument: bool(true) - Using ReflectionObject object argument: bool(true) - Using string argument: bool(true) Is B a subclass of B? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is B a subclass of C? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is B a subclass of I? - Using ReflectionClass object argument: bool(false) - Using string argument: bool(false) Is B a subclass of X? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is C a subclass of A? - Using ReflectionClass object argument: bool(true) - Using ReflectionObject object argument: bool(true) - Using string argument: bool(true) Is C a subclass of B? - Using ReflectionClass object argument: bool(true) - Using ReflectionObject object argument: bool(true) - Using string argument: bool(true) Is C a subclass of C? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is C a subclass of I? - Using ReflectionClass object argument: bool(false) - Using string argument: bool(false) Is C a subclass of X? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is X a subclass of A? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is X a subclass of B? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is X a subclass of C? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is X a subclass of I? - Using ReflectionClass object argument: bool(true) - Using string argument: bool(true) Is X a subclass of X? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt --TEST-- ReflectionObject::isSubclassOf() - invalid params --FILE-- <?php class A {} $ro = new ReflectionObject(new A); var_dump($ro->isSubclassOf()); var_dump($ro->isSubclassOf('A',5)); var_dump($ro->isSubclassOf('X')); ?> --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 Fatal error: Uncaught exception 'ReflectionException' with message 'Class X does not exist' in %s:7 Stack trace: #0 %s(7): ReflectionClass->isSubclassOf('X') #1 {main} thrown in %s on line 7 http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt --TEST-- ReflectionObject::isUserDefined() - basic function test --FILE-- <?php class C { } $r1 = new ReflectionObject(new stdClass); $r2 = new ReflectionObject(new ReflectionClass('C')); $r3 = new ReflectionObject(new ReflectionProperty('Exception', 'message')); $r4 = new ReflectionObject(new Exception); $r5 = new ReflectionObject(new C); var_dump($r1->isUserDefined(), $r2->isUserDefined(), $r3->isUserDefined(), $r4->isUserDefined(), $r5->isUserDefined()); ?> --EXPECTF-- bool(false) bool(false) bool(false) bool(false) bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt --TEST-- ReflectionObject::isUserDefined() - invalid params --FILE-- <?php $r1 = new ReflectionObject(new stdClass); var_dump($r1->isUserDefined('X')); var_dump($r1->isUserDefined('X', true)); ?> --EXPECTF-- Warning: ReflectionClass::isUserDefined() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::isUserDefined() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_export_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_export_basic.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_export_basic.phpt --TEST-- ReflectionParameter::export() --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); foreach($reflect->getParameters() as $key => $value) { echo ReflectionParameter::export('ReflectionParameterTest', $key); } ?> ==DONE== --EXPECT-- Parameter #0 [ <required> $test ] Parameter #1 [ <optional> $test2 = NULL ] ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_export_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_export_error.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_export_error.phpt --TEST-- ReflectionParameter::export() without parameters --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); foreach($reflect->getParameters() as $key => $value) { ReflectionParameter::export(); } ?> ==DONE== --EXPECTF-- Warning: ReflectionParameter::export() expects at least 2 parameters, 0 given in %s.php on line %d Warning: ReflectionParameter::export() expects at least 2 parameters, 0 given in %s.php on line %d ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_export_error2.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_export_error2.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_export_error2.phpt --TEST-- ReflectionParameter::export() with incorrect first parameter --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); $params = $reflect->getParameters(); try { foreach($params as $key => $value) { ReflectionParameter::export($reflect, $key); } } catch (ReflectionException $e) { echo $e->getMessage() . "\n"; } try { foreach($params as $key => $value) { ReflectionParameter::export(42, $key); } } catch (ReflectionException $e) { echo $e->getMessage() . "\n"; } ?> --EXPECTF-- Method ReflectionFunction::__invoke() does not exist The parameter class is expected to be either a string, an array(class, method) or a callable object http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_export_error3.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_export_error3.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_export_error3.phpt --TEST-- ReflectionParameter::export() with incorrect second parameter --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); $params = $reflect->getParameters(); foreach($params as $key => $value) { ReflectionParameter::export('ReflectionParameterTest', 'incorrect_parameter'); } --EXPECTF-- Fatal error: Uncaught exception 'ReflectionException' with message 'The parameter specified by its name could not be found' in %s.php:%d Stack trace: #0 [internal function]: ReflectionParameter->__construct('ReflectionParam...', 'incorrect_param...') #1 %s.php(%d): ReflectionParameter::export('ReflectionParam...', 'incorrect_param...') #2 {main} thrown in %s.php on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt --TEST-- ReflectionParameter::getDeclaringFunction() --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> #testfest roosendaal on 2008-05-10 --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); $params = $reflect->getParameters(); foreach($params as $key => $value) { echo $value->getDeclaringFunction() . "\n"; } ?> ==DONE== --EXPECTF-- Function [ <user> function ReflectionParameterTest ] { @@ %s.php %d - %d - Parameters [2] { Parameter #0 [ <required> $test ] Parameter #1 [ <optional> $test2 = NULL ] } } Function [ <user> function ReflectionParameterTest ] { @@ %s.php %d - %d - Parameters [2] { Parameter #0 [ <required> $test ] Parameter #1 [ <optional> $test2 = NULL ] } } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt --TEST-- ReflectionParameter::getPosition() --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> #testfest roosendaal on 2008-05-10 --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); $params = $reflect->getParameters(); foreach($params as $key => $value) { var_dump($value->getPosition()); } ?> ==DONE== --EXPECT-- int(0) int(1) ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt --TEST-- ReflectionParameter::__construct(): Invalid method as constructor --FILE-- <?php // Invalid class name try { new ReflectionParameter (array ('A', 'b'), 0); } catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } // Invalid class method try { new ReflectionParameter (array ('C', 'b'), 0); } catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } // Invalid object method try { new ReflectionParameter (array (new C, 'b'), 0); } catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } echo "Done.\n"; class C { } ?> --EXPECTF-- Class A does not exist Method C::b() does not exist Method C::b() does not exist Done. http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_toString_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_toString_basic.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_toString_basic.phpt --TEST-- ReflectionParameter::__toString() --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); $params = $reflect->getParameters(); foreach($params as $key => $value) { echo $value->__toString() . "\n"; } ?> ==DONE== --EXPECT-- Parameter #0 [ <required> $test ] Parameter #1 [ <optional> $test2 = NULL ] ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_basic1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_basic1.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_basic1.phpt --TEST-- Test usage of ReflectionProperty methods __toString(), export(), getName(), isPublic(), isPrivate(), isProtected(), isStatic(), getValue() and setValue(). --FILE-- <?php function reflectProperty($class, $property) { $propInfo = new ReflectionProperty($class, $property); echo "**********************************\n"; echo "Reflecting on property $class::$property\n\n"; echo "__toString():\n"; var_dump($propInfo->__toString()); echo "export():\n"; var_dump(ReflectionProperty::export($class, $property, true)); echo "export():\n"; var_dump(ReflectionProperty::export($class, $property, false)); echo "getName():\n"; var_dump($propInfo->getName()); echo "isPublic():\n"; var_dump($propInfo->isPublic()); echo "isPrivate():\n"; var_dump($propInfo->isPrivate()); echo "isProtected():\n"; var_dump($propInfo->isProtected()); echo "isStatic():\n"; var_dump($propInfo->isStatic()); $instance = new $class(); if ($propInfo->isPublic()) { echo "getValue():\n"; var_dump($propInfo->getValue($instance)); $propInfo->setValue($instance, "NewValue"); echo "getValue() after a setValue():\n"; var_dump($propInfo->getValue($instance)); } echo "\n**********************************\n"; } class TestClass { public $pub; static public $stat = "static property"; protected $prot = 4; private $priv = "keepOut"; } reflectProperty("TestClass", "pub"); reflectProperty("TestClass", "stat"); reflectProperty("TestClass", "prot"); reflectProperty("TestClass", "priv"); ?> --EXPECT-- ********************************** Reflecting on property TestClass::pub __toString(): unicode(35) "Property [ <default> public $pub ] " export(): unicode(35) "Property [ <default> public $pub ] " export(): Property [ <default> public $pub ] NULL getName(): unicode(3) "pub" isPublic(): bool(true) isPrivate(): bool(false) isProtected(): bool(false) isStatic(): bool(false) getValue(): NULL getValue() after a setValue(): unicode(8) "NewValue" ********************************** ********************************** Reflecting on property TestClass::stat __toString(): unicode(33) "Property [ public static $stat ] " export(): unicode(33) "Property [ public static $stat ] " export(): Property [ public static $stat ] NULL getName(): unicode(4) "stat" isPublic(): bool(true) isPrivate(): bool(false) isProtected(): bool(false) isStatic(): bool(true) getValue(): unicode(15) "static property" getValue() after a setValue(): unicode(8) "NewValue" ********************************** ********************************** Reflecting on property TestClass::prot __toString(): unicode(39) "Property [ <default> protected $prot ] " export(): unicode(39) "Property [ <default> protected $prot ] " export(): Property [ <default> protected $prot ] NULL getName(): unicode(4) "prot" isPublic(): bool(false) isPrivate(): bool(false) isProtected(): bool(true) isStatic(): bool(false) ********************************** ********************************** Reflecting on property TestClass::priv __toString(): unicode(37) "Property [ <default> private $priv ] " export(): unicode(37) "Property [ <default> private $priv ] " export(): Property [ <default> private $priv ] NULL getName(): unicode(4) "priv" isPublic(): bool(false) isPrivate(): bool(true) isProtected(): bool(false) isStatic(): bool(false) ********************************** http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_basic2.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_basic2.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_basic2.phpt --TEST-- Test usage of ReflectionProperty methods isDefault(), getModifiers(), getDeclaringClass() and getDocComment(). --FILE-- <?php function reflectProperty($class, $property) { $propInfo = new ReflectionProperty($class, $property); echo "**********************************\n"; echo "Reflecting on property $class::$property\n\n"; echo "isDefault():\n"; var_dump($propInfo->isDefault()); echo "getModifiers():\n"; var_dump($propInfo->getModifiers()); echo "getDeclaringClass():\n"; var_dump($propInfo->getDeclaringClass()); echo "getDocComment():\n"; var_dump($propInfo->getDocComment()); echo "\n**********************************\n"; } class TestClass { public $pub; static public $stat = "static property"; /** * This property has a comment. */ protected $prot = 4; private $priv = "keepOut"; } reflectProperty("TestClass", "pub"); reflectProperty("TestClass", "stat"); reflectProperty("TestClass", "prot"); reflectProperty("TestClass", "priv"); ?> --EXPECTF-- ********************************** Reflecting on property TestClass::pub isDefault(): bool(true) getModifiers(): int(256) getDeclaringClass(): object(ReflectionClass)#%d (1) { [u"name"]=> unicode(9) "TestClass" } getDocComment(): bool(false) ********************************** ********************************** Reflecting on property TestClass::stat isDefault(): bool(true) getModifiers(): int(257) getDeclaringClass(): object(ReflectionClass)#%d (1) { [u"name"]=> unicode(9) "TestClass" } getDocComment(): bool(false) ********************************** ********************************** Reflecting on property TestClass::prot isDefault(): bool(true) getModifiers(): int(512) getDeclaringClass(): object(ReflectionClass)#%d (1) { [u"name"]=> unicode(9) "TestClass" } getDocComment(): unicode(47) "/** * This property has a comment. */" ********************************** ********************************** Reflecting on property TestClass::priv isDefault(): bool(true) getModifiers(): int(1024) getDeclaringClass(): object(ReflectionClass)#%d (1) { [u"name"]=> unicode(9) "TestClass" } getDocComment(): bool(false) ********************************** http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_constructor_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_constructor_error.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_constructor_error.phpt --TEST-- Test ReflectionProperty class constructor errors. --FILE-- <?php class TestClass { } $a = 5; echo "Non-existent class:\n"; try { $propInfo = new ReflectionProperty("NonExistentClass", "prop"); } catch(Exception $e) { echo $e->getMessage(); } echo "\n\nWrong property parameter type:\n"; try { $propInfo = new ReflectionProperty($a, 'TestClass'); } catch(ReflectionException $e) { echo $e->getMessage(); } echo "\n\nNon-existent property:\n"; try { $propInfo = new ReflectionProperty('TestClass', "nonExistentProperty"); } catch(Exception $e) { echo $e->getMessage(); } ?> --EXPECT-- Non-existent class: Class NonExistentClass does not exist Wrong property parameter type: The parameter class is expected to be either a string or an object Non-existent property: Property TestClass::$nonExistentProperty does not exist http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt --TEST-- ReflectionProperty::__construct(): ensure inherited private props can't be accessed through ReflectionProperty. --FILE-- <?php class C { private $p = 1; static function testFromC() { try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); } catch (Exception $e) { echo $e->getMessage(); } } } class D extends C{ static function testFromD() { try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); } catch (Exception $e) { echo $e->getMessage(); } } } echo "--> Reflect inherited private from global scope:\n"; try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); } catch (Exception $e) { echo $e->getMessage(); } echo "\n\n--> Reflect inherited private from declaring scope:\n"; C::testFromC(); echo "\n\n--> Reflect inherited private from declaring scope via subclass:\n"; D::testFromC(); echo "\n\n--> Reflect inherited private from subclass:\n"; D::testFromD(); ?> --EXPECTF-- --> Reflect inherited private from global scope: Property D::$p does not exist --> Reflect inherited private from declaring scope: Property D::$p does not exist --> Reflect inherited private from declaring scope via subclass: Property D::$p does not exist --> Reflect inherited private from subclass: Property D::$p does not exist http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_error.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_error.phpt --TEST-- Test ReflectionProperty class errors. --FILE-- <?php class C { public static $p; } var_dump(new ReflectionProperty()); var_dump(new ReflectionProperty('C::p')); var_dump(new ReflectionProperty('C', 'p', 'x')); $rp = new ReflectionProperty('C', 'p'); var_dump($rp->getName(1)); var_dump($rp->isPrivate(1)); var_dump($rp->isProtected(1)); var_dump($rp->isPublic(1)); var_dump($rp->isStatic(1)); var_dump($rp->getModifiers(1)); var_dump($rp->isDefault(1)); ?> --EXPECTF-- Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 0 given in %s on line %d object(ReflectionProperty)#%d (2) { [u"name"]=> unicode(0) "" [u"class"]=> unicode(0) "" } Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 1 given in %s on line %d object(ReflectionProperty)#%d (2) { [u"name"]=> unicode(0) "" [u"class"]=> unicode(0) "" } Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 3 given in %s on line %d object(ReflectionProperty)#%d (2) { [u"name"]=> unicode(0) "" [u"class"]=> unicode(0) "" } Warning: ReflectionProperty::getName() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::isPrivate() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::isProtected() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::isPublic() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::isStatic() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::getModifiers() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::isDefault() expects exactly 0 parameters, 1 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_export_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_export_basic.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_export_basic.phpt --TEST-- Test ReflectionProperty::export() usage. --FILE-- <?php class TestClass { public $proper = 5; } var_dump(ReflectionProperty::export('TestClass', 'proper')); ?> --EXPECT-- Property [ <default> public $proper ] NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_export_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_export_error.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_export_error.phpt --TEST-- Test ReflectionProperty::export() errors. --FILE-- <?php class TestClass { } $a = 5; echo "Non-existent class:\n"; try { ReflectionProperty::export("NonExistentClass", "prop", true); } catch(Exception $e) { echo $e->getMessage(); } echo "\n\nWrong property parameter type:\n"; try { ReflectionProperty::export($a, 'TestClass', false); } catch(ReflectionException $e) { echo $e->getMessage(); } echo "\n\nNon-existent property:\n"; try { ReflectionProperty::export('TestClass', "nonExistentProperty", true); } catch(Exception $e) { echo $e->getMessage(); } echo "\n\nIncorrect number of args:\n"; ReflectionProperty::export(); ReflectionProperty::export('TestClass', "nonExistentProperty", true, false); ?> --EXPECTF-- Non-existent class: Class NonExistentClass does not exist Wrong property parameter type: The parameter class is expected to be either a string or an object Non-existent property: Property TestClass::$nonExistentProperty does not exist Incorrect number of args: Warning: ReflectionProperty::export() expects at least 2 parameters, 0 given in %s on line %d Warning: ReflectionProperty::export() expects at most 3 parameters, 4 given in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt --TEST-- Test ReflectionProperty::getDeclaringClass() with inherited properties. --FILE-- <?php class A { public $prop; } class B extends A { } $propInfo = new ReflectionProperty('B', 'prop'); var_dump($propInfo->getDeclaringClass()); echo "Wrong number of params:\n"; $propInfo->getDeclaringClass(1); ?> --EXPECTF-- object(ReflectionClass)#%d (1) { [u"name"]=> unicode(1) "A" } Wrong number of params: Warning: ReflectionProperty::getDeclaringClass() expects exactly 0 parameters, 1 given in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_getDocComment_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_getDocComment_basic.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_getDocComment_basic.phpt --TEST-- Test ReflectionProperty::getDocComment() usage. --FILE-- <?php class A { /** * My Doc Comment for $a * */ public $a = 2, $b, $c = 1; /** * My Doc Comment for $d */ var $d; /**Not a doc comment */ private $e; /** * Doc comment for $f */ static protected $f; } class B extends A { public $a = 2; /** A doc comment for $b */ var $b, $c = 1; /** A doc comment for $e */ var $e; } foreach(array('A', 'B') as $class) { $rc = new ReflectionClass($class); $rps = $rc->getProperties(); foreach($rps as $rp) { echo "\n\n---> Doc comment for $class::$" . $rp->getName() . ":\n"; var_dump($rp->getDocComment()); } } ?> --EXPECTF-- ---> Doc comment for A::$a: unicode(47) "/** * My Doc Comment for $a * */" ---> Doc comment for A::$b: bool(false) ---> Doc comment for A::$c: bool(false) ---> Doc comment for A::$d: unicode(40) "/** * My Doc Comment for $d */" ---> Doc comment for A::$e: bool(false) ---> Doc comment for A::$f: unicode(37) "/** * Doc comment for $f */" ---> Doc comment for B::$a: bool(false) ---> Doc comment for B::$b: unicode(27) "/** A doc comment for $b */" ---> Doc comment for B::$c: bool(false) ---> Doc comment for B::$e: unicode(27) "/** A doc comment for $e */" ---> Doc comment for B::$d: unicode(40) "/** * My Doc Comment for $d */" ---> Doc comment for B::$f: unicode(37) "/** * Doc comment for $f */" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt --TEST-- Test ReflectionProperty::getDocComment() errors. --FILE-- <?php class C { public $a; } $rc = new ReflectionProperty('C', 'a'); var_dump($rc->getDocComment(null)); var_dump($rc->getDocComment('X')); var_dump($rc->getDocComment(true)); var_dump($rc->getDocComment(array(1, 2, 3))); ?> --EXPECTF-- Warning: ReflectionProperty::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt --TEST-- Test ReflectionProperty::getModifiers() usage. --FILE-- <?php class C { public $a1; protected $a2; private $a3; static public $a4; static protected $a5; static private $a6; } class D extends C { public $a1; protected $a2; private $a3; static public $a4; static protected $a5; static private $a6; } for ($i = 1;$i <= 6;$i++) { $rp = new ReflectionProperty("C", "a$i"); echo "C::a$i: "; var_dump($rp->getModifiers()); $rp = new ReflectionProperty("D", "a$i"); echo "D::a$i: "; var_dump($rp->getModifiers()); } ?> --EXPECTF-- C::a1: int(256) D::a1: int(256) C::a2: int(512) D::a2: int(512) C::a3: int(1024) D::a3: int(3072) C::a4: int(257) D::a4: int(257) C::a5: int(513) D::a5: int(513) C::a6: int(1025) D::a6: int(3073) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_getValue_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_getValue_error.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_getValue_error.phpt --TEST-- Test ReflectionProperty::getValue() errors. --FILE-- <?php class TestClass { public $pub; public $pub2 = 5; static public $stat = "static property"; protected $prot = 4; private $priv = "keepOut"; } class AnotherClass { } $instance = new TestClass(); $instanceWithNoProperties = new AnotherClass(); $propInfo = new ReflectionProperty('TestClass', 'pub2'); echo "Too few args:\n"; var_dump($propInfo->getValue()); echo "\nToo many args:\n"; var_dump($propInfo->getValue($instance, true)); echo "\nWrong type of arg:\n"; var_dump($propInfo->getValue(true)); echo "\nInstance without property:\n"; $propInfo = new ReflectionProperty('TestClass', 'stat'); echo "\nStatic property / too many args:\n"; var_dump($propInfo->getValue($instance, true)); echo "\nStatic property / wrong type of arg:\n"; var_dump($propInfo->getValue(true)); echo "\nProtected property:\n"; try { $propInfo = new ReflectionProperty('TestClass', 'prot'); var_dump($propInfo->getValue($instance)); } catch(Exception $exc) { echo $exc->getMessage(); } echo "\n\nInstance without property:\n"; $propInfo = new ReflectionProperty('TestClass', 'pub2'); var_dump($propInfo->getValue($instanceWithNoProperties)); ?> --EXPECTF-- Too few args: Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 0 given in %s on line %d NULL Too many args: Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 2 given in %s on line %d NULL Wrong type of arg: Warning: ReflectionProperty::getValue() expects parameter 1 to be object, boolean given in %s on line %d NULL Instance without property: Static property / too many args: unicode(15) "static property" Static property / wrong type of arg: unicode(15) "static property" Protected property: Cannot access non-public member TestClass::prot Instance without property: NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt --TEST-- Test ReflectionProperty::isDefault() usage. --FILE-- <?php function reflectProperty($class, $property) { $propInfo = new ReflectionProperty($class, $property); echo "**********************************\n"; echo "Reflecting on property $class::$property\n\n"; echo "isDefault():\n"; var_dump($propInfo->isDefault()); echo "\n**********************************\n"; } class TestClass { public $pub; static public $stat = "static property"; protected $prot = 4; private $priv = "keepOut"; } reflectProperty("TestClass", "pub"); reflectProperty("TestClass", "stat"); reflectProperty("TestClass", "prot"); reflectProperty("TestClass", "priv"); echo "Wrong number of params:\n"; $propInfo = new ReflectionProperty('TestClass', 'pub'); $propInfo->isDefault(1); ?> --EXPECTF-- ********************************** Reflecting on property TestClass::pub isDefault(): bool(true) ********************************** ********************************** Reflecting on property TestClass::stat isDefault(): bool(true) ********************************** ********************************** Reflecting on property TestClass::prot isDefault(): bool(true) ********************************** ********************************** Reflecting on property TestClass::priv isDefault(): bool(true) ********************************** Wrong number of params: Warning: ReflectionProperty::isDefault() expects exactly 0 parameters, 1 given in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_setAccessible.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_setAccessible.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_setAccessible.phpt --TEST-- Test ReflectionProperty::setAccessible(). --FILE-- <?php class A { protected $protected = 'a'; protected static $protectedStatic = 'b'; private $private = 'c'; private static $privateStatic = 'd'; } class B extends A {} $a = new A; $protected = new ReflectionProperty($a, 'protected'); $protectedStatic = new ReflectionProperty('A', 'protectedStatic'); $private = new ReflectionProperty($a, 'private'); $privateStatic = new ReflectionProperty('A', 'privateStatic'); try { var_dump($protected->getValue($a)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($protectedStatic->getValue()); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($private->getValue($a)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($privateStatic->getValue()); } catch (ReflectionException $e) { var_dump($e->getMessage()); } $protected->setAccessible(TRUE); $protectedStatic->setAccessible(TRUE); $private->setAccessible(TRUE); $privateStatic->setAccessible(TRUE); var_dump($protected->getValue($a)); var_dump($protectedStatic->getValue()); var_dump($private->getValue($a)); var_dump($privateStatic->getValue()); $protected->setValue($a, 'e'); $protectedStatic->setValue('f'); $private->setValue($a, 'g'); $privateStatic->setValue('h'); var_dump($protected->getValue($a)); var_dump($protectedStatic->getValue()); var_dump($private->getValue($a)); var_dump($privateStatic->getValue()); $a = new A; $b = new B; $protected = new ReflectionProperty($b, 'protected'); $protectedStatic = new ReflectionProperty('B', 'protectedStatic'); $private = new ReflectionProperty($a, 'private'); try { var_dump($protected->getValue($b)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($protectedStatic->getValue()); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($private->getValue($b)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } $protected->setAccessible(TRUE); $protectedStatic->setAccessible(TRUE); $private->setAccessible(TRUE); var_dump($protected->getValue($b)); var_dump($protectedStatic->getValue()); var_dump($private->getValue($b)); $protected->setValue($b, 'e'); $protectedStatic->setValue('f'); $private->setValue($b, 'g'); var_dump($protected->getValue($b)); var_dump($protectedStatic->getValue()); var_dump($private->getValue($b)); ?> --EXPECT-- unicode(44) "Cannot access non-public member A::protected" unicode(50) "Cannot access non-public member A::protectedStatic" unicode(42) "Cannot access non-public member A::private" unicode(48) "Cannot access non-public member A::privateStatic" unicode(1) "a" unicode(1) "b" unicode(1) "c" unicode(1) "d" unicode(1) "e" unicode(1) "f" unicode(1) "g" unicode(1) "h" unicode(44) "Cannot access non-public member B::protected" unicode(50) "Cannot access non-public member B::protectedStatic" unicode(42) "Cannot access non-public member A::private" unicode(1) "a" unicode(1) "f" unicode(1) "c" unicode(1) "e" unicode(1) "f" unicode(1) "g" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_setValue_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_setValue_error.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_setValue_error.phpt --TEST-- Test ReflectionProperty::setValue() error cases. --FILE-- <?php class TestClass { public $pub; public $pub2 = 5; static public $stat = "static property"; protected $prot = 4; private $priv = "keepOut"; } class AnotherClass { } $instance = new TestClass(); $instanceWithNoProperties = new AnotherClass(); $propInfo = new ReflectionProperty('TestClass', 'pub2'); echo "Too few args:\n"; var_dump($propInfo->setValue()); var_dump($propInfo->setValue($instance)); echo "\nToo many args:\n"; var_dump($propInfo->setValue($instance, "NewValue", true)); echo "\nWrong type of arg:\n"; var_dump($propInfo->setValue(true, "NewValue")); $propInfo = new ReflectionProperty('TestClass', 'stat'); echo "\nStatic property / too many args:\n"; var_dump($propInfo->setValue($instance, "NewValue", true)); echo "\nStatic property / too few args:\n"; var_dump($propInfo->setValue("A new value")); var_dump(TestClass::$stat); var_dump($propInfo->setValue()); var_dump(TestClass::$stat); echo "\nStatic property / wrong type of arg:\n"; var_dump($propInfo->setValue(true, "Another new value")); var_dump(TestClass::$stat); echo "\nProtected property:\n"; try { $propInfo = new ReflectionProperty('TestClass', 'prot'); var_dump($propInfo->setValue($instance, "NewValue")); } catch(Exception $exc) { echo $exc->getMessage(); } echo "\n\nInstance without property:\n"; $propInfo = new ReflectionProperty('TestClass', 'pub2'); var_dump($propInfo->setValue($instanceWithNoProperties, "NewValue")); var_dump($instanceWithNoProperties->pub2); ?> --EXPECTF-- Too few args: Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d NULL Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 1 given in %s on line %d NULL Too many args: Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 3 given in %s on line %d NULL Wrong type of arg: Warning: ReflectionProperty::setValue() expects parameter 1 to be object, boolean given in %s on line %d NULL Static property / too many args: Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 3 given in %s on line %d NULL Static property / too few args: NULL unicode(11) "A new value" Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d NULL unicode(11) "A new value" Static property / wrong type of arg: NULL unicode(17) "Another new value" Protected property: Cannot access non-public member TestClass::prot Instance without property: NULL unicode(8) "NewValue"
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt --TEST-- ReflectionClass::getFileName(), ReflectionClass::getStartLine(), ReflectionClass::getEndLine() --FILE-- <?php //New instance of class C - defined below $rc = new ReflectionClass("C"); //Get the file name of the PHP script in which C is defined var_dump($rc->getFileName()); //Get the line number at the start of the definition of class C var_dump($rc->getStartLine()); //Get the line number at the end of the definition of class C var_dump($rc->getEndLine()); //Same tests as above but stdclass is internal - so all results should be false. $rc = new ReflectionClass("stdClass"); var_dump($rc->getFileName()); var_dump($rc->getStartLine()); var_dump($rc->getEndLine()); Class C { } ?> --EXPECTF-- unicode(%d) "%sReflectionClass_FileInfo_basic.php" int(20) int(22) bool(false) bool(false) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_FileInfo_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_FileInfo_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_FileInfo_error.phpt --TEST-- ReflectionClass::getFileName(), ReflectionClass::getStartLine(), ReflectionClass::getEndLine() - bad params --FILE-- <?php Class C { } $rc = new ReflectionClass("C"); $methods = array("getFileName", "getStartLine", "getEndLine"); foreach ($methods as $method) { var_dump($rc->$method()); var_dump($rc->$method(null)); var_dump($rc->$method('X', 0)); } ?> --EXPECTF-- unicode(%s) "%s" Warning: ReflectionClass::getFileName() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getFileName() expects exactly 0 parameters, 2 given in %s on line %d NULL int(2) Warning: ReflectionClass::getStartLine() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getStartLine() expects exactly 0 parameters, 2 given in %s on line %d NULL int(2) Warning: ReflectionClass::getEndLine() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getEndLine() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_constructor_001.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_constructor_001.phpt +++ php-src/ext/reflection/tests/ReflectionClass_constructor_001.phpt --TEST-- ReflectionClass::__constructor() --FILE-- <?php $r1 = new ReflectionClass("stdClass"); $myInstance = new stdClass; $r2 = new ReflectionClass($myInstance); class TrickClass { function __toString() { //Return the name of another class return "Exception"; } } $myTrickClass = new TrickClass; $r3 = new ReflectionClass($myTrickClass); var_dump($r1, $r2, $r3); ?> --EXPECTF-- object(ReflectionClass)#%d (1) { [u"name"]=> unicode(8) "stdClass" } object(ReflectionClass)#%d (1) { [u"name"]=> unicode(8) "stdClass" } object(ReflectionClass)#%d (1) { [u"name"]=> unicode(10) "TrickClass" } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_constructor_002.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_constructor_002.phpt +++ php-src/ext/reflection/tests/ReflectionClass_constructor_002.phpt --TEST-- ReflectionClass::__constructor() - bad arguments --FILE-- <?php try { var_dump(new ReflectionClass()); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { var_dump(new ReflectionClass(null)); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { var_dump(new ReflectionClass(true)); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { var_dump(new ReflectionClass(1)); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { var_dump(new ReflectionClass(array(1,2,3))); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { var_dump(new ReflectionClass("stdClass", 1)); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { var_dump(new ReflectionClass("X")); } catch (Exception $e) { echo $e->getMessage() . "\n"; } ?> --EXPECTF-- Warning: ReflectionClass::__construct() expects exactly 1 parameter, 0 given in %s on line 3 object(ReflectionClass)#%d (1) { [u"name"]=> unicode(0) "" } Class does not exist Class 1 does not exist Class 1 does not exist Warning: ReflectionClass::__construct() expects parameter 1 to be string (Unicode or binary), array given in %s on line 27 object(ReflectionClass)#3 (1) { [u"name"]=> unicode(0) "" } Warning: ReflectionClass::__construct() expects exactly 1 parameter, 2 given in %s on line 33 object(ReflectionClass)#%d (1) { [u"name"]=> unicode(0) "" } Class X does not exist http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_export_basic1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_export_basic1.phpt +++ php-src/ext/reflection/tests/ReflectionClass_export_basic1.phpt --TEST-- ReflectionClass::export() - various parameters --FILE-- <?php Class A { public function privf(Exception $a) {} public function pubf(A $a, $b, C $c = null, $d = K, $e = "15 chars long -", $f = null, $g = false, array $h = null) {} } Class C extends A { } define('K', "16 chars long --"); ReflectionClass::export("C"); ?> --EXPECTF-- Class [ <user> class C extends A ] { @@ %s 14-14 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Methods [2] { Method [ <user, inherits A> public method privf ] { @@ %s 3 - 3 - Parameters [1] { Parameter #0 [ <required> Exception $a ] } } Method [ <user, inherits A> public method pubf ] { @@ %s 4 - 11 - Parameters [8] { Parameter #0 [ <required> A $a ] Parameter #1 [ <required> $b ] Parameter #2 [ <optional> C or NULL $c = NULL ] Parameter #3 [ <optional> $d = '16 chars long -...' ] Parameter #4 [ <optional> $e = '15 chars long -' ] Parameter #5 [ <optional> $f = NULL ] Parameter #6 [ <optional> $g = false ] Parameter #7 [ <optional> array or NULL $h = NULL ] } } } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_export_basic2.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_export_basic2.phpt +++ php-src/ext/reflection/tests/ReflectionClass_export_basic2.phpt --TEST-- ReflectionClass::export() - ensure inherited private props are hidden. --FILE-- <?php Class c { private $a; static private $b; } class d extends c {} ReflectionClass::export("c"); ReflectionClass::export("d"); ?> --EXPECTF-- Class [ <user> class c ] { @@ %s 2-5 - Constants [0] { } - Static properties [1] { Property [ private static $b ] } - Static methods [0] { } - Properties [1] { Property [ <default> private $a ] } - Methods [0] { } } Class [ <user> class d extends c ] { @@ %s 7-7 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Methods [0] { } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt --TEST-- ReflectionClass::getConstants() --FILE-- <?php class C { const a = 'hello from C'; } class D extends C { } class E extends D { } class F extends E { const a = 'hello from F'; } class X { } $classes = array("C", "D", "E", "F", "X"); foreach($classes as $class) { echo "Reflecting on class $class: \n"; $rc = new ReflectionClass($class); var_dump($rc->getConstant('a')); var_dump($rc->getConstant('doesntexist')); } ?> --EXPECTF-- Reflecting on class C: unicode(12) "hello from C" bool(false) Reflecting on class D: unicode(12) "hello from C" bool(false) Reflecting on class E: unicode(12) "hello from C" bool(false) Reflecting on class F: unicode(12) "hello from F" bool(false) Reflecting on class X: bool(false) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getConstant_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getConstant_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getConstant_error.phpt --TEST-- ReflectionClass::getConstant() - bad params --FILE-- <?php class C { const myConst = 1; } $rc = new ReflectionClass("C"); echo "Check invalid params:\n"; var_dump($rc->getConstant()); var_dump($rc->getConstant("myConst", "myConst")); var_dump($rc->getConstant(null)); var_dump($rc->getConstant(1)); var_dump($rc->getConstant(1.5)); var_dump($rc->getConstant(true)); var_dump($rc->getConstant(array(1,2,3))); var_dump($rc->getConstant(new C)); ?> --EXPECTF-- Check invalid params: Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 0 given in %s on line 8 NULL Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 2 given in %s on line 9 NULL bool(false) bool(false) bool(false) bool(false) Warning: ReflectionClass::getConstant() expects parameter 1 to be string (Unicode or binary), array given in %s on line 14 NULL Warning: ReflectionClass::getConstant() expects parameter 1 to be string (Unicode or binary), object given in %s on line 15 NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt --TEST-- ReflectionClass::getConstants() --FILE-- <?php class C { const a = 'hello from C'; } class D extends C { } class E extends D { } class F extends E { const a = 'hello from F'; } class X { } $classes = array('C', 'D', 'E', 'F', 'X'); foreach($classes as $class) { echo "Constants from class $class: \n"; $rc = new ReflectionClass($class); var_dump($rc->getConstants()); } ?> --EXPECTF-- Constants from class C: array(1) { [u"a"]=> unicode(12) "hello from C" } Constants from class D: array(1) { [u"a"]=> unicode(12) "hello from C" } Constants from class E: array(1) { [u"a"]=> unicode(12) "hello from C" } Constants from class F: array(1) { [u"a"]=> unicode(12) "hello from F" } Constants from class X: array(0) { } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getConstants_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getConstants_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getConstants_error.phpt --TEST-- ReflectionClass::getConstants() --FILE-- <?php class X { } $rc = new reflectionClass('X'); //Test invalid arguments $rc->getConstants('X'); $rc->getConstants(true); $rc->getConstants(null); $rc->getConstants('A', 'B'); ?> --EXPECTF-- Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 2 given in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt --TEST-- ReflectionClass::getConstructor() --SKIPIF-- <?php extension_loaded('reflection') or die('skip - reflection extension not loaded'); ?> --CREDITS-- Michelangelo van Dam <dragonbe@gmail.com> #testfest roosendaal on 2008-05-10 --FILE-- <?php class NewCtor { function __construct() {} } class ExtendsNewCtor extends NewCtor { } class OldCtor { function OldCtor() {} } class ExtendsOldCtor extends OldCtor { } class X { function Y() {} } class Y extends X { } class OldAndNewCtor { function OldAndNewCtor() {} function __construct() {} } class NewAndOldCtor { function __construct() {} function NewAndOldCtor() {} } class B { function B() {} } class C extends B { function C() {} } class D1 extends C { function __construct() {} } class D2 extends C { } $classes = array('NewCtor', 'ExtendsNewCtor', 'OldCtor', 'ExtendsOldCtor', 'OldAndNewCtor', 'NewAndOldCtor', 'B', 'C', 'D1', 'D2', 'X', 'Y'); foreach ($classes as $class) { $rc = new ReflectionClass($class); $rm = $rc->getConstructor(); if ($rm != null) { echo "Constructor of $class: " . $rm->getName() . "\n"; } else { echo "No constructor for $class\n"; } } ?> --EXPECTF-- Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line 26 Strict Standards: %s for class NewAndOldCtor in %s on line 31 Constructor of NewCtor: __construct Constructor of ExtendsNewCtor: __construct Constructor of OldCtor: OldCtor Constructor of ExtendsOldCtor: OldCtor Constructor of OldAndNewCtor: __construct Constructor of NewAndOldCtor: __construct Constructor of B: B Constructor of C: C Constructor of D1: __construct Constructor of D2: C No constructor for X No constructor for Y http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getConstructor_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getConstructor_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getConstructor_error.phpt --TEST-- ReflectionClass::getConstructor() - bad params --FILE-- <?php class C {} $rc = new ReflectionClass('C'); var_dump($rc->getConstructor(null)); var_dump($rc->getConstructor('X')); var_dump($rc->getConstructor(true)); var_dump($rc->getConstructor(array(1,2,3))); ?> --EXPECTF-- Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt --TEST-- ReflectionClass::getExtensionName() method - basic test for getExtensionName() method --SKIPIF-- <?php extension_loaded('dom') or die('skip - dom extension not loaded'); ?> --CREDITS-- Rein Velt <rein@velt.org> #testFest Roosendaal 2008-05-10 --FILE-- <?php $rc=new reflectionClass('domDocument'); var_dump( $rc->getExtensionName()) ; ?> --EXPECT-- unicode(3) "dom" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt --TEST-- ReflectionClass::getExtensionName() method - variation test for getExtensionName() --CREDITS-- Rein Velt <rein@velt.org> #testFest Roosendaal 2008-05-10 --FILE-- <?php class myClass { public $varX; public $varY; } $rc=new reflectionClass('myClass'); var_dump( $rc->getExtensionName()) ; ?> --EXPECT-- bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt --TEST-- ReflectionClass::getExtension() method - basic test for getExtension() method --SKIPIF-- <?php extension_loaded('dom') or die('skip - dom extension not loaded'); ?> --CREDITS-- Rein Velt <rein@velt.org> #testFest Roosendaal 2008-05-10 --FILE-- <?php $rc=new reflectionClass('domDocument'); var_dump($rc->getExtension()) ; ?> --EXPECTF-- object(ReflectionExtension)#%d (1) { [u"name"]=> unicode(3) "dom" } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt --TEST-- ReflectionClass::getExtension() method - variation test for getExtension() --CREDITS-- Rein Velt <rein@velt.org> #testFest Roosendaal 2008-05-10 --FILE-- <?php class myClass { public $varX; public $varY; } $rc=new reflectionClass('myClass'); var_dump( $rc->getExtension()) ; ?> --EXPECT-- NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getInterfaceNames_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getInterfaceNames_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getInterfaceNames_basic.phpt --TEST-- ReflectionClass::getInterfaceNames() --CREDITS-- Michelangelo van Dam <dragonbe@gmail.com> #testfest roosendaal on 2008-05-10 --FILE-- <?php interface Foo { } interface Bar { } class Baz implements Foo, Bar { } $rc1 = new ReflectionClass("Baz"); var_dump($rc1->getInterfaceNames()); ?> --EXPECT-- array(2) { [0]=> unicode(3) "Foo" [1]=> unicode(3) "Bar" } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt --TEST-- ReflectionClass::getModifierNames() basic tests --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --FILE-- <?php class a {} abstract class b {} final class c {} class x { function __construct() {} function __destruct() {} private function a() {} private static function b() {} protected function c() {} protected static function d() {} public function e() {} public static function f() {} final function g() {} function h() {} } abstract class y { abstract function a(); abstract protected function b(); } function dump_modifierNames($class) { $obj = new ReflectionClass($class); var_dump($obj->getName(), Reflection::getModifierNames($obj->getModifiers())); } function dump_methodModifierNames($class) { $obj = new ReflectionClass($class); foreach($obj->getMethods() as $method) { var_dump($obj->getName() . "::" . $method->getName(), Reflection::getModifierNames($method->getModifiers())); } } dump_modifierNames('a'); dump_modifierNames('b'); dump_modifierNames('c'); dump_methodModifierNames('x'); dump_methodModifierNames('y'); ?> ==DONE== --EXPECT-- unicode(1) "a" array(0) { } unicode(1) "b" array(1) { [0]=> unicode(8) "abstract" } unicode(1) "c" array(1) { [0]=> unicode(5) "final" } unicode(14) "x::__construct" array(1) { [0]=> unicode(6) "public" } unicode(13) "x::__destruct" array(1) { [0]=> unicode(6) "public" } unicode(4) "x::a" array(1) { [0]=> unicode(7) "private" } unicode(4) "x::b" array(2) { [0]=> unicode(7) "private" [1]=> unicode(6) "static" } unicode(4) "x::c" array(1) { [0]=> unicode(9) "protected" } unicode(4) "x::d" array(2) { [0]=> unicode(9) "protected" [1]=> unicode(6) "static" } unicode(4) "x::e" array(1) { [0]=> unicode(6) "public" } unicode(4) "x::f" array(2) { [0]=> unicode(6) "public" [1]=> unicode(6) "static" } unicode(4) "x::g" array(2) { [0]=> unicode(5) "final" [1]=> unicode(6) "public" } unicode(4) "x::h" array(1) { [0]=> unicode(6) "public" } unicode(4) "y::a" array(2) { [0]=> unicode(8) "abstract" [1]=> unicode(6) "public" } unicode(4) "y::b" array(2) { [0]=> unicode(8) "abstract" [1]=> unicode(9) "protected" } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt --TEST-- ReflectionClass::getModifiers() --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --FILE-- <?php class a {} abstract class b {} final class c {} interface d {} class e implements d {} interface f extends d {} class g extends b {} function dump_modifiers($class) { $obj = new ReflectionClass($class); var_dump($obj->getModifiers()); } dump_modifiers('a'); dump_modifiers('b'); dump_modifiers('c'); dump_modifiers('d'); dump_modifiers('e'); dump_modifiers('f'); dump_modifiers('g'); ?> --EXPECT-- int(0) int(32) int(64) int(128) int(524288) int(524416) int(0) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getName_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getName_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getName_basic.phpt --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-- unicode(8) "stdClass" unicode(8) "stdClass" unicode(10) "TrickClass" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getName_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getName_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getName_error.phpt --TEST-- ReflectionClass::getName() - invalid params --FILE-- <?php $r1 = new ReflectionClass("stdClass"); var_dump($r1->getName('X')); var_dump($r1->getName('X', true)); ?> --EXPECTF-- Warning: ReflectionClass::getName() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getName() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getName_error1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getName_error1.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getName_error1.phpt --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 http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getNamespaceName.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getNamespaceName.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getNamespaceName.phpt --TEST-- ReflectionClass::getNamespaceName() --FILE-- <?php namespace A\B; class Foo { } $function = new \ReflectionClass('stdClass'); var_dump($function->inNamespace()); var_dump($function->getName()); var_dump($function->getNamespaceName()); var_dump($function->getShortName()); $function = new \ReflectionClass('A\\B\\Foo'); var_dump($function->inNamespace()); var_dump($function->getName()); var_dump($function->getNamespaceName()); var_dump($function->getShortName()); ?> --EXPECT-- bool(false) unicode(8) "stdClass" unicode(0) "" unicode(8) "stdClass" bool(true) unicode(7) "A\B\Foo" unicode(3) "A\B" unicode(3) "Foo" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_getParentClass.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_getParentClass.phpt +++ php-src/ext/reflection/tests/ReflectionClass_getParentClass.phpt --TEST-- ReflectionClass::getParentClass() --CREDITS-- Michelangelo van Dam <dragonbe@gmail.com> #testfest roosendaal on 2008-05-10 --FILE-- <?php class Foo {} class Bar extends Foo {} $rc1 = new ReflectionClass("Bar"); var_dump($rc1->getParentClass()); ?> --EXPECTF-- object(ReflectionClass)#%d (1) { [u"name"]=> unicode(3) "Foo" } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_hasConstant_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_hasConstant_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_hasConstant_basic.phpt --TEST-- ReflectionClass::hasConstant() --CREDITS-- Marc Veldman <marc@ibuildings.nl> #testfest roosendaal on 2008-05-10 --FILE-- <?php //New instance of class C - defined below $rc = new ReflectionClass("C"); //Check if C has constant foo var_dump($rc->hasConstant('foo')); //C should not have constant bar var_dump($rc->hasConstant('bar')); Class C { const foo=1; } ?> --EXPECTF-- bool(true) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_hasMethod_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_hasMethod_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_hasMethod_basic.phpt --TEST-- ReflectionClass::hasMethod() --CREDITS-- Marc Veldman <marc@ibuildings.nl> #testfest roosendaal on 2008-05-10 --FILE-- <?php //New instance of class C - defined below $rc = new ReflectionClass("C"); //Check if C has public method publicFoo var_dump($rc->hasMethod('publicFoo')); //Check if C has protected method protectedFoo var_dump($rc->hasMethod('protectedFoo')); //Check if C has private method privateFoo var_dump($rc->hasMethod('privateFoo')); //Check if C has static method staticFoo var_dump($rc->hasMethod('staticFoo')); //C should not have method bar var_dump($rc->hasMethod('bar')); //Method names are case insensitive var_dump($rc->hasMethod('PUBLICfOO')); Class C { public function publicFoo() { return true; } protected function protectedFoo() { return true; } private function privateFoo() { return true; } static function staticFoo() { return true; } } ?> --EXPECTF-- bool(true) bool(true) bool(true) bool(true) bool(false) bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_hasProperty_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_hasProperty_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_hasProperty_basic.phpt --TEST-- ReflectionClass::hasProperty() --CREDITS-- Marc Veldman <marc@ibuildings.nl> #testfest roosendaal on 2008-05-10 --FILE-- <?php //New instance of class C - defined below $rc = new ReflectionClass("C"); //Check if C has public property publicFoo var_dump($rc->hasProperty('publicFoo')); //Check if C has protected property protectedFoo var_dump($rc->hasProperty('protectedFoo')); //Check if C has private property privateFoo var_dump($rc->hasProperty('privateFoo')); //Check if C has static property staticFoo var_dump($rc->hasProperty('staticFoo')); //C should not have property bar var_dump($rc->hasProperty('bar')); Class C { public $publicFoo; protected $protectedFoo; private $privateFoo; public static $staticFoo; } ?> --EXPECTF-- bool(true) bool(true) bool(true) bool(true) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isAbstract_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isAbstract_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isAbstract_basic.phpt --TEST-- ReflectionClass::isAbstract() method --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> #testfest roosendaal on 2008-05-10 --FILE-- <?php class TestClass {} abstract class TestAbstractClass {} $testClass = new ReflectionClass('TestClass'); $abstractClass = new ReflectionClass('TestAbstractClass'); var_dump($testClass->isAbstract()); var_dump($abstractClass->isAbstract()); ?> --EXPECT-- bool(false) bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isFinal_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isFinal_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isFinal_basic.phpt --TEST-- ReflectionClass::isFinal() method --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> #testfest roosendaal on 2008-05-10 --FILE-- <?php class TestClass {} final class TestFinalClass {} $normalClass = new ReflectionClass('TestClass'); $finalClass = new ReflectionClass('TestFinalClass'); var_dump($normalClass->isFinal()); var_dump($finalClass->isFinal()); ?> --EXPECT-- bool(false) bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt --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(true) 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(true) 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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInstance_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInstance_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInstance_error.phpt --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, 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 http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt --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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt --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: ReflectionClass::isInstantiable() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt --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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInterface_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInterface_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInterface_basic.phpt --TEST-- ReflectionClass::isInterface() method --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> #testfest roosendaal on 2008-05-10 --FILE-- <?php interface TestInterface {} class TestClass {} interface DerivedInterface extends TestInterface {} $reflectionClass = new ReflectionClass('TestInterface'); $reflectionClass2 = new ReflectionClass('TestClass'); $reflectionClass3 = new ReflectionClass('DerivedInterface'); var_dump($reflectionClass->isInterface()); var_dump($reflectionClass2->isInterface()); var_dump($reflectionClass3->isInterface()); ?> --EXPECT-- bool(true) bool(false) bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt --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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isInternal_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isInternal_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isInternal_error.phpt --TEST-- ReflectionClass::isInternal() - invalid params --FILE-- <?php $r1 = new ReflectionClass("stdClass"); var_dump($r1->isInternal('X')); var_dump($r1->isInternal('X', true)); ?> --EXPECTF-- Warning: ReflectionClass::isInternal() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::isInternal() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt --TEST-- ReflectionClass::isIterateable() basic --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com>, Marc Veldman <marc@ibuildings.nl> --FILE-- <?php class IteratorClass implements Iterator { public function __construct() { } public function key() {} public function current() {} function next() {} function valid() {} function rewind() {} } class DerivedClass extends IteratorClass {} class NonIterator {} function dump_iterateable($class) { $reflection = new ReflectionClass($class); var_dump($reflection->isIterateable()); } $classes = array("ArrayObject", "IteratorClass", "DerivedClass", "NonIterator"); foreach ($classes as $class) { echo "Is $class iterateable? "; dump_iterateable($class); } ?> --EXPECT-- Is ArrayObject iterateable? bool(true) Is IteratorClass iterateable? bool(true) Is DerivedClass iterateable? bool(true) Is NonIterator iterateable? bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt --TEST-- ReflectionClass::isIterateable() variations --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --FILE-- <?php class BasicClass {} function dump_iterateable($obj) { $reflection = new ReflectionClass($obj); var_dump($reflection->isIterateable()); } $basicClass = new BasicClass(); $stdClass = new StdClass(); dump_iterateable($basicClass); dump_iterateable($stdClass); ?> --EXPECT-- bool(false) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt --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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt --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 http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt --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 http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt --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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt +++ php-src/ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt --TEST-- ReflectionClass::isUserDefined() - invalid params. --FILE-- <?php $r1 = new ReflectionClass("stdClass"); var_dump($r1->isUserDefined('X')); var_dump($r1->isUserDefined('X', true)); ?> --EXPECTF-- Warning: ReflectionClass::isUserDefined() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::isUserDefined() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt --TEST-- ReflectionExtension::__construct() --CREDITS-- Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php $obj = new ReflectionExtension('reflection'); $test = $obj instanceof ReflectionExtension; var_dump($test); ?> ==DONE== --EXPECT-- bool(true) ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_constructor_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_constructor_error.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_constructor_error.phpt --TEST-- ReflectionExtension::__construct() --CREDITS-- Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php $obj = new ReflectionExtension(); $test = $obj instanceof ReflectionExtension; var_dump($test); ?> ==DONE== --EXPECTF-- Warning: ReflectionExtension::__construct() expects exactly %d parameter, %d given in %s.php on line %d bool(true) ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_export_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_export_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_export_basic.phpt --TEST-- ReflectionExtension::export() --CREDITS-- Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php ob_start(); ReflectionExtension::export("reflection", true); $test = ob_get_clean(); var_dump(empty($test)); unset($test); ob_start(); ReflectionExtension::export("reflection", false); $test = ob_get_clean(); var_dump(empty($test)); ?> ==DONE== --EXPECT-- bool(true) bool(false) ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt --TEST-- ReflectionExtension::getClassNames() method on an extension which acually returns some information --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --FILE-- <?php $standard = new ReflectionExtension('standard'); var_dump($standard->getClassNames()); ?> ==DONE== --EXPECTF-- array(3) { [0]=> %s(22) "__PHP_Incomplete_Class" [1]=> %s(15) "php_user_filter" [2]=> %s(9) "Directory" } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt --TEST-- ReflectionExtension::getClassNames() method on an extension with no classes --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --FILE-- <?php $ereg = new ReflectionExtension('ereg'); var_dump($ereg->getClassNames()); ?> ==DONE== --EXPECT-- array(0) { } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt --TEST-- ReflectionExtension::getClasses(); --CREDITS-- Thijs Lensselink <tl@lenss.nl> --FILE-- <?php $ext = new ReflectionExtension('reflection'); var_dump($ext->getClasses()); ?> ==DONE== --EXPECTF-- array(11) { [%s"ReflectionException"]=> &object(ReflectionClass)#2 (1) { [%s"name"]=> unicode(19) "ReflectionException" } [%s"Reflection"]=> &object(ReflectionClass)#3 (1) { [%s"name"]=> unicode(10) "Reflection" } [%s"Reflector"]=> &object(ReflectionClass)#4 (1) { [%s"name"]=> unicode(9) "Reflector" } [%s"ReflectionFunctionAbstract"]=> &object(ReflectionClass)#5 (1) { [%s"name"]=> unicode(26) "ReflectionFunctionAbstract" } [%s"ReflectionFunction"]=> &object(ReflectionClass)#6 (1) { [%s"name"]=> unicode(18) "ReflectionFunction" } [%s"ReflectionParameter"]=> &object(ReflectionClass)#7 (1) { [%s"name"]=> unicode(19) "ReflectionParameter" } [%s"ReflectionMethod"]=> &object(ReflectionClass)#8 (1) { [%s"name"]=> unicode(16) "ReflectionMethod" } [%s"ReflectionClass"]=> &object(ReflectionClass)#9 (1) { [%s"name"]=> unicode(15) "ReflectionClass" } [%s"ReflectionObject"]=> &object(ReflectionClass)#10 (1) { [%s"name"]=> unicode(16) "ReflectionObject" } [%s"ReflectionProperty"]=> &object(ReflectionClass)#11 (1) { [%s"name"]=> unicode(18) "ReflectionProperty" } [%s"ReflectionExtension"]=> &object(ReflectionClass)#12 (1) { [%s"name"]=> unicode(19) "ReflectionExtension" } } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt --TEST-- ReflectionExtension::getDependencies() method on an extension with a required and conflicting dependency --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --SKIPIF-- <?php if (!extension_loaded("dom")) die("skip no dom extension"); ?> --FILE-- <?php $dom = new ReflectionExtension('dom'); var_dump($dom->getDependencies()); ?> ==DONE== --EXPECTF-- array(2) { [%s"libxml"]=> %s(8) "Required" [%s"domxml"]=> %s(9) "Conflicts" } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt --TEST-- ReflectionExtension::getDependencies() method on an extension with one optional dependency --CREDITS-- Felix De Vliegher <felix.devliegher@gmail.com> --FILE-- <?php $standard = new ReflectionExtension('standard'); var_dump($standard->getDependencies()); ?> ==DONE== --EXPECTF-- array(1) { [%s"session"]=> %s(8) "Optional" } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getName_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getName_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getName_basic.phpt --TEST-- ReflectionExtension::getName() --CREDITS-- Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php $obj = new ReflectionExtension('reflection'); var_dump($obj->getName()); ?> ==DONE== --EXPECTF-- %s(10) "Reflection" ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt --TEST-- ReflectionExtension::getVersion() --CREDITS-- Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php $obj = new ReflectionExtension('reflection'); $var = $obj->getVersion() ? $obj->getVersion() : null; $test = floatval($var) == $var ? true : false; var_dump($test); ?> ==DONE== --EXPECT-- bool(true) ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionExtension_info_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionExtension_info_basic.phpt +++ php-src/ext/reflection/tests/ReflectionExtension_info_basic.phpt --TEST-- ReflectionExtension::info() --CREDITS-- Gerrit "Remi" te Sligte <remi@wolerized.com> Leon Luijkx <leon@phpgg.nl> --FILE-- <?php $obj = new ReflectionExtension('reflection'); ob_start(); $testa = $obj->info(); $testb = ob_get_clean(); var_dump($testa); var_dump(strlen($testb) > 24); ?> ==DONE== --EXPECT-- NULL bool(true) ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_FileInfo_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_FileInfo_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_FileInfo_basic.phpt --TEST-- ReflectionObject::getFileName(), ReflectionObject::getStartLine(), ReflectionObject::getEndLine() - basic function --FILE-- <?php $rc = new ReflectionObject(new C); var_dump($rc->getFileName()); var_dump($rc->getStartLine()); var_dump($rc->getEndLine()); $rc = new ReflectionObject(new stdclass); var_dump($rc->getFileName()); var_dump($rc->getStartLine()); var_dump($rc->getEndLine()); Class C { } ?> --EXPECTF-- unicode(%d) "%sReflectionObject_FileInfo_basic.php" int(12) int(14) bool(false) bool(false) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt --TEST-- ReflectionObject::getFileName(), ReflectionObject::getStartLine(), ReflectionObject::getEndLine() -invalid aparams --FILE-- <?php Class C { } $rc = new ReflectionObject(new C); $methods = array("getFileName", "getStartLine", "getEndLine"); foreach ($methods as $method) { var_dump($rc->$method()); var_dump($rc->$method(null)); var_dump($rc->$method('X', 0)); } ?> --EXPECTF-- unicode(%d) "%s" Warning: ReflectionClass::getFileName() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getFileName() expects exactly 0 parameters, 2 given in %s on line %d NULL int(2) Warning: ReflectionClass::getStartLine() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getStartLine() expects exactly 0 parameters, 2 given in %s on line %d NULL int(2) Warning: ReflectionClass::getEndLine() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getEndLine() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject___toString_basic1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject___toString_basic1.phpt +++ php-src/ext/reflection/tests/ReflectionObject___toString_basic1.phpt --TEST-- ReflectionObject::__toString() : very basic test with no dynamic properties --FILE-- <?php class Foo { public $bar = 1; } $f = new foo; echo new ReflectionObject($f); ?> --EXPECTF-- Object of class [ <user> class Foo ] { @@ %s 3-5 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ <default> public $bar ] } - Dynamic properties [0] { } - Methods [0] { } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject___toString_basic2.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject___toString_basic2.phpt +++ php-src/ext/reflection/tests/ReflectionObject___toString_basic2.phpt --TEST-- ReflectionObject::__toString() : very basic test with dynamic properties --FILE-- <?php class Foo { public $bar = 1; } $f = new foo; $f->dynProp = 'hello'; $f->dynProp2 = 'hello again'; echo new ReflectionObject($f); ?> --EXPECTF-- Object of class [ <user> class Foo ] { @@ %s 3-5 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ <default> public $bar ] } - Dynamic properties [2] { Property [ <dynamic> public $dynProp ] Property [ <dynamic> public $dynProp2 ] } - Methods [0] { } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_constructor_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_constructor_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_constructor_basic.phpt --TEST-- ReflectionObject::__construct - basic function test --FILE-- <?php $r1 = new ReflectionObject(new stdClass); var_dump($r1); class C { } $myInstance = new C; $r2 = new ReflectionObject($myInstance); var_dump($r2); $r3 = new ReflectionObject($r2); var_dump($r3); ?> --EXPECTF-- object(ReflectionObject)#%d (1) { [u"name"]=> unicode(8) "stdClass" } object(ReflectionObject)#%d (1) { [u"name"]=> unicode(1) "C" } object(ReflectionObject)#%d (1) { [u"name"]=> unicode(16) "ReflectionObject" } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_constructor_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_constructor_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_constructor_error.phpt --TEST-- ReflectionObject::__construct - invalid arguments --FILE-- <?php var_dump(new ReflectionObject()); var_dump(new ReflectionObject('stdClass')); $myInstance = new stdClass; var_dump(new ReflectionObject($myInstance, $myInstance)); var_dump(new ReflectionObject(0)); var_dump(new ReflectionObject(null)); var_dump(new ReflectionObject(array(1,2))); ?> --EXPECTF-- Warning: ReflectionObject::__construct() expects exactly 1 parameter, 0 given in %s on line 3 object(ReflectionObject)#%d (1) { [u"name"]=> unicode(0) "" } Warning: ReflectionObject::__construct() expects parameter 1 to be object, Unicode string given in %s on line 4 object(ReflectionObject)#%d (1) { [u"name"]=> unicode(0) "" } Warning: ReflectionObject::__construct() expects exactly 1 parameter, 2 given in %s on line 6 object(ReflectionObject)#%d (1) { [u"name"]=> unicode(0) "" } Warning: ReflectionObject::__construct() expects parameter 1 to be object, integer given in %s on line 7 object(ReflectionObject)#%d (1) { [u"name"]=> unicode(0) "" } Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in %s on line 8 object(ReflectionObject)#%d (1) { [u"name"]=> unicode(0) "" } Warning: ReflectionObject::__construct() expects parameter 1 to be object, array given in %s on line 9 object(ReflectionObject)#%d (1) { [u"name"]=> unicode(0) "" } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_export_basic1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_export_basic1.phpt +++ php-src/ext/reflection/tests/ReflectionObject_export_basic1.phpt --TEST-- ReflectionObject::export() : very basic test with no dynamic properties --FILE-- <?php class Foo { public $bar = 1; } $f = new foo; ReflectionObject::export($f); ?> --EXPECTF-- Object of class [ <user> class Foo ] { @@ %s 3-5 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ <default> public $bar ] } - Dynamic properties [0] { } - Methods [0] { } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_export_basic2.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_export_basic2.phpt +++ php-src/ext/reflection/tests/ReflectionObject_export_basic2.phpt --TEST-- ReflectionObject::export() : very basic test with dynamic properties --FILE-- <?php class Foo { public $bar = 1; } $f = new foo; $f->dynProp = 'hello'; $f->dynProp2 = 'hello again'; ReflectionObject::export($f); ?> --EXPECTF-- Object of class [ <user> class Foo ] { @@ %s 3-5 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ <default> public $bar ] } - Dynamic properties [2] { Property [ <dynamic> public $dynProp ] Property [ <dynamic> public $dynProp2 ] } - Methods [0] { } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_export_basic3.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_export_basic3.phpt +++ php-src/ext/reflection/tests/ReflectionObject_export_basic3.phpt --TEST-- ReflectionObject::export() - ensure dynamic property with same name as inherited private property is shown. --FILE-- <?php class C { private $p = 1; } class D extends C{ } $Obj = new D; $Obj->p = 'value'; ReflectionObject::export($Obj) ?> --EXPECTF-- Object of class [ <user> class D extends C ] { @@ %s 6-7 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Dynamic properties [0] { } - Methods [0] { } } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt --TEST-- ReflectionObject::getConstant() basic function test --FILE-- <?php class C { const a = 'hello from C'; } class D extends C { } class E extends D { } class F extends E { const a = 'hello from F'; } class X { } $classes = array("C", "D", "E", "F", "X"); foreach($classes as $class) { echo "Reflecting on instance of class $class: \n"; $rc = new ReflectionObject(new $class); var_dump($rc->getConstant('a')); var_dump($rc->getConstant('doesntexist')); } ?> --EXPECTF-- Reflecting on instance of class C: unicode(12) "hello from C" bool(false) Reflecting on instance of class D: unicode(12) "hello from C" bool(false) Reflecting on instance of class E: unicode(12) "hello from C" bool(false) Reflecting on instance of class F: unicode(12) "hello from F" bool(false) Reflecting on instance of class X: bool(false) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getConstant_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getConstant_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getConstant_error.phpt --TEST-- ReflectionObject::getConstant() - invalid params --FILE-- <?php class C { const myConst = 1; } $rc = new ReflectionObject(new C); var_dump($rc->getConstant()); var_dump($rc->getConstant("myConst", "myConst")); var_dump($rc->getConstant(null)); var_dump($rc->getConstant(1)); var_dump($rc->getConstant(1.5)); var_dump($rc->getConstant(true)); var_dump($rc->getConstant(array(1,2,3))); var_dump($rc->getConstant(new C)); ?> --EXPECTF-- Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 0 given in %s on line 7 NULL Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 2 given in %s on line 8 NULL bool(false) bool(false) bool(false) bool(false) Warning: ReflectionClass::getConstant() expects parameter 1 to be string (Unicode or binary), array given in %s on line 13 NULL Warning: ReflectionClass::getConstant() expects parameter 1 to be string (Unicode or binary), object given in %s on line 14 NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt --TEST-- ReflectionObject::getConstants() - basic function test --FILE-- <?php class C { const a = 'hello from C'; } class D extends C { } class E extends D { } class F extends E { const a = 'hello from F'; } class X { } $classes = array("C", "D", "E", "F", "X"); foreach($classes as $class) { echo "Reflecting on instance of class $class: \n"; $rc = new ReflectionObject(new $class); var_dump($rc->getConstants()); } ?> --EXPECTF-- Reflecting on instance of class C: array(1) { [u"a"]=> unicode(12) "hello from C" } Reflecting on instance of class D: array(1) { [u"a"]=> unicode(12) "hello from C" } Reflecting on instance of class E: array(1) { [u"a"]=> unicode(12) "hello from C" } Reflecting on instance of class F: array(1) { [u"a"]=> unicode(12) "hello from F" } Reflecting on instance of class X: array(0) { } http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getConstants_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getConstants_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getConstants_error.phpt --TEST-- ReflectionObject::getConstants() - invalid params --FILE-- <?php class X { } $rc = new ReflectionObject(new X); $rc->getConstants('X'); $rc->getConstants(true); ?> --EXPECTF-- Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d Warning: ReflectionClass::getConstants() expects exactly 0 parameters, 1 given in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt --TEST-- ReflectionObject::getConstructor() - basic function test --FILE-- <?php class NewCtor { function __construct() {} } class ExtendsNewCtor extends NewCtor { } class OldCtor { function OldCtor() {} } class ExtendsOldCtor extends OldCtor { } class X { function Y() {} } class Y extends X { } class OldAndNewCtor { function OldAndNewCtor() {} function __construct() {} } class NewAndOldCtor { function __construct() {} function NewAndOldCtor() {} } class B { function B() {} } class C extends B { function C() {} } class D1 extends C { function __construct() {} } class D2 extends C { } $classes = array('NewCtor', 'ExtendsNewCtor', 'OldCtor', 'ExtendsOldCtor', 'OldAndNewCtor', 'NewAndOldCtor', 'B', 'C', 'D1', 'D2', 'X', 'Y'); foreach ($classes as $class) { $rc = new ReflectionObject(new $class); $rm = $rc->getConstructor(); if ($rm != null) { echo "Constructor of $class: " . $rm->getName() . "\n"; } else { echo "No constructor for $class\n"; } } ?> --EXPECTF-- Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line 26 Strict Standards: %s for class NewAndOldCtor in %s on line 31 Constructor of NewCtor: __construct Constructor of ExtendsNewCtor: __construct Constructor of OldCtor: OldCtor Constructor of ExtendsOldCtor: OldCtor Constructor of OldAndNewCtor: __construct Constructor of NewAndOldCtor: __construct Constructor of B: B Constructor of C: C Constructor of D1: __construct Constructor of D2: C No constructor for X No constructor for Y http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getConstructor_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getConstructor_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getConstructor_error.phpt --TEST-- ReflectionObject::getConstructor() - invalid params --FILE-- <?php class C {} $rc = new ReflectionObject(new C); var_dump($rc->getConstructor(null)); var_dump($rc->getConstructor('X')); var_dump($rc->getConstructor(true)); var_dump($rc->getConstructor(array(1,2,3))); ?> --EXPECTF-- Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getConstructor() expects exactly 0 parameters, 1 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getName_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getName_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getName_basic.phpt --TEST-- ReflectionObject::getName() - basic function test --FILE-- <?php $r0 = new ReflectionObject(); var_dump($r0->getName()); $r1 = new ReflectionObject(new stdClass); var_dump($r1->getName()); class C { } $myInstance = new C; $r2 = new ReflectionObject($myInstance); var_dump($r2->getName()); $r3 = new ReflectionObject($r2); var_dump($r3->getName()); ?> --EXPECTF-- Warning: ReflectionObject::__construct() expects exactly 1 parameter, 0 given in %s on line 2 unicode(0) "" unicode(8) "stdClass" unicode(1) "C" unicode(16) "ReflectionObject" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getName_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getName_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getName_error.phpt --TEST-- ReflectionObject::getname() - invalid params --FILE-- <?php class C { } $myInstance = new C; $r2 = new ReflectionObject($myInstance); $r3 = new ReflectionObject($r2); var_dump($r3->getName(null)); var_dump($r3->getName('x','y')); var_dump($r3->getName(0)); ?> --EXPECTF-- Warning: ReflectionClass::getName() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::getName() expects exactly 0 parameters, 2 given in %s on line %d NULL Warning: ReflectionClass::getName() expects exactly 0 parameters, 1 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_getName_error1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_getName_error1.phpt +++ php-src/ext/reflection/tests/ReflectionObject_getName_error1.phpt --TEST-- ReflectionObject::getName - forbid static invocation --FILE-- <?php ReflectionObject::getName(); ?> --EXPECTF-- Fatal error: Non-static method ReflectionClass::getName() cannot be called statically in %s on line 2 http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt --TEST-- ReflectionObject::isInstance() - basic function test --FILE-- <?php class A {} class B extends A {} class X {} $classes = array("A", "B", "X"); $instances = array( "myA" => new A, "myB" => new B, "myX" => new X ); foreach ($classes as $class) { $ro = new ReflectionObject(new $class); foreach ($instances as $name => $instance) { echo "is $name a $class? "; var_dump($ro->isInstance($instance)); } } ?> --EXPECTF-- is myA a A? bool(true) is myB a A? bool(true) is myX a A? bool(false) is myA a B? bool(false) is myB a B? bool(true) is myX a B? bool(false) is myA a X? bool(false) is myB a X? bool(false) is myX a X? bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInstance_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInstance_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInstance_error.phpt --TEST-- ReflectionObject::isInstance() - invalid params --FILE-- <?php class X {} $instance = new X; $ro = new ReflectionObject(new X); var_dump($ro->isInstance()); var_dump($ro->isInstance($instance, $instance)); var_dump($ro->isInstance(1)); var_dump($ro->isInstance(1.5)); var_dump($ro->isInstance(true)); var_dump($ro->isInstance('X')); var_dump($ro->isInstance(null)); ?> --EXPECTF-- Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 0 given in %s on line 6 NULL Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 2 given in %s on line 7 NULL Warning: ReflectionClass::isInstance() expects parameter 1 to be object, integer given in %s on line 8 NULL Warning: ReflectionClass::isInstance() expects parameter 1 to be object, double given in %s on line 9 NULL Warning: ReflectionClass::isInstance() expects parameter 1 to be object, boolean given in %s on line 10 NULL Warning: ReflectionClass::isInstance() expects parameter 1 to be object, Unicode string given in %s on line 11 NULL Warning: ReflectionClass::isInstance() expects parameter 1 to be object, null given in %s on line 12 NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt --TEST-- ReflectionObject::IsInstantiable() - basic function test --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", "ifaceImpl", "D"); foreach($classes as $class ) { $ro = new ReflectionObject(new $class); echo "Is $class instantiable? "; var_dump($ro->IsInstantiable()); } ?> --EXPECTF-- Is C instantiable? bool(true) Is ifaceImpl instantiable? bool(true) Is D instantiable? bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt --TEST-- ReflectionObject::IsInstantiable() - invalid params --FILE-- <?php class privateCtorOld { private function privateCtorOld() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } $reflectionObject = privateCtorOld::reflectionObjectFactory(); var_dump($reflectionObject->IsInstantiable('X')); var_dump($reflectionObject->IsInstantiable(0, null)); ?> --EXPECTF-- Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt --TEST-- ReflectionObject::IsInstantiable() - variation - constructors --FILE-- <?php class noCtor { public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } class publicCtorNew { public function __construct() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } class protectedCtorNew { protected function __construct() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } class privateCtorNew { private function __construct() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } class publicCtorOld { public function publicCtorOld() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } class protectedCtorOld { protected function protectedCtorOld() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } class privateCtorOld { private function privateCtorOld() {} public static function reflectionObjectFactory() { return new ReflectionObject(new self); } } $reflectionObjects = array( noCtor::reflectionObjectFactory(), publicCtorNew::reflectionObjectFactory(), protectedCtorNew::reflectionObjectFactory(), privateCtorNew::reflectionObjectFactory(), publicCtorOld::reflectionObjectFactory(), protectedCtorOld::reflectionObjectFactory(), privateCtorOld::reflectionObjectFactory() ); foreach($reflectionObjects as $reflectionObject ) { $name = $reflectionObject->getName(); echo "Is $name instantiable? "; var_dump($reflectionObject->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) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt --TEST-- ReflectionObject::isInternal() - basic function test --FILE-- <?php class C { } $r1 = new ReflectionObject(new stdClass); $r2 = new ReflectionObject(new ReflectionClass('C')); $r3 = new ReflectionObject(new ReflectionProperty('Exception', 'message')); $r4 = new ReflectionObject(new Exception); $r5 = new ReflectionObject(new C); var_dump($r1->isInternal(), $r2->isInternal(), $r3->isInternal(), $r4->isInternal(), $r5->isInternal()); ?> --EXPECTF-- bool(true) bool(true) bool(true) bool(true) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isInternal_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isInternal_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isInternal_error.phpt --TEST-- ReflectionObject::isInternal() - invalid params --FILE-- <?php $r1 = new ReflectionObject(new stdClass); var_dump($r1->isInternal('X')); var_dump($r1->isInternal('X', true)); ?> --EXPECTF-- Warning: ReflectionClass::isInternal() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::isInternal() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt --TEST-- ReflectionObject::isSubclassOf() - basic function test --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'); //Create ReflectionClasses foreach ($classNames as $className) { $rcs[$className] = new ReflectionClass($className); } //Create ReflectionObjects foreach ($classNames as $className) { if ($rcs[$className]->isInstantiable()) { $ros[$className] = new ReflectionObject(new $className); } } foreach ($ros as $childName => $child) { foreach ($rcs as $parentName => $parent) { echo "Is " . $childName . " a subclass of " . $parentName . "? \n"; echo " - Using ReflectionClass object argument: "; var_dump($child->isSubclassOf($parent)); if ($parent->isInstantiable()) { echo " - Using ReflectionObject object argument: "; var_dump($child->isSubclassOf($ros[$parentName])); } echo " - Using string argument: "; var_dump($child->isSubclassOf($parentName)); } } ?> --EXPECTF-- Is A a subclass of A? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is A a subclass of B? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is A a subclass of C? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is A a subclass of I? - Using ReflectionClass object argument: bool(false) - Using string argument: bool(false) Is A a subclass of X? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is B a subclass of A? - Using ReflectionClass object argument: bool(true) - Using ReflectionObject object argument: bool(true) - Using string argument: bool(true) Is B a subclass of B? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is B a subclass of C? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is B a subclass of I? - Using ReflectionClass object argument: bool(false) - Using string argument: bool(false) Is B a subclass of X? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is C a subclass of A? - Using ReflectionClass object argument: bool(true) - Using ReflectionObject object argument: bool(true) - Using string argument: bool(true) Is C a subclass of B? - Using ReflectionClass object argument: bool(true) - Using ReflectionObject object argument: bool(true) - Using string argument: bool(true) Is C a subclass of C? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is C a subclass of I? - Using ReflectionClass object argument: bool(false) - Using string argument: bool(false) Is C a subclass of X? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is X a subclass of A? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is X a subclass of B? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is X a subclass of C? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) Is X a subclass of I? - Using ReflectionClass object argument: bool(true) - Using string argument: bool(true) Is X a subclass of X? - Using ReflectionClass object argument: bool(false) - Using ReflectionObject object argument: bool(false) - Using string argument: bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt --TEST-- ReflectionObject::isSubclassOf() - invalid params --FILE-- <?php class A {} $ro = new ReflectionObject(new A); var_dump($ro->isSubclassOf()); var_dump($ro->isSubclassOf('A',5)); var_dump($ro->isSubclassOf('X')); ?> --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 Fatal error: Uncaught exception 'ReflectionException' with message 'Class X does not exist' in %s:7 Stack trace: #0 %s(7): ReflectionClass->isSubclassOf('X') #1 {main} thrown in %s on line 7 http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt --TEST-- ReflectionObject::isUserDefined() - basic function test --FILE-- <?php class C { } $r1 = new ReflectionObject(new stdClass); $r2 = new ReflectionObject(new ReflectionClass('C')); $r3 = new ReflectionObject(new ReflectionProperty('Exception', 'message')); $r4 = new ReflectionObject(new Exception); $r5 = new ReflectionObject(new C); var_dump($r1->isUserDefined(), $r2->isUserDefined(), $r3->isUserDefined(), $r4->isUserDefined(), $r5->isUserDefined()); ?> --EXPECTF-- bool(false) bool(false) bool(false) bool(false) bool(true) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt +++ php-src/ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt --TEST-- ReflectionObject::isUserDefined() - invalid params --FILE-- <?php $r1 = new ReflectionObject(new stdClass); var_dump($r1->isUserDefined('X')); var_dump($r1->isUserDefined('X', true)); ?> --EXPECTF-- Warning: ReflectionClass::isUserDefined() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionClass::isUserDefined() expects exactly 0 parameters, 2 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_export_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_export_basic.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_export_basic.phpt --TEST-- ReflectionParameter::export() --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); foreach($reflect->getParameters() as $key => $value) { echo ReflectionParameter::export('ReflectionParameterTest', $key); } ?> ==DONE== --EXPECT-- Parameter #0 [ <required> $test ] Parameter #1 [ <optional> $test2 = NULL ] ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_export_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_export_error.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_export_error.phpt --TEST-- ReflectionParameter::export() without parameters --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); foreach($reflect->getParameters() as $key => $value) { ReflectionParameter::export(); } ?> ==DONE== --EXPECTF-- Warning: ReflectionParameter::export() expects at least 2 parameters, 0 given in %s.php on line %d Warning: ReflectionParameter::export() expects at least 2 parameters, 0 given in %s.php on line %d ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_export_error2.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_export_error2.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_export_error2.phpt --TEST-- ReflectionParameter::export() with incorrect first parameter --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); $params = $reflect->getParameters(); try { foreach($params as $key => $value) { ReflectionParameter::export($reflect, $key); } } catch (ReflectionException $e) { echo $e->getMessage() . "\n"; } try { foreach($params as $key => $value) { ReflectionParameter::export(42, $key); } } catch (ReflectionException $e) { echo $e->getMessage() . "\n"; } ?> --EXPECTF-- Method ReflectionFunction::__invoke() does not exist The parameter class is expected to be either a string, an array(class, method) or a callable object http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_export_error3.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_export_error3.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_export_error3.phpt --TEST-- ReflectionParameter::export() with incorrect second parameter --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); $params = $reflect->getParameters(); foreach($params as $key => $value) { ReflectionParameter::export('ReflectionParameterTest', 'incorrect_parameter'); } --EXPECTF-- Fatal error: Uncaught exception 'ReflectionException' with message 'The parameter specified by its name could not be found' in %s.php:%d Stack trace: #0 [internal function]: ReflectionParameter->__construct('ReflectionParam...', 'incorrect_param...') #1 %s.php(%d): ReflectionParameter::export('ReflectionParam...', 'incorrect_param...') #2 {main} thrown in %s.php on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt --TEST-- ReflectionParameter::getDeclaringFunction() --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> #testfest roosendaal on 2008-05-10 --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); $params = $reflect->getParameters(); foreach($params as $key => $value) { echo $value->getDeclaringFunction() . "\n"; } ?> ==DONE== --EXPECTF-- Function [ <user> function ReflectionParameterTest ] { @@ %s.php %d - %d - Parameters [2] { Parameter #0 [ <required> $test ] Parameter #1 [ <optional> $test2 = NULL ] } } Function [ <user> function ReflectionParameterTest ] { @@ %s.php %d - %d - Parameters [2] { Parameter #0 [ <required> $test ] Parameter #1 [ <optional> $test2 = NULL ] } } ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt --TEST-- ReflectionParameter::getPosition() --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> #testfest roosendaal on 2008-05-10 --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); $params = $reflect->getParameters(); foreach($params as $key => $value) { var_dump($value->getPosition()); } ?> ==DONE== --EXPECT-- int(0) int(1) ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt --TEST-- ReflectionParameter::__construct(): Invalid method as constructor --FILE-- <?php // Invalid class name try { new ReflectionParameter (array ('A', 'b'), 0); } catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } // Invalid class method try { new ReflectionParameter (array ('C', 'b'), 0); } catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } // Invalid object method try { new ReflectionParameter (array (new C, 'b'), 0); } catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } echo "Done.\n"; class C { } ?> --EXPECTF-- Class A does not exist Method C::b() does not exist Method C::b() does not exist Done. http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionParameter_toString_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionParameter_toString_basic.phpt +++ php-src/ext/reflection/tests/ReflectionParameter_toString_basic.phpt --TEST-- ReflectionParameter::__toString() --CREDITS-- Stefan Koopmanschap <stefan@stefankoopmanschap.nl> --FILE-- <?php function ReflectionParameterTest($test, $test2 = null) { echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); $params = $reflect->getParameters(); foreach($params as $key => $value) { echo $value->__toString() . "\n"; } ?> ==DONE== --EXPECT-- Parameter #0 [ <required> $test ] Parameter #1 [ <optional> $test2 = NULL ] ==DONE== http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_basic1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_basic1.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_basic1.phpt --TEST-- Test usage of ReflectionProperty methods __toString(), export(), getName(), isPublic(), isPrivate(), isProtected(), isStatic(), getValue() and setValue(). --FILE-- <?php function reflectProperty($class, $property) { $propInfo = new ReflectionProperty($class, $property); echo "**********************************\n"; echo "Reflecting on property $class::$property\n\n"; echo "__toString():\n"; var_dump($propInfo->__toString()); echo "export():\n"; var_dump(ReflectionProperty::export($class, $property, true)); echo "export():\n"; var_dump(ReflectionProperty::export($class, $property, false)); echo "getName():\n"; var_dump($propInfo->getName()); echo "isPublic():\n"; var_dump($propInfo->isPublic()); echo "isPrivate():\n"; var_dump($propInfo->isPrivate()); echo "isProtected():\n"; var_dump($propInfo->isProtected()); echo "isStatic():\n"; var_dump($propInfo->isStatic()); $instance = new $class(); if ($propInfo->isPublic()) { echo "getValue():\n"; var_dump($propInfo->getValue($instance)); $propInfo->setValue($instance, "NewValue"); echo "getValue() after a setValue():\n"; var_dump($propInfo->getValue($instance)); } echo "\n**********************************\n"; } class TestClass { public $pub; static public $stat = "static property"; protected $prot = 4; private $priv = "keepOut"; } reflectProperty("TestClass", "pub"); reflectProperty("TestClass", "stat"); reflectProperty("TestClass", "prot"); reflectProperty("TestClass", "priv"); ?> --EXPECT-- ********************************** Reflecting on property TestClass::pub __toString(): unicode(35) "Property [ <default> public $pub ] " export(): unicode(35) "Property [ <default> public $pub ] " export(): Property [ <default> public $pub ] NULL getName(): unicode(3) "pub" isPublic(): bool(true) isPrivate(): bool(false) isProtected(): bool(false) isStatic(): bool(false) getValue(): NULL getValue() after a setValue(): unicode(8) "NewValue" ********************************** ********************************** Reflecting on property TestClass::stat __toString(): unicode(33) "Property [ public static $stat ] " export(): unicode(33) "Property [ public static $stat ] " export(): Property [ public static $stat ] NULL getName(): unicode(4) "stat" isPublic(): bool(true) isPrivate(): bool(false) isProtected(): bool(false) isStatic(): bool(true) getValue(): unicode(15) "static property" getValue() after a setValue(): unicode(8) "NewValue" ********************************** ********************************** Reflecting on property TestClass::prot __toString(): unicode(39) "Property [ <default> protected $prot ] " export(): unicode(39) "Property [ <default> protected $prot ] " export(): Property [ <default> protected $prot ] NULL getName(): unicode(4) "prot" isPublic(): bool(false) isPrivate(): bool(false) isProtected(): bool(true) isStatic(): bool(false) ********************************** ********************************** Reflecting on property TestClass::priv __toString(): unicode(37) "Property [ <default> private $priv ] " export(): unicode(37) "Property [ <default> private $priv ] " export(): Property [ <default> private $priv ] NULL getName(): unicode(4) "priv" isPublic(): bool(false) isPrivate(): bool(true) isProtected(): bool(false) isStatic(): bool(false) ********************************** http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_basic2.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_basic2.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_basic2.phpt --TEST-- Test usage of ReflectionProperty methods isDefault(), getModifiers(), getDeclaringClass() and getDocComment(). --FILE-- <?php function reflectProperty($class, $property) { $propInfo = new ReflectionProperty($class, $property); echo "**********************************\n"; echo "Reflecting on property $class::$property\n\n"; echo "isDefault():\n"; var_dump($propInfo->isDefault()); echo "getModifiers():\n"; var_dump($propInfo->getModifiers()); echo "getDeclaringClass():\n"; var_dump($propInfo->getDeclaringClass()); echo "getDocComment():\n"; var_dump($propInfo->getDocComment()); echo "\n**********************************\n"; } class TestClass { public $pub; static public $stat = "static property"; /** * This property has a comment. */ protected $prot = 4; private $priv = "keepOut"; } reflectProperty("TestClass", "pub"); reflectProperty("TestClass", "stat"); reflectProperty("TestClass", "prot"); reflectProperty("TestClass", "priv"); ?> --EXPECTF-- ********************************** Reflecting on property TestClass::pub isDefault(): bool(true) getModifiers(): int(256) getDeclaringClass(): object(ReflectionClass)#%d (1) { [u"name"]=> unicode(9) "TestClass" } getDocComment(): bool(false) ********************************** ********************************** Reflecting on property TestClass::stat isDefault(): bool(true) getModifiers(): int(257) getDeclaringClass(): object(ReflectionClass)#%d (1) { [u"name"]=> unicode(9) "TestClass" } getDocComment(): bool(false) ********************************** ********************************** Reflecting on property TestClass::prot isDefault(): bool(true) getModifiers(): int(512) getDeclaringClass(): object(ReflectionClass)#%d (1) { [u"name"]=> unicode(9) "TestClass" } getDocComment(): unicode(47) "/** * This property has a comment. */" ********************************** ********************************** Reflecting on property TestClass::priv isDefault(): bool(true) getModifiers(): int(1024) getDeclaringClass(): object(ReflectionClass)#%d (1) { [u"name"]=> unicode(9) "TestClass" } getDocComment(): bool(false) ********************************** http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_constructor_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_constructor_error.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_constructor_error.phpt --TEST-- Test ReflectionProperty class constructor errors. --FILE-- <?php class TestClass { } $a = 5; echo "Non-existent class:\n"; try { $propInfo = new ReflectionProperty("NonExistentClass", "prop"); } catch(Exception $e) { echo $e->getMessage(); } echo "\n\nWrong property parameter type:\n"; try { $propInfo = new ReflectionProperty($a, 'TestClass'); } catch(ReflectionException $e) { echo $e->getMessage(); } echo "\n\nNon-existent property:\n"; try { $propInfo = new ReflectionProperty('TestClass', "nonExistentProperty"); } catch(Exception $e) { echo $e->getMessage(); } ?> --EXPECT-- Non-existent class: Class NonExistentClass does not exist Wrong property parameter type: The parameter class is expected to be either a string or an object Non-existent property: Property TestClass::$nonExistentProperty does not exist http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt --TEST-- ReflectionProperty::__construct(): ensure inherited private props can't be accessed through ReflectionProperty. --FILE-- <?php class C { private $p = 1; static function testFromC() { try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); } catch (Exception $e) { echo $e->getMessage(); } } } class D extends C{ static function testFromD() { try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); } catch (Exception $e) { echo $e->getMessage(); } } } echo "--> Reflect inherited private from global scope:\n"; try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); } catch (Exception $e) { echo $e->getMessage(); } echo "\n\n--> Reflect inherited private from declaring scope:\n"; C::testFromC(); echo "\n\n--> Reflect inherited private from declaring scope via subclass:\n"; D::testFromC(); echo "\n\n--> Reflect inherited private from subclass:\n"; D::testFromD(); ?> --EXPECTF-- --> Reflect inherited private from global scope: Property D::$p does not exist --> Reflect inherited private from declaring scope: Property D::$p does not exist --> Reflect inherited private from declaring scope via subclass: Property D::$p does not exist --> Reflect inherited private from subclass: Property D::$p does not exist http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_error.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_error.phpt --TEST-- Test ReflectionProperty class errors. --FILE-- <?php class C { public static $p; } var_dump(new ReflectionProperty()); var_dump(new ReflectionProperty('C::p')); var_dump(new ReflectionProperty('C', 'p', 'x')); $rp = new ReflectionProperty('C', 'p'); var_dump($rp->getName(1)); var_dump($rp->isPrivate(1)); var_dump($rp->isProtected(1)); var_dump($rp->isPublic(1)); var_dump($rp->isStatic(1)); var_dump($rp->getModifiers(1)); var_dump($rp->isDefault(1)); ?> --EXPECTF-- Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 0 given in %s on line %d object(ReflectionProperty)#%d (2) { [u"name"]=> unicode(0) "" [u"class"]=> unicode(0) "" } Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 1 given in %s on line %d object(ReflectionProperty)#%d (2) { [u"name"]=> unicode(0) "" [u"class"]=> unicode(0) "" } Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 3 given in %s on line %d object(ReflectionProperty)#%d (2) { [u"name"]=> unicode(0) "" [u"class"]=> unicode(0) "" } Warning: ReflectionProperty::getName() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::isPrivate() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::isProtected() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::isPublic() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::isStatic() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::getModifiers() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::isDefault() expects exactly 0 parameters, 1 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_export_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_export_basic.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_export_basic.phpt --TEST-- Test ReflectionProperty::export() usage. --FILE-- <?php class TestClass { public $proper = 5; } var_dump(ReflectionProperty::export('TestClass', 'proper')); ?> --EXPECT-- Property [ <default> public $proper ] NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_export_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_export_error.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_export_error.phpt --TEST-- Test ReflectionProperty::export() errors. --FILE-- <?php class TestClass { } $a = 5; echo "Non-existent class:\n"; try { ReflectionProperty::export("NonExistentClass", "prop", true); } catch(Exception $e) { echo $e->getMessage(); } echo "\n\nWrong property parameter type:\n"; try { ReflectionProperty::export($a, 'TestClass', false); } catch(ReflectionException $e) { echo $e->getMessage(); } echo "\n\nNon-existent property:\n"; try { ReflectionProperty::export('TestClass', "nonExistentProperty", true); } catch(Exception $e) { echo $e->getMessage(); } echo "\n\nIncorrect number of args:\n"; ReflectionProperty::export(); ReflectionProperty::export('TestClass', "nonExistentProperty", true, false); ?> --EXPECTF-- Non-existent class: Class NonExistentClass does not exist Wrong property parameter type: The parameter class is expected to be either a string or an object Non-existent property: Property TestClass::$nonExistentProperty does not exist Incorrect number of args: Warning: ReflectionProperty::export() expects at least 2 parameters, 0 given in %s on line %d Warning: ReflectionProperty::export() expects at most 3 parameters, 4 given in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt --TEST-- Test ReflectionProperty::getDeclaringClass() with inherited properties. --FILE-- <?php class A { public $prop; } class B extends A { } $propInfo = new ReflectionProperty('B', 'prop'); var_dump($propInfo->getDeclaringClass()); echo "Wrong number of params:\n"; $propInfo->getDeclaringClass(1); ?> --EXPECTF-- object(ReflectionClass)#%d (1) { [u"name"]=> unicode(1) "A" } Wrong number of params: Warning: ReflectionProperty::getDeclaringClass() expects exactly 0 parameters, 1 given in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_getDocComment_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_getDocComment_basic.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_getDocComment_basic.phpt --TEST-- Test ReflectionProperty::getDocComment() usage. --FILE-- <?php class A { /** * My Doc Comment for $a * */ public $a = 2, $b, $c = 1; /** * My Doc Comment for $d */ var $d; /**Not a doc comment */ private $e; /** * Doc comment for $f */ static protected $f; } class B extends A { public $a = 2; /** A doc comment for $b */ var $b, $c = 1; /** A doc comment for $e */ var $e; } foreach(array('A', 'B') as $class) { $rc = new ReflectionClass($class); $rps = $rc->getProperties(); foreach($rps as $rp) { echo "\n\n---> Doc comment for $class::$" . $rp->getName() . ":\n"; var_dump($rp->getDocComment()); } } ?> --EXPECTF-- ---> Doc comment for A::$a: unicode(47) "/** * My Doc Comment for $a * */" ---> Doc comment for A::$b: bool(false) ---> Doc comment for A::$c: bool(false) ---> Doc comment for A::$d: unicode(40) "/** * My Doc Comment for $d */" ---> Doc comment for A::$e: bool(false) ---> Doc comment for A::$f: unicode(37) "/** * Doc comment for $f */" ---> Doc comment for B::$a: bool(false) ---> Doc comment for B::$b: unicode(27) "/** A doc comment for $b */" ---> Doc comment for B::$c: bool(false) ---> Doc comment for B::$e: unicode(27) "/** A doc comment for $e */" ---> Doc comment for B::$d: unicode(40) "/** * My Doc Comment for $d */" ---> Doc comment for B::$f: unicode(37) "/** * Doc comment for $f */" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt --TEST-- Test ReflectionProperty::getDocComment() errors. --FILE-- <?php class C { public $a; } $rc = new ReflectionProperty('C', 'a'); var_dump($rc->getDocComment(null)); var_dump($rc->getDocComment('X')); var_dump($rc->getDocComment(true)); var_dump($rc->getDocComment(array(1, 2, 3))); ?> --EXPECTF-- Warning: ReflectionProperty::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d NULL Warning: ReflectionProperty::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt --TEST-- Test ReflectionProperty::getModifiers() usage. --FILE-- <?php class C { public $a1; protected $a2; private $a3; static public $a4; static protected $a5; static private $a6; } class D extends C { public $a1; protected $a2; private $a3; static public $a4; static protected $a5; static private $a6; } for ($i = 1;$i <= 6;$i++) { $rp = new ReflectionProperty("C", "a$i"); echo "C::a$i: "; var_dump($rp->getModifiers()); $rp = new ReflectionProperty("D", "a$i"); echo "D::a$i: "; var_dump($rp->getModifiers()); } ?> --EXPECTF-- C::a1: int(256) D::a1: int(256) C::a2: int(512) D::a2: int(512) C::a3: int(1024) D::a3: int(3072) C::a4: int(257) D::a4: int(257) C::a5: int(513) D::a5: int(513) C::a6: int(1025) D::a6: int(3073) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_getValue_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_getValue_error.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_getValue_error.phpt --TEST-- Test ReflectionProperty::getValue() errors. --FILE-- <?php class TestClass { public $pub; public $pub2 = 5; static public $stat = "static property"; protected $prot = 4; private $priv = "keepOut"; } class AnotherClass { } $instance = new TestClass(); $instanceWithNoProperties = new AnotherClass(); $propInfo = new ReflectionProperty('TestClass', 'pub2'); echo "Too few args:\n"; var_dump($propInfo->getValue()); echo "\nToo many args:\n"; var_dump($propInfo->getValue($instance, true)); echo "\nWrong type of arg:\n"; var_dump($propInfo->getValue(true)); echo "\nInstance without property:\n"; $propInfo = new ReflectionProperty('TestClass', 'stat'); echo "\nStatic property / too many args:\n"; var_dump($propInfo->getValue($instance, true)); echo "\nStatic property / wrong type of arg:\n"; var_dump($propInfo->getValue(true)); echo "\nProtected property:\n"; try { $propInfo = new ReflectionProperty('TestClass', 'prot'); var_dump($propInfo->getValue($instance)); } catch(Exception $exc) { echo $exc->getMessage(); } echo "\n\nInstance without property:\n"; $propInfo = new ReflectionProperty('TestClass', 'pub2'); var_dump($propInfo->getValue($instanceWithNoProperties)); ?> --EXPECTF-- Too few args: Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 0 given in %s on line %d NULL Too many args: Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 2 given in %s on line %d NULL Wrong type of arg: Warning: ReflectionProperty::getValue() expects parameter 1 to be object, boolean given in %s on line %d NULL Instance without property: Static property / too many args: unicode(15) "static property" Static property / wrong type of arg: unicode(15) "static property" Protected property: Cannot access non-public member TestClass::prot Instance without property: NULL http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt --TEST-- Test ReflectionProperty::isDefault() usage. --FILE-- <?php function reflectProperty($class, $property) { $propInfo = new ReflectionProperty($class, $property); echo "**********************************\n"; echo "Reflecting on property $class::$property\n\n"; echo "isDefault():\n"; var_dump($propInfo->isDefault()); echo "\n**********************************\n"; } class TestClass { public $pub; static public $stat = "static property"; protected $prot = 4; private $priv = "keepOut"; } reflectProperty("TestClass", "pub"); reflectProperty("TestClass", "stat"); reflectProperty("TestClass", "prot"); reflectProperty("TestClass", "priv"); echo "Wrong number of params:\n"; $propInfo = new ReflectionProperty('TestClass', 'pub'); $propInfo->isDefault(1); ?> --EXPECTF-- ********************************** Reflecting on property TestClass::pub isDefault(): bool(true) ********************************** ********************************** Reflecting on property TestClass::stat isDefault(): bool(true) ********************************** ********************************** Reflecting on property TestClass::prot isDefault(): bool(true) ********************************** ********************************** Reflecting on property TestClass::priv isDefault(): bool(true) ********************************** Wrong number of params: Warning: ReflectionProperty::isDefault() expects exactly 0 parameters, 1 given in %s on line %d http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_setAccessible.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_setAccessible.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_setAccessible.phpt --TEST-- Test ReflectionProperty::setAccessible(). --FILE-- <?php class A { protected $protected = 'a'; protected static $protectedStatic = 'b'; private $private = 'c'; private static $privateStatic = 'd'; } class B extends A {} $a = new A; $protected = new ReflectionProperty($a, 'protected'); $protectedStatic = new ReflectionProperty('A', 'protectedStatic'); $private = new ReflectionProperty($a, 'private'); $privateStatic = new ReflectionProperty('A', 'privateStatic'); try { var_dump($protected->getValue($a)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($protectedStatic->getValue()); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($private->getValue($a)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($privateStatic->getValue()); } catch (ReflectionException $e) { var_dump($e->getMessage()); } $protected->setAccessible(TRUE); $protectedStatic->setAccessible(TRUE); $private->setAccessible(TRUE); $privateStatic->setAccessible(TRUE); var_dump($protected->getValue($a)); var_dump($protectedStatic->getValue()); var_dump($private->getValue($a)); var_dump($privateStatic->getValue()); $protected->setValue($a, 'e'); $protectedStatic->setValue('f'); $private->setValue($a, 'g'); $privateStatic->setValue('h'); var_dump($protected->getValue($a)); var_dump($protectedStatic->getValue()); var_dump($private->getValue($a)); var_dump($privateStatic->getValue()); $a = new A; $b = new B; $protected = new ReflectionProperty($b, 'protected'); $protectedStatic = new ReflectionProperty('B', 'protectedStatic'); $private = new ReflectionProperty($a, 'private'); try { var_dump($protected->getValue($b)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($protectedStatic->getValue()); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($private->getValue($b)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } $protected->setAccessible(TRUE); $protectedStatic->setAccessible(TRUE); $private->setAccessible(TRUE); var_dump($protected->getValue($b)); var_dump($protectedStatic->getValue()); var_dump($private->getValue($b)); $protected->setValue($b, 'e'); $protectedStatic->setValue('f'); $private->setValue($b, 'g'); var_dump($protected->getValue($b)); var_dump($protectedStatic->getValue()); var_dump($private->getValue($b)); ?> --EXPECT-- unicode(44) "Cannot access non-public member A::protected" unicode(50) "Cannot access non-public member A::protectedStatic" unicode(42) "Cannot access non-public member A::private" unicode(48) "Cannot access non-public member A::privateStatic" unicode(1) "a" unicode(1) "b" unicode(1) "c" unicode(1) "d" unicode(1) "e" unicode(1) "f" unicode(1) "g" unicode(1) "h" unicode(44) "Cannot access non-public member B::protected" unicode(50) "Cannot access non-public member B::protectedStatic" unicode(42) "Cannot access non-public member A::private" unicode(1) "a" unicode(1) "f" unicode(1) "c" unicode(1) "e" unicode(1) "f" unicode(1) "g" http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/ReflectionProperty_setValue_error.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/ReflectionProperty_setValue_error.phpt +++ php-src/ext/reflection/tests/ReflectionProperty_setValue_error.phpt --TEST-- Test ReflectionProperty::setValue() error cases. --FILE-- <?php class TestClass { public $pub; public $pub2 = 5; static public $stat = "static property"; protected $prot = 4; private $priv = "keepOut"; } class AnotherClass { } $instance = new TestClass(); $instanceWithNoProperties = new AnotherClass(); $propInfo = new ReflectionProperty('TestClass', 'pub2'); echo "Too few args:\n"; var_dump($propInfo->setValue()); var_dump($propInfo->setValue($instance)); echo "\nToo many args:\n"; var_dump($propInfo->setValue($instance, "NewValue", true)); echo "\nWrong type of arg:\n"; var_dump($propInfo->setValue(true, "NewValue")); $propInfo = new ReflectionProperty('TestClass', 'stat'); echo "\nStatic property / too many args:\n"; var_dump($propInfo->setValue($instance, "NewValue", true)); echo "\nStatic property / too few args:\n"; var_dump($propInfo->setValue("A new value")); var_dump(TestClass::$stat); var_dump($propInfo->setValue()); var_dump(TestClass::$stat); echo "\nStatic property / wrong type of arg:\n"; var_dump($propInfo->setValue(true, "Another new value")); var_dump(TestClass::$stat); echo "\nProtected property:\n"; try { $propInfo = new ReflectionProperty('TestClass', 'prot'); var_dump($propInfo->setValue($instance, "NewValue")); } catch(Exception $exc) { echo $exc->getMessage(); } echo "\n\nInstance without property:\n"; $propInfo = new ReflectionProperty('TestClass', 'pub2'); var_dump($propInfo->setValue($instanceWithNoProperties, "NewValue")); var_dump($instanceWithNoProperties->pub2); ?> --EXPECTF-- Too few args: Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d NULL Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 1 given in %s on line %d NULL Too many args: Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 3 given in %s on line %d NULL Wrong type of arg: Warning: ReflectionProperty::setValue() expects parameter 1 to be object, boolean given in %s on line %d NULL Static property / too many args: Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 3 given in %s on line %d NULL Static property / too few args: NULL unicode(11) "A new value" Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d NULL unicode(11) "A new value" Static property / wrong type of arg: NULL unicode(17) "Another new value" Protected property: Cannot access non-public member TestClass::prot Instance without property: NULL unicode(8) "NewValue"