summaryrefslogtreecommitdiff
path: root/ext/reflection/tests
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/reflection/tests
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/reflection/tests')
-rw-r--r--ext/reflection/tests/001.phpt89
-rw-r--r--ext/reflection/tests/002.phpt63
-rw-r--r--ext/reflection/tests/003.phpt31
-rw-r--r--ext/reflection/tests/004.phpt42
-rw-r--r--ext/reflection/tests/005.phpt54
-rw-r--r--ext/reflection/tests/006.phpt103
-rw-r--r--ext/reflection/tests/007.phpt160
-rw-r--r--ext/reflection/tests/008.phpt39
-rw-r--r--ext/reflection/tests/009.phpt112
-rw-r--r--ext/reflection/tests/010.phpt21
-rw-r--r--ext/reflection/tests/011.phpt12
-rw-r--r--ext/reflection/tests/012.phpt16
-rw-r--r--ext/reflection/tests/013.phpt13
-rw-r--r--ext/reflection/tests/014.phpt13
-rw-r--r--ext/reflection/tests/015.phpt15
-rw-r--r--ext/reflection/tests/016.phpt20
-rw-r--r--ext/reflection/tests/017.phpt33
-rw-r--r--ext/reflection/tests/018.phpt15
-rw-r--r--ext/reflection/tests/019.phpt11
-rw-r--r--ext/reflection/tests/020.phpt27
-rw-r--r--ext/reflection/tests/021.phpt16
-rw-r--r--ext/reflection/tests/022.phpt16
-rw-r--r--ext/reflection/tests/023.phpt32
-rw-r--r--ext/reflection/tests/024.phpt45
-rw-r--r--ext/reflection/tests/025.phpt114
-rw-r--r--ext/reflection/tests/026.phpt34
-rw-r--r--ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt15
-rw-r--r--ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt33
-rw-r--r--ext/reflection/tests/ReflectionClass_FileInfo_error.phpt37
-rw-r--r--ext/reflection/tests/ReflectionClass_constructor_001.phpt33
-rw-r--r--ext/reflection/tests/ReflectionClass_constructor_002.phpt67
-rw-r--r--ext/reflection/tests/ReflectionClass_export_basic1.phpt62
-rw-r--r--ext/reflection/tests/ReflectionClass_export_basic2.phpt54
-rw-r--r--ext/reflection/tests/ReflectionClass_getConstant_basic.phpt41
-rw-r--r--ext/reflection/tests/ReflectionClass_getConstant_error.phpt37
-rw-r--r--ext/reflection/tests/ReflectionClass_getConstants_basic.phpt48
-rw-r--r--ext/reflection/tests/ReflectionClass_getConstants_error.phpt24
-rw-r--r--ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt79
-rw-r--r--ext/reflection/tests/ReflectionClass_getConstructor_error.phpt23
-rw-r--r--ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt194
-rw-r--r--ext/reflection/tests/ReflectionClass_getDefaultProperties_002.phpt44
-rw-r--r--ext/reflection/tests/ReflectionClass_getDocComment_001.phpt98
-rw-r--r--ext/reflection/tests/ReflectionClass_getDocComment_002.phpt26
-rw-r--r--ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt14
-rw-r--r--ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt18
-rw-r--r--ext/reflection/tests/ReflectionClass_getExtension_basic.phpt17
-rw-r--r--ext/reflection/tests/ReflectionClass_getExtension_variation.phpt18
-rw-r--r--ext/reflection/tests/ReflectionClass_getInterfaceNames_basic.phpt23
-rw-r--r--ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt311
-rw-r--r--ext/reflection/tests/ReflectionClass_getInterfaces_002.phpt53
-rw-r--r--ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt69
-rw-r--r--ext/reflection/tests/ReflectionClass_getInterfaces_004.phpt27
-rw-r--r--ext/reflection/tests/ReflectionClass_getMethod_001.phpt168
-rw-r--r--ext/reflection/tests/ReflectionClass_getMethod_002.phpt74
-rw-r--r--ext/reflection/tests/ReflectionClass_getMethods_001.phpt140
-rw-r--r--ext/reflection/tests/ReflectionClass_getMethods_002.phpt18
-rw-r--r--ext/reflection/tests/ReflectionClass_getMethods_003.phpt191
-rw-r--r--ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt139
-rw-r--r--ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt37
-rw-r--r--ext/reflection/tests/ReflectionClass_getName_basic.phpt25
-rw-r--r--ext/reflection/tests/ReflectionClass_getName_error.phpt16
-rw-r--r--ext/reflection/tests/ReflectionClass_getName_error1.phpt8
-rw-r--r--ext/reflection/tests/ReflectionClass_getNamespaceName.phpt30
-rw-r--r--ext/reflection/tests/ReflectionClass_getParentClass.phpt21
-rw-r--r--ext/reflection/tests/ReflectionClass_getParentClass_001.phpt38
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperties_001.phpt126
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperties_002.phpt17
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperties_003.phpt189
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperty_001.phpt146
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperty_002.phpt72
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperty_003.phpt251
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperty_004.phpt251
-rw-r--r--ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt69
-rw-r--r--ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001_2_4.phpt61
-rw-r--r--ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt52
-rw-r--r--ext/reflection/tests/ReflectionClass_hasConstant_001.phpt36
-rw-r--r--ext/reflection/tests/ReflectionClass_hasConstant_002.phpt40
-rw-r--r--ext/reflection/tests/ReflectionClass_hasConstant_basic.phpt23
-rw-r--r--ext/reflection/tests/ReflectionClass_hasMethod_001.phpt75
-rw-r--r--ext/reflection/tests/ReflectionClass_hasMethod_002.phpt40
-rw-r--r--ext/reflection/tests/ReflectionClass_hasMethod_basic.phpt57
-rw-r--r--ext/reflection/tests/ReflectionClass_hasProperty_001.phpt75
-rw-r--r--ext/reflection/tests/ReflectionClass_hasProperty_002.phpt40
-rw-r--r--ext/reflection/tests/ReflectionClass_hasProperty_basic.phpt38
-rw-r--r--ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt155
-rw-r--r--ext/reflection/tests/ReflectionClass_isAbstract_basic.phpt21
-rw-r--r--ext/reflection/tests/ReflectionClass_isCloneable_001.phpt71
-rw-r--r--ext/reflection/tests/ReflectionClass_isCloneable_002.phpt25
-rw-r--r--ext/reflection/tests/ReflectionClass_isFinal_basic.phpt21
-rw-r--r--ext/reflection/tests/ReflectionClass_isInstance_basic.phpt51
-rw-r--r--ext/reflection/tests/ReflectionClass_isInstance_error.phpt39
-rw-r--r--ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt40
-rw-r--r--ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt19
-rw-r--r--ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt50
-rw-r--r--ext/reflection/tests/ReflectionClass_isInterface_basic.phpt25
-rw-r--r--ext/reflection/tests/ReflectionClass_isInternal_basic.phpt22
-rw-r--r--ext/reflection/tests/ReflectionClass_isInternal_error.phpt14
-rw-r--r--ext/reflection/tests/ReflectionClass_isIterateable_001.phpt89
-rw-r--r--ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt34
-rw-r--r--ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt25
-rw-r--r--ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt49
-rw-r--r--ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt103
-rw-r--r--ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt17
-rw-r--r--ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt16
-rw-r--r--ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt22
-rw-r--r--ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt14
-rw-r--r--ext/reflection/tests/ReflectionClass_modifiers_001.phpt44
-rw-r--r--ext/reflection/tests/ReflectionClass_modifiers_002.phpt27
-rw-r--r--ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt98
-rw-r--r--ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt20
-rw-r--r--ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt33
-rw-r--r--ext/reflection/tests/ReflectionClass_newInstance_001.phpt98
-rw-r--r--ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt79
-rw-r--r--ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001_2_4.phpt61
-rw-r--r--ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt60
-rw-r--r--ext/reflection/tests/ReflectionClass_toString_001.phpt350
-rw-r--r--ext/reflection/tests/ReflectionClass_toString_002.phpt123
-rw-r--r--ext/reflection/tests/ReflectionClass_toString_003.phpt120
-rw-r--r--ext/reflection/tests/ReflectionExtension_constructor_basic.phpt15
-rw-r--r--ext/reflection/tests/ReflectionExtension_constructor_error.phpt16
-rw-r--r--ext/reflection/tests/ReflectionExtension_export_basic.phpt22
-rw-r--r--ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt20
-rw-r--r--ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt14
-rw-r--r--ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt74
-rw-r--r--ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt22
-rw-r--r--ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt16
-rw-r--r--ext/reflection/tests/ReflectionExtension_getName_basic.phpt14
-rw-r--r--ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt16
-rw-r--r--ext/reflection/tests/ReflectionExtension_info_basic.phpt19
-rw-r--r--ext/reflection/tests/ReflectionExtension_isPersistant.phpt11
-rw-r--r--ext/reflection/tests/ReflectionExtension_isTemporary.phpt11
-rw-r--r--ext/reflection/tests/ReflectionFunction_001.phpt67
-rw-r--r--ext/reflection/tests/ReflectionFunction_construct.001.phpt23
-rw-r--r--ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt31
-rw-r--r--ext/reflection/tests/ReflectionFunction_getClosureThis.phpt17
-rw-r--r--ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt37
-rw-r--r--ext/reflection/tests/ReflectionFunction_getClosure_error.phpt27
-rw-r--r--ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt41
-rw-r--r--ext/reflection/tests/ReflectionFunction_getExtension.phpt19
-rw-r--r--ext/reflection/tests/ReflectionFunction_getExtensionName.phpt16
-rw-r--r--ext/reflection/tests/ReflectionFunction_getFileName.001.phpt18
-rw-r--r--ext/reflection/tests/ReflectionFunction_getFileName.002.phpt39
-rw-r--r--ext/reflection/tests/ReflectionFunction_getNamespaceName.phpt29
-rw-r--r--ext/reflection/tests/ReflectionFunction_isClosure_basic.phpt18
-rw-r--r--ext/reflection/tests/ReflectionFunction_isDeprecated_basic.phpt15
-rw-r--r--ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt17
-rw-r--r--ext/reflection/tests/ReflectionMethod_006.phpt100
-rw-r--r--ext/reflection/tests/ReflectionMethod_basic1.phpt298
-rw-r--r--ext/reflection/tests/ReflectionMethod_basic2.phpt188
-rw-r--r--ext/reflection/tests/ReflectionMethod_basic3.phpt167
-rw-r--r--ext/reflection/tests/ReflectionMethod_basic4.phpt170
-rw-r--r--ext/reflection/tests/ReflectionMethod_constructor_basic.phpt117
-rw-r--r--ext/reflection/tests/ReflectionMethod_constructor_error1.phpt103
-rw-r--r--ext/reflection/tests/ReflectionMethod_constructor_error2.phpt37
-rw-r--r--ext/reflection/tests/ReflectionMethod_getClosureThis.phpt53
-rw-r--r--ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt55
-rw-r--r--ext/reflection/tests/ReflectionMethod_getClosure_error.phpt73
-rw-r--r--ext/reflection/tests/ReflectionMethod_getDeclaringClass_basic.phpt30
-rw-r--r--ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt113
-rw-r--r--ext/reflection/tests/ReflectionMethod_getDocComment_error.phpt15
-rw-r--r--ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt242
-rw-r--r--ext/reflection/tests/ReflectionMethod_getStaticVariables_basic.phpt63
-rw-r--r--ext/reflection/tests/ReflectionMethod_invokeArgs_basic.phpt73
-rw-r--r--ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt36
-rw-r--r--ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt27
-rw-r--r--ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt117
-rw-r--r--ext/reflection/tests/ReflectionMethod_invoke_basic.phpt108
-rw-r--r--ext/reflection/tests/ReflectionMethod_invoke_error1.phpt71
-rw-r--r--ext/reflection/tests/ReflectionMethod_invoke_error2.phpt32
-rw-r--r--ext/reflection/tests/ReflectionMethod_returnsReference_basic.phpt23
-rw-r--r--ext/reflection/tests/ReflectionMethod_setAccessible.phpt111
-rw-r--r--ext/reflection/tests/ReflectionObject_FileInfo_basic.phpt25
-rw-r--r--ext/reflection/tests/ReflectionObject_FileInfo_error.phpt37
-rw-r--r--ext/reflection/tests/ReflectionObject___toString_basic1.phpt36
-rw-r--r--ext/reflection/tests/ReflectionObject___toString_basic2.phpt39
-rw-r--r--ext/reflection/tests/ReflectionObject_constructor_basic.phpt28
-rw-r--r--ext/reflection/tests/ReflectionObject_constructor_error.phpt49
-rw-r--r--ext/reflection/tests/ReflectionObject_export_basic1.phpt36
-rw-r--r--ext/reflection/tests/ReflectionObject_export_basic2.phpt39
-rw-r--r--ext/reflection/tests/ReflectionObject_export_basic3.phpt38
-rw-r--r--ext/reflection/tests/ReflectionObject_getConstant_basic.phpt41
-rw-r--r--ext/reflection/tests/ReflectionObject_getConstant_error.phpt34
-rw-r--r--ext/reflection/tests/ReflectionObject_getConstants_basic.phpt49
-rw-r--r--ext/reflection/tests/ReflectionObject_getConstants_error.phpt17
-rw-r--r--ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt79
-rw-r--r--ext/reflection/tests/ReflectionObject_getConstructor_error.phpt23
-rw-r--r--ext/reflection/tests/ReflectionObject_getName_basic.phpt27
-rw-r--r--ext/reflection/tests/ReflectionObject_getName_error.phpt23
-rw-r--r--ext/reflection/tests/ReflectionObject_getName_error1.phpt8
-rw-r--r--ext/reflection/tests/ReflectionObject_isInstance_basic.phpt33
-rw-r--r--ext/reflection/tests/ReflectionObject_isInstance_error.phpt38
-rw-r--r--ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt36
-rw-r--r--ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt22
-rw-r--r--ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt78
-rw-r--r--ext/reflection/tests/ReflectionObject_isInternal_basic.phpt23
-rw-r--r--ext/reflection/tests/ReflectionObject_isInternal_error.phpt15
-rw-r--r--ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt48
-rw-r--r--ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt116
-rw-r--r--ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt24
-rw-r--r--ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt23
-rw-r--r--ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt15
-rw-r--r--ext/reflection/tests/ReflectionParameter_001.phpt80
-rw-r--r--ext/reflection/tests/ReflectionParameter_002.phpt80
-rw-r--r--ext/reflection/tests/ReflectionParameter_003.phpt88
-rw-r--r--ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt52
-rw-r--r--ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt30
-rw-r--r--ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt23
-rw-r--r--ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt84
-rw-r--r--ext/reflection/tests/ReflectionParameter_export_basic.phpt19
-rw-r--r--ext/reflection/tests/ReflectionParameter_export_error.phpt21
-rw-r--r--ext/reflection/tests/ReflectionParameter_export_error2.phpt31
-rw-r--r--ext/reflection/tests/ReflectionParameter_export_error3.phpt22
-rw-r--r--ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt37
-rw-r--r--ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt21
-rw-r--r--ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt31
-rw-r--r--ext/reflection/tests/ReflectionParameter_isDefault.phpt34
-rw-r--r--ext/reflection/tests/ReflectionParameter_toString_basic.phpt20
-rw-r--r--ext/reflection/tests/ReflectionProperty_basic1.phpt160
-rw-r--r--ext/reflection/tests/ReflectionProperty_basic2.phpt103
-rw-r--r--ext/reflection/tests/ReflectionProperty_constructor_error.phpt44
-rw-r--r--ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt58
-rw-r--r--ext/reflection/tests/ReflectionProperty_error.phpt67
-rw-r--r--ext/reflection/tests/ReflectionProperty_export_basic.phpt16
-rw-r--r--ext/reflection/tests/ReflectionProperty_export_error.phpt54
-rw-r--r--ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt27
-rw-r--r--ext/reflection/tests/ReflectionProperty_getDocComment_basic.phpt100
-rw-r--r--ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt28
-rw-r--r--ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt66
-rw-r--r--ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt46
-rw-r--r--ext/reflection/tests/ReflectionProperty_getValue_error.phpt81
-rw-r--r--ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt63
-rw-r--r--ext/reflection/tests/ReflectionProperty_setAccessible.phpt139
-rw-r--r--ext/reflection/tests/ReflectionProperty_setValue_error.phpt100
-rw-r--r--ext/reflection/tests/bug26640.phpt25
-rw-r--r--ext/reflection/tests/bug26695.phpt25
-rw-r--r--ext/reflection/tests/bug29268.phpt27
-rw-r--r--ext/reflection/tests/bug29523.phpt38
-rw-r--r--ext/reflection/tests/bug29828.phpt35
-rw-r--r--ext/reflection/tests/bug29986.phpt41
-rw-r--r--ext/reflection/tests/bug30146.phpt23
-rw-r--r--ext/reflection/tests/bug30148.phpt35
-rw-r--r--ext/reflection/tests/bug30209.phpt31
-rw-r--r--ext/reflection/tests/bug30856.phpt20
-rw-r--r--ext/reflection/tests/bug30961.phpt20
-rw-r--r--ext/reflection/tests/bug31651.phpt24
-rw-r--r--ext/reflection/tests/bug32981.phpt34
-rw-r--r--ext/reflection/tests/bug33312.phpt20
-rw-r--r--ext/reflection/tests/bug33389.phpt97
-rw-r--r--ext/reflection/tests/bug36308.phpt20
-rw-r--r--ext/reflection/tests/bug36337.phpt28
-rw-r--r--ext/reflection/tests/bug36434.phpt31
-rw-r--r--ext/reflection/tests/bug37816.phpt28
-rw-r--r--ext/reflection/tests/bug37964.phpt50
-rw-r--r--ext/reflection/tests/bug38132.phpt32
-rw-r--r--ext/reflection/tests/bug38194.phpt11
-rw-r--r--ext/reflection/tests/bug38217.phpt40
-rw-r--r--ext/reflection/tests/bug38465.phpt64
-rw-r--r--ext/reflection/tests/bug38653.phpt28
-rw-r--r--ext/reflection/tests/bug38942.phpt34
-rw-r--r--ext/reflection/tests/bug39001.phpt27
-rw-r--r--ext/reflection/tests/bug39067.phpt45
-rw-r--r--ext/reflection/tests/bug39884.phpt22
-rw-r--r--ext/reflection/tests/bug40431.phpt136
-rw-r--r--ext/reflection/tests/bug40794.phpt32
-rw-r--r--ext/reflection/tests/bug41061.phpt28
-rw-r--r--ext/reflection/tests/bug41884.phpt25
-rw-r--r--ext/reflection/tests/bug42976.phpt38
-rw-r--r--ext/reflection/tests/bug43926.phpt67
-rw-r--r--ext/reflection/tests/bug45139.phpt58
-rw-r--r--ext/reflection/tests/bug45571.phpt40
-rw-r--r--ext/reflection/tests/bug45765.phpt82
-rw-r--r--ext/reflection/tests/bug46064.phpt76
-rw-r--r--ext/reflection/tests/bug46064_2.phpt74
-rw-r--r--ext/reflection/tests/bug46205.phpt14
-rw-r--r--ext/reflection/tests/bug47254.phpt41
-rw-r--r--ext/reflection/tests/bug48336.phpt44
-rw-r--r--ext/reflection/tests/bug48757.phpt21
-rw-r--r--ext/reflection/tests/bug49074.phpt31
-rw-r--r--ext/reflection/tests/bug49092.phpt12
-rw-r--r--ext/reflection/tests/bug49719.phpt44
-rw-r--r--ext/reflection/tests/bug51905.phpt28
-rw-r--r--ext/reflection/tests/bug51911.phpt22
-rw-r--r--ext/reflection/tests/bug52057.phpt54
-rw-r--r--ext/reflection/tests/bug52854.phpt28
-rw-r--r--ext/reflection/tests/bug53366.phpt25
-rw-r--r--ext/reflection/tests/bug53915.phpt28
-rw-r--r--ext/reflection/tests/bug60357.phpt10
-rw-r--r--ext/reflection/tests/bug60367.phpt28
-rw-r--r--ext/reflection/tests/bug61388.phpt32
-rw-r--r--ext/reflection/tests/bug62384.phpt21
-rw-r--r--ext/reflection/tests/bug62715.phpt24
-rw-r--r--ext/reflection/tests/bug63399.phpt49
-rw-r--r--ext/reflection/tests/bug63614.phpt41
-rw-r--r--ext/reflection/tests/closures_001.phpt70
-rw-r--r--ext/reflection/tests/closures_002.phpt29
-rw-r--r--ext/reflection/tests/closures_003.phpt25
-rw-r--r--ext/reflection/tests/closures_003_v1.phpt25
-rw-r--r--ext/reflection/tests/closures_004.phpt43
-rw-r--r--ext/reflection/tests/exception.inc16
-rw-r--r--ext/reflection/tests/included4.inc9
-rw-r--r--ext/reflection/tests/parameters_001.phpt38
-rw-r--r--ext/reflection/tests/parameters_002.phpt207
-rw-r--r--ext/reflection/tests/property_exists.phpt222
-rw-r--r--ext/reflection/tests/static_properties_002.phpt60
-rw-r--r--ext/reflection/tests/traits001.phpt70
-rw-r--r--ext/reflection/tests/traits002.phpt54
-rw-r--r--ext/reflection/tests/traits003.phpt30
-rw-r--r--ext/reflection/tests/traits004.phpt58
-rw-r--r--ext/reflection/tests/traits005.phpt41
309 files changed, 16444 insertions, 0 deletions
diff --git a/ext/reflection/tests/001.phpt b/ext/reflection/tests/001.phpt
new file mode 100644
index 0000000..f68afc9
--- /dev/null
+++ b/ext/reflection/tests/001.phpt
@@ -0,0 +1,89 @@
+--TEST--
+Reflection inheritance
+--FILE--
+<?php
+
+class ReflectionClassEx extends ReflectionClass
+{
+ public $bla;
+
+ function getMethodNames()
+ {
+ $res = array();
+ foreach($this->getMethods() as $m)
+ {
+ $res[] = $m->class . '::' . $m->name;
+ }
+ return $res;
+ }
+}
+
+$r = new ReflectionClassEx('ReflectionClassEx');
+
+$exp = array (
+ 'UMLClass::__clone',
+ 'UMLClass::export',
+ 'UMLClass::__construct',
+ 'UMLClass::__toString',
+ 'UMLClass::getName',
+ 'UMLClass::isInternal',
+ 'UMLClass::isUserDefined',
+ 'UMLClass::isInstantiable',
+ 'UMLClass::getFileName',
+ 'UMLClass::getStartLine',
+ 'UMLClass::getEndLine',
+ 'UMLClass::getDocComment',
+ 'UMLClass::getConstructor',
+ 'UMLClass::getMethod',
+ 'UMLClass::getMethods',
+ 'UMLClass::getProperty',
+ 'UMLClass::getProperties',
+ 'UMLClass::getConstants',
+ 'UMLClass::getConstant',
+ 'UMLClass::getInterfaces',
+ 'UMLClass::isInterface',
+ 'UMLClass::isAbstract',
+ 'UMLClass::isFinal',
+ 'UMLClass::getModifiers',
+ 'UMLClass::isInstance',
+ 'UMLClass::newInstance',
+ 'UMLClass::getParentClass',
+ 'UMLClass::isSubclassOf',
+ 'UMLClass::getStaticProperties',
+ 'UMLClass::getDefaultProperties',
+ 'UMLClass::isIterateable',
+ 'UMLClass::implementsInterface',
+ 'UMLClass::getExtension',
+ 'UMLClass::getExtensionName');
+
+$miss = array();
+
+$res = $r->getMethodNames();
+
+foreach($exp as $m)
+{
+ if (!in_array($m, $exp))
+ {
+ $miss[] = $m;
+ }
+}
+
+var_dump($miss);
+
+$props = array_keys(get_class_vars('ReflectionClassEx'));
+sort($props);
+var_dump($props);
+var_dump($r->name);
+?>
+===DONE===
+--EXPECT--
+array(0) {
+}
+array(2) {
+ [0]=>
+ string(3) "bla"
+ [1]=>
+ string(4) "name"
+}
+string(17) "ReflectionClassEx"
+===DONE===
diff --git a/ext/reflection/tests/002.phpt b/ext/reflection/tests/002.phpt
new file mode 100644
index 0000000..833fed4
--- /dev/null
+++ b/ext/reflection/tests/002.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Reflection properties are read only
+--FILE--
+<?php
+
+class ReflectionMethodEx extends ReflectionMethod
+{
+ public $foo = "xyz";
+
+ function __construct($c,$m)
+ {
+ echo __METHOD__ . "\n";
+ parent::__construct($c,$m);
+ }
+}
+
+$r = new ReflectionMethodEx('ReflectionMethodEx','getName');
+
+var_dump($r->class);
+var_dump($r->name);
+var_dump($r->foo);
+@var_dump($r->bar);
+
+try
+{
+ $r->class = 'bullshit';
+}
+catch(ReflectionException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+try
+{
+$r->name = 'bullshit';
+}
+catch(ReflectionException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+$r->foo = 'bar';
+$r->bar = 'baz';
+
+var_dump($r->class);
+var_dump($r->name);
+var_dump($r->foo);
+var_dump($r->bar);
+
+?>
+===DONE===
+--EXPECTF--
+ReflectionMethodEx::__construct
+%unicode|string%(26) "ReflectionFunctionAbstract"
+%unicode|string%(7) "getName"
+%unicode|string%(3) "xyz"
+NULL
+Cannot set read-only property ReflectionMethodEx::$class
+Cannot set read-only property ReflectionMethodEx::$name
+%unicode|string%(26) "ReflectionFunctionAbstract"
+%unicode|string%(7) "getName"
+%unicode|string%(3) "bar"
+%unicode|string%(3) "baz"
+===DONE===
diff --git a/ext/reflection/tests/003.phpt b/ext/reflection/tests/003.phpt
new file mode 100644
index 0000000..80bf0a6
--- /dev/null
+++ b/ext/reflection/tests/003.phpt
@@ -0,0 +1,31 @@
+--TEST--
+ReflectionMethod::invoke() with base class method
+--FILE--
+<?php
+
+class Foo
+{
+ function Test()
+ {
+ echo __METHOD__ . "\n";
+ }
+}
+
+class Bar extends Foo
+{
+ function Test()
+ {
+ echo __METHOD__ . "\n";
+ }
+}
+
+$o = new Bar;
+$r = new ReflectionMethod('Foo','Test');
+
+$r->invoke($o);
+
+?>
+===DONE===
+--EXPECT--
+Foo::Test
+===DONE===
diff --git a/ext/reflection/tests/004.phpt b/ext/reflection/tests/004.phpt
new file mode 100644
index 0000000..2c81c50
--- /dev/null
+++ b/ext/reflection/tests/004.phpt
@@ -0,0 +1,42 @@
+--TEST--
+ReflectionMethod::invoke() with non object or null value
+--FILE--
+<?php
+
+class a {
+ function a(){
+ }
+}
+class b {
+}
+
+$b = new b();
+
+$a=new ReflectionClass("a");
+$m=$a->getMethod("a");
+
+try {
+ $m->invoke(null);
+} catch (ReflectionException $E) {
+ echo $E->getMessage()."\n";
+}
+
+
+try {
+ $m->invoke($b);
+} catch (ReflectionException $E) {
+ echo $E->getMessage()."\n";
+}
+
+$b = new a();
+try {
+ $m->invoke($b);
+} catch (ReflectionException $E) {
+ echo $E->getMessage()."\n";
+}
+
+echo "===DONE===\n";?>
+--EXPECT--
+Non-object passed to Invoke()
+Given object is not an instance of the class this method was declared in
+===DONE===
diff --git a/ext/reflection/tests/005.phpt b/ext/reflection/tests/005.phpt
new file mode 100644
index 0000000..f337e44
--- /dev/null
+++ b/ext/reflection/tests/005.phpt
@@ -0,0 +1,54 @@
+--TEST--
+ReflectionMethod::getDocComment() uses wrong comment block
+--FILE--
+<?php
+
+function strip_doc_comment($c)
+{
+ if (!strlen($c) || $c === false) return $c;
+ return trim(substr($c, 3, -2));
+}
+
+/** Comment for class A */
+class A
+{
+ /** Method A::bla()
+ */
+ function bla()
+ {
+ }
+
+ function foo() {
+ /**
+ * This is a valid comment inside a method
+ */
+ }
+
+ function bar() {
+ // I don't have a doc comment....
+ }
+
+ /**
+ * Comment for A::baz()
+ */
+ function baz() {
+ }
+}
+
+$r = new ReflectionClass('A');
+var_dump(strip_doc_comment($r->getDocComment()));
+
+foreach($r->getMethods() as $m)
+{
+ var_dump(strip_doc_comment($m->getDocComment()));
+}
+
+?>
+===DONE===
+--EXPECT--
+string(19) "Comment for class A"
+string(15) "Method A::bla()"
+bool(false)
+bool(false)
+string(22) "* Comment for A::baz()"
+===DONE===
diff --git a/ext/reflection/tests/006.phpt b/ext/reflection/tests/006.phpt
new file mode 100644
index 0000000..89c4387
--- /dev/null
+++ b/ext/reflection/tests/006.phpt
@@ -0,0 +1,103 @@
+--TEST--
+ReflectionClass::[gs]etStaticPropertyValue
+--FILE--
+<?php
+
+/* ReflectionClass cannot touch protected or private static properties */
+
+/* ReflectionClass cannot create or delete static properties */
+
+Class Test
+{
+ static public $pub = 'pub';
+ static protected $pro = 'pro';
+ static private $pri = 'pri';
+
+ static function testing()
+ {
+ $ref = new ReflectionClass('Test');
+
+ foreach(array('pub', 'pro', 'pri') as $name)
+ {
+ try
+ {
+ var_dump($ref->getStaticPropertyValue($name));
+ var_dump($ref->getStaticPropertyValue($name));
+ $ref->setStaticPropertyValue($name, 'updated');
+ var_dump($ref->getStaticPropertyValue($name));
+ }
+ catch(Exception $e)
+ {
+ echo "EXCEPTION\n";
+ }
+ }
+ }
+}
+
+Class TestDerived extends Test
+{
+// static public $pub = 'pub';
+// static protected $pro = 'pro';
+ static private $pri = 'pri';
+
+ static function testing()
+ {
+ $ref = new ReflectionClass('Test');
+
+ foreach(array('pub', 'pro', 'pri') as $name)
+ {
+ try
+ {
+ var_dump($ref->getStaticPropertyValue($name));
+ var_dump($ref->getStaticPropertyValue($name));
+ $ref->setStaticPropertyValue($name, 'updated');
+ var_dump($ref->getStaticPropertyValue($name));
+ }
+ catch(Exception $e)
+ {
+ echo "EXCEPTION\n";
+ }
+ }
+ }
+}
+
+$ref = new ReflectionClass('Test');
+
+foreach(array('pub', 'pro', 'pri') as $name)
+{
+ try
+ {
+ var_dump($ref->getStaticPropertyValue($name));
+ var_dump($ref->getStaticPropertyValue($name));
+ $ref->setStaticPropertyValue($name, 'updated');
+ var_dump($ref->getStaticPropertyValue($name));
+ }
+ catch(Exception $e)
+ {
+ echo "EXCEPTION\n";
+ }
+}
+
+Test::testing();
+TestDerived::testing();
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+string(3) "pub"
+string(3) "pub"
+string(7) "updated"
+EXCEPTION
+EXCEPTION
+string(7) "updated"
+string(7) "updated"
+string(7) "updated"
+EXCEPTION
+EXCEPTION
+string(7) "updated"
+string(7) "updated"
+string(7) "updated"
+EXCEPTION
+EXCEPTION
+===DONE===
diff --git a/ext/reflection/tests/007.phpt b/ext/reflection/tests/007.phpt
new file mode 100644
index 0000000..004158c
--- /dev/null
+++ b/ext/reflection/tests/007.phpt
@@ -0,0 +1,160 @@
+--TEST--
+ReflectionClass::newInstance[Args]
+--FILE--
+<?php
+
+function test($class)
+{
+ echo "====>$class\n";
+ try
+ {
+ $ref = new ReflectionClass($class);
+ }
+ catch (ReflectionException $e)
+ {
+ var_dump($e->getMessage());
+ return; // only here
+ }
+
+ echo "====>newInstance()\n";
+ try
+ {
+ var_dump($ref->newInstance());
+ }
+ catch (ReflectionException $e)
+ {
+ var_dump($e->getMessage());
+ }
+
+ echo "====>newInstance(25)\n";
+ try
+ {
+ var_dump($ref->newInstance(25));
+ }
+ catch (ReflectionException $e)
+ {
+ var_dump($e->getMessage());
+ }
+
+ echo "====>newInstance(25, 42)\n";
+ try
+ {
+ var_dump($ref->newInstance(25, 42));
+ }
+ catch (ReflectionException $e)
+ {
+ var_dump($e->getMessage());
+ }
+
+ echo "\n";
+}
+
+function __autoload($class)
+{
+ echo __FUNCTION__ . "($class)\n";
+}
+
+test('Class_does_not_exist');
+
+Class NoCtor
+{
+}
+
+test('NoCtor');
+
+Class WithCtor
+{
+ function __construct()
+ {
+ echo __METHOD__ . "()\n";
+ var_dump(func_get_args());
+ }
+}
+
+test('WithCtor');
+
+Class WithCtorWithArgs
+{
+ function __construct($arg)
+ {
+ echo __METHOD__ . "($arg)\n";
+ var_dump(func_get_args());
+ }
+}
+
+test('WithCtorWithArgs');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+
+====>Class_does_not_exist
+__autoload(Class_does_not_exist)
+string(41) "Class Class_does_not_exist does not exist"
+====>NoCtor
+====>newInstance()
+object(NoCtor)#%d (0) {
+}
+====>newInstance(25)
+string(86) "Class NoCtor does not have a constructor, so you cannot pass any constructor arguments"
+====>newInstance(25, 42)
+string(86) "Class NoCtor does not have a constructor, so you cannot pass any constructor arguments"
+
+====>WithCtor
+====>newInstance()
+WithCtor::__construct()
+array(0) {
+}
+object(WithCtor)#%d (0) {
+}
+====>newInstance(25)
+WithCtor::__construct()
+array(1) {
+ [0]=>
+ int(25)
+}
+object(WithCtor)#%d (0) {
+}
+====>newInstance(25, 42)
+WithCtor::__construct()
+array(2) {
+ [0]=>
+ int(25)
+ [1]=>
+ int(42)
+}
+object(WithCtor)#%d (0) {
+}
+
+====>WithCtorWithArgs
+====>newInstance()
+
+Warning: Missing argument 1 for WithCtorWithArgs::__construct() in %s007.php on line %d
+
+Notice: Undefined variable: arg in %s007.php on line %d
+WithCtorWithArgs::__construct()
+array(0) {
+}
+object(WithCtorWithArgs)#%d (0) {
+}
+====>newInstance(25)
+WithCtorWithArgs::__construct(25)
+array(1) {
+ [0]=>
+ int(25)
+}
+object(WithCtorWithArgs)#%d (0) {
+}
+====>newInstance(25, 42)
+WithCtorWithArgs::__construct(25)
+array(2) {
+ [0]=>
+ int(25)
+ [1]=>
+ int(42)
+}
+object(WithCtorWithArgs)#%d (0) {
+}
+
+===DONE===
diff --git a/ext/reflection/tests/008.phpt b/ext/reflection/tests/008.phpt
new file mode 100644
index 0000000..2abdcdb
--- /dev/null
+++ b/ext/reflection/tests/008.phpt
@@ -0,0 +1,39 @@
+--TEST--
+ReflectionMethod::__construct() tests
+--FILE--
+<?php
+
+$a = array("", 1, "::", "a::", "::b", "a::b");
+
+foreach ($a as $val) {
+ try {
+ new ReflectionMethod($val);
+ } catch (Exception $e) {
+ var_dump($e->getMessage());
+ }
+}
+
+$a = array("", 1, "");
+$b = array("", "", 1);
+
+foreach ($a as $key=>$val) {
+ try {
+ new ReflectionMethod($val, $b[$key]);
+ } catch (Exception $e) {
+ var_dump($e->getMessage());
+ }
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(20) "Invalid method name "
+string(21) "Invalid method name 1"
+string(21) "Class does not exist"
+string(22) "Class a does not exist"
+string(21) "Class does not exist"
+string(22) "Class a does not exist"
+string(21) "Class does not exist"
+string(66) "The parameter class is expected to be either a string or an object"
+string(21) "Class does not exist"
+Done
diff --git a/ext/reflection/tests/009.phpt b/ext/reflection/tests/009.phpt
new file mode 100644
index 0000000..e96b21e
--- /dev/null
+++ b/ext/reflection/tests/009.phpt
@@ -0,0 +1,112 @@
+--TEST--
+ReflectionFunction basic tests
+--FILE--
+<?php
+
+/**
+hoho
+*/
+function test ($a, $b = 1, $c = "") {
+ static $var = 1;
+}
+
+$func = new ReflectionFunction("test");
+
+var_dump($func->export("test"));
+echo "--getName--\n";
+var_dump($func->getName());
+echo "--isInternal--\n";
+var_dump($func->isInternal());
+echo "--isUserDefined--\n";
+var_dump($func->isUserDefined());
+echo "--getFilename--\n";
+var_dump($func->getFilename());
+echo "--getStartline--\n";
+var_dump($func->getStartline());
+echo "--getEndline--\n";
+var_dump($func->getEndline());
+echo "--getDocComment--\n";
+var_dump($func->getDocComment());
+echo "--getStaticVariables--\n";
+var_dump($func->getStaticVariables());
+echo "--invoke--\n";
+var_dump($func->invoke(array(1,2,3)));
+echo "--invokeArgs--\n";
+var_dump($func->invokeArgs(array(1,2,3)));
+echo "--returnsReference--\n";
+var_dump($func->returnsReference());
+echo "--getParameters--\n";
+var_dump($func->getParameters());
+echo "--getNumberOfParameters--\n";
+var_dump($func->getNumberOfParameters());
+echo "--getNumberOfRequiredParameters--\n";
+var_dump($func->getNumberOfRequiredParameters());
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+/**
+hoho
+*/
+Function [ <user> function test ] {
+ @@ %s009.php 6 - 8
+
+ - Parameters [3] {
+ Parameter #0 [ <required> $a ]
+ Parameter #1 [ <optional> $b = 1 ]
+ Parameter #2 [ <optional> $c = '' ]
+ }
+}
+
+NULL
+--getName--
+string(4) "test"
+--isInternal--
+bool(false)
+--isUserDefined--
+bool(true)
+--getFilename--
+string(%d) "%s009.php"
+--getStartline--
+int(6)
+--getEndline--
+int(8)
+--getDocComment--
+string(11) "/**
+hoho
+*/"
+--getStaticVariables--
+array(1) {
+ ["var"]=>
+ int(1)
+}
+--invoke--
+NULL
+--invokeArgs--
+NULL
+--returnsReference--
+bool(false)
+--getParameters--
+array(3) {
+ [0]=>
+ &object(ReflectionParameter)#2 (1) {
+ ["name"]=>
+ string(1) "a"
+ }
+ [1]=>
+ &object(ReflectionParameter)#3 (1) {
+ ["name"]=>
+ string(1) "b"
+ }
+ [2]=>
+ &object(ReflectionParameter)#4 (1) {
+ ["name"]=>
+ string(1) "c"
+ }
+}
+--getNumberOfParameters--
+int(3)
+--getNumberOfRequiredParameters--
+int(1)
+Done
diff --git a/ext/reflection/tests/010.phpt b/ext/reflection/tests/010.phpt
new file mode 100644
index 0000000..8f92fee
--- /dev/null
+++ b/ext/reflection/tests/010.phpt
@@ -0,0 +1,21 @@
+--TEST--
+ReflectionMethod::__toString() tests (overriden method)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+class Foo {
+ function func() {
+ }
+}
+class Bar extends Foo {
+ function func() {
+ }
+}
+$m = new ReflectionMethod("Bar::func");
+echo $m;
+?>
+--EXPECTF--
+Method [ <user, overwrites Foo, prototype Foo> public method func ] {
+ @@ %s010.php 7 - 8
+}
diff --git a/ext/reflection/tests/011.phpt b/ext/reflection/tests/011.phpt
new file mode 100644
index 0000000..b39be37
--- /dev/null
+++ b/ext/reflection/tests/011.phpt
@@ -0,0 +1,12 @@
+--TEST--
+ReflectionExtension::getClasses()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+$ext = new ReflectionExtension("reflection");
+$classes = $ext->getClasses();
+echo $classes["ReflectionException"]->getName();
+?>
+--EXPECT--
+ReflectionException
diff --git a/ext/reflection/tests/012.phpt b/ext/reflection/tests/012.phpt
new file mode 100644
index 0000000..b8a2694
--- /dev/null
+++ b/ext/reflection/tests/012.phpt
@@ -0,0 +1,16 @@
+--TEST--
+ReflectionClass::getDefaultProperties()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+class Foo {
+ public $test = "ok";
+}
+$class = new ReflectionClass("Foo");
+$props = $class->getDefaultProperties();
+echo $props["test"];
+?>
+--EXPECT--
+ok
+
diff --git a/ext/reflection/tests/013.phpt b/ext/reflection/tests/013.phpt
new file mode 100644
index 0000000..9ecfa8b
--- /dev/null
+++ b/ext/reflection/tests/013.phpt
@@ -0,0 +1,13 @@
+--TEST--
+ReflectionExtension::getFunctions()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+$ext = new ReflectionExtension("standard");
+$funcs = $ext->getFunctions();
+echo $funcs["sleep"]->getName();
+?>
+--EXPECT--
+sleep
+
diff --git a/ext/reflection/tests/014.phpt b/ext/reflection/tests/014.phpt
new file mode 100644
index 0000000..8b5955f
--- /dev/null
+++ b/ext/reflection/tests/014.phpt
@@ -0,0 +1,13 @@
+--TEST--
+ReflectionExtension::getConstants()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+$ext = new ReflectionExtension("standard");
+$consts = $ext->getConstants();
+var_dump($consts["CONNECTION_NORMAL"]);
+?>
+--EXPECT--
+int(0)
+
diff --git a/ext/reflection/tests/015.phpt b/ext/reflection/tests/015.phpt
new file mode 100644
index 0000000..b172362
--- /dev/null
+++ b/ext/reflection/tests/015.phpt
@@ -0,0 +1,15 @@
+--TEST--
+ReflectionExtension::getINIEntries()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--INI--
+user_agent=php
+--FILE--
+<?php
+$ext = new ReflectionExtension("standard");
+$inis = $ext->getINIEntries();
+var_dump($inis["user_agent"]);
+?>
+--EXPECT--
+string(3) "php"
+
diff --git a/ext/reflection/tests/016.phpt b/ext/reflection/tests/016.phpt
new file mode 100644
index 0000000..d289165
--- /dev/null
+++ b/ext/reflection/tests/016.phpt
@@ -0,0 +1,20 @@
+--TEST--
+ReflectionExtension::getDependencies()
+--SKIPIF--
+<?php
+extension_loaded('reflection') or die('skip');
+if (!extension_loaded("xml")) {
+ die('skip xml extension not available');
+}
+?>
+--FILE--
+<?php
+$ext = new ReflectionExtension("xml");
+$deps = $ext->getDependencies();
+var_dump($deps);
+?>
+--EXPECT--
+array(1) {
+ ["libxml"]=>
+ string(8) "Required"
+}
diff --git a/ext/reflection/tests/017.phpt b/ext/reflection/tests/017.phpt
new file mode 100644
index 0000000..d40c4d8
--- /dev/null
+++ b/ext/reflection/tests/017.phpt
@@ -0,0 +1,33 @@
+--TEST--
+ReflectionClass::__toString() (constants)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+class Foo {
+ const test = "ok";
+}
+$class = new ReflectionClass("Foo");
+echo $class;
+?>
+--EXPECTF--
+Class [ <user> class Foo ] {
+ @@ %s017.php 2-4
+
+ - Constants [1] {
+ Constant [ string test ] { ok }
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [0] {
+ }
+}
+
diff --git a/ext/reflection/tests/018.phpt b/ext/reflection/tests/018.phpt
new file mode 100644
index 0000000..fbda5d6
--- /dev/null
+++ b/ext/reflection/tests/018.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Reflection::getModifierNames
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+var_dump(Reflection::getModifierNames(ReflectionMethod::IS_FINAL | ReflectionMethod::IS_PROTECTED));
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(5) "final"
+ [1]=>
+ string(9) "protected"
+}
diff --git a/ext/reflection/tests/019.phpt b/ext/reflection/tests/019.phpt
new file mode 100644
index 0000000..b6ac20c
--- /dev/null
+++ b/ext/reflection/tests/019.phpt
@@ -0,0 +1,11 @@
+--TEST--
+ReflectionFunction::getExtensionName
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+$f = new ReflectionFunction("sleep");
+var_dump($f->getExtensionName());
+?>
+--EXPECT--
+string(8) "standard"
diff --git a/ext/reflection/tests/020.phpt b/ext/reflection/tests/020.phpt
new file mode 100644
index 0000000..c5b0ae5
--- /dev/null
+++ b/ext/reflection/tests/020.phpt
@@ -0,0 +1,27 @@
+--TEST--
+ReflectionObject::hasProperty
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+class Foo {
+ public $p1;
+ protected $p2;
+ private $p3;
+
+ function __isset($name) {
+ var_dump($name);
+ return false;
+ }
+}
+$obj = new ReflectionObject(new Foo());
+var_dump($obj->hasProperty("p1"));
+var_dump($obj->hasProperty("p2"));
+var_dump($obj->hasProperty("p3"));
+var_dump($obj->hasProperty("p4"));
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(false)
diff --git a/ext/reflection/tests/021.phpt b/ext/reflection/tests/021.phpt
new file mode 100644
index 0000000..30dbb5a
--- /dev/null
+++ b/ext/reflection/tests/021.phpt
@@ -0,0 +1,16 @@
+--TEST--
+ReflectionClass::hasConstant
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+class Foo {
+ const c1 = 1;
+}
+$class = new ReflectionClass("Foo");
+var_dump($class->hasConstant("c1"));
+var_dump($class->hasConstant("c2"));
+?>
+--EXPECT--
+bool(true)
+bool(false)
diff --git a/ext/reflection/tests/022.phpt b/ext/reflection/tests/022.phpt
new file mode 100644
index 0000000..50dbd6e
--- /dev/null
+++ b/ext/reflection/tests/022.phpt
@@ -0,0 +1,16 @@
+--TEST--
+ReflectionClass::getConstant
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+class Foo {
+ const c1 = 1;
+}
+$class = new ReflectionClass("Foo");
+var_dump($class->getConstant("c1"));
+var_dump($class->getConstant("c2"));
+?>
+--EXPECT--
+int(1)
+bool(false)
diff --git a/ext/reflection/tests/023.phpt b/ext/reflection/tests/023.phpt
new file mode 100644
index 0000000..ab11365
--- /dev/null
+++ b/ext/reflection/tests/023.phpt
@@ -0,0 +1,32 @@
+--TEST--
+ReflectionClass::getDefaultProperties (filtering parent privates)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+class C1 {
+ private $p1 = 1;
+ protected $p2 = 2;
+ public $p3 = 3;
+}
+class C2 extends C1 {
+ private $p4 = 4;
+ protected $p5 = 5;
+ public $p6 = 6;
+}
+$class = new ReflectionClass("C2");
+var_dump($class->getDefaultProperties());
+?>
+--EXPECT--
+array(5) {
+ ["p4"]=>
+ int(4)
+ ["p5"]=>
+ int(5)
+ ["p6"]=>
+ int(6)
+ ["p2"]=>
+ int(2)
+ ["p3"]=>
+ int(3)
+}
diff --git a/ext/reflection/tests/024.phpt b/ext/reflection/tests/024.phpt
new file mode 100644
index 0000000..a1c2c81
--- /dev/null
+++ b/ext/reflection/tests/024.phpt
@@ -0,0 +1,45 @@
+--TEST--
+ReflectionObject::__toString (filtering privates/protected dynamic properties)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+class C1 {
+ private $p1 = 1;
+ protected $p2 = 2;
+ public $p3 = 3;
+}
+
+$x = new C1();
+$x->z = 4;
+$x->p3 = 5;
+
+$obj = new ReflectionObject($x);
+echo $obj;
+?>
+--EXPECTF--
+Object of class [ <user> class C1 ] {
+ @@ %s024.php 2-6
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [3] {
+ Property [ <default> private $p1 ]
+ Property [ <default> protected $p2 ]
+ Property [ <default> public $p3 ]
+ }
+
+ - Dynamic properties [1] {
+ Property [ <dynamic> public $z ]
+ }
+
+ - Methods [0] {
+ }
+}
diff --git a/ext/reflection/tests/025.phpt b/ext/reflection/tests/025.phpt
new file mode 100644
index 0000000..a5f604f
--- /dev/null
+++ b/ext/reflection/tests/025.phpt
@@ -0,0 +1,114 @@
+--TEST--
+ReflectionFunction basic tests
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+/**
+hoho
+*/
+function test ($a, $b = 1, $c = "") {
+ static $var = 1;
+}
+
+$func = new ReflectionFunction("test");
+
+var_dump($func->export("test"));
+echo "--getName--\n";
+var_dump($func->getName());
+echo "--isInternal--\n";
+var_dump($func->isInternal());
+echo "--isUserDefined--\n";
+var_dump($func->isUserDefined());
+echo "--getFilename--\n";
+var_dump($func->getFilename());
+echo "--getStartline--\n";
+var_dump($func->getStartline());
+echo "--getEndline--\n";
+var_dump($func->getEndline());
+echo "--getDocComment--\n";
+var_dump($func->getDocComment());
+echo "--getStaticVariables--\n";
+var_dump($func->getStaticVariables());
+echo "--invoke--\n";
+var_dump($func->invoke(array(1,2,3)));
+echo "--invokeArgs--\n";
+var_dump($func->invokeArgs(array(1,2,3)));
+echo "--returnsReference--\n";
+var_dump($func->returnsReference());
+echo "--getParameters--\n";
+var_dump($func->getParameters());
+echo "--getNumberOfParameters--\n";
+var_dump($func->getNumberOfParameters());
+echo "--getNumberOfRequiredParameters--\n";
+var_dump($func->getNumberOfRequiredParameters());
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+/**
+hoho
+*/
+Function [ <user> function test ] {
+ @@ %s 6 - 8
+
+ - Parameters [3] {
+ Parameter #0 [ <required> $a ]
+ Parameter #1 [ <optional> $b = 1 ]
+ Parameter #2 [ <optional> $c = '' ]
+ }
+}
+
+NULL
+--getName--
+string(4) "test"
+--isInternal--
+bool(false)
+--isUserDefined--
+bool(true)
+--getFilename--
+string(%d) "%s025.php"
+--getStartline--
+int(6)
+--getEndline--
+int(8)
+--getDocComment--
+string(11) "/**
+hoho
+*/"
+--getStaticVariables--
+array(1) {
+ ["var"]=>
+ int(1)
+}
+--invoke--
+NULL
+--invokeArgs--
+NULL
+--returnsReference--
+bool(false)
+--getParameters--
+array(3) {
+ [0]=>
+ &object(ReflectionParameter)#2 (1) {
+ ["name"]=>
+ string(1) "a"
+ }
+ [1]=>
+ &object(ReflectionParameter)#3 (1) {
+ ["name"]=>
+ string(1) "b"
+ }
+ [2]=>
+ &object(ReflectionParameter)#4 (1) {
+ ["name"]=>
+ string(1) "c"
+ }
+}
+--getNumberOfParameters--
+int(3)
+--getNumberOfRequiredParameters--
+int(1)
+Done
diff --git a/ext/reflection/tests/026.phpt b/ext/reflection/tests/026.phpt
new file mode 100644
index 0000000..dc4c4a3
--- /dev/null
+++ b/ext/reflection/tests/026.phpt
@@ -0,0 +1,34 @@
+--TEST--
+ReflectionExtension::info()
+--FILE--
+<?php
+$r = new ReflectionExtension("reflection");
+$r->info();
+
+date_default_timezone_set('Europe/Berlin');
+$r = new ReflectionExtension("date");
+$r->info();
+
+echo "\nDone!\n";
+?>
+--EXPECTF--
+Reflection
+
+Reflection => enabled
+Version => %s
+
+date
+
+date/time support => enabled
+"Olson" Timezone Database Version => %s
+Timezone Database => %s
+Default timezone => %s
+
+Directive => %s => %s
+date.timezone => %s => %s
+date.default_latitude => %s => %s
+date.default_longitude => %s => %s
+date.sunset_zenith => %s => %s
+date.sunrise_zenith => %s => %s
+
+Done!
diff --git a/ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt b/ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt
new file mode 100644
index 0000000..6b440cf
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Reflection class can not be cloned
+--CREDITS--
+Stefan Koopmanschap <stefan@phpgg.nl>
+TestFest PHP|Tek
+--SKIPIF--
+<?php
+if (!extension_loaded('reflection)) print 'skip';
+?>
+--FILE--
+<?php
+$rc = new ReflectionClass("stdClass");
+$rc2 = clone($rc);
+--EXPECTF--
+Fatal error: Trying to clone an uncloneable object of class ReflectionClass in %s on line %d
diff --git a/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt b/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt
new file mode 100644
index 0000000..da276e6
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt
@@ -0,0 +1,33 @@
+--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--
+string(%d) "%sReflectionClass_FileInfo_basic.php"
+int(20)
+int(22)
+bool(false)
+bool(false)
+bool(false)
diff --git a/ext/reflection/tests/ReflectionClass_FileInfo_error.phpt b/ext/reflection/tests/ReflectionClass_FileInfo_error.phpt
new file mode 100644
index 0000000..b42be13
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_FileInfo_error.phpt
@@ -0,0 +1,37 @@
+--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--
+string(%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
diff --git a/ext/reflection/tests/ReflectionClass_constructor_001.phpt b/ext/reflection/tests/ReflectionClass_constructor_001.phpt
new file mode 100644
index 0000000..1a70fe1
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_constructor_001.phpt
@@ -0,0 +1,33 @@
+--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) {
+ ["name"]=>
+ string(8) "stdClass"
+}
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(8) "stdClass"
+}
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(10) "TrickClass"
+}
diff --git a/ext/reflection/tests/ReflectionClass_constructor_002.phpt b/ext/reflection/tests/ReflectionClass_constructor_002.phpt
new file mode 100644
index 0000000..3685c63
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_constructor_002.phpt
@@ -0,0 +1,67 @@
+--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) {
+ ["name"]=>
+ string(0) ""
+}
+Class does not exist
+Class 1 does not exist
+Class 1 does not exist
+
+Notice: Array to string conversion in %s on line 27
+Class Array does not exist
+
+Warning: ReflectionClass::__construct() expects exactly 1 parameter, 2 given in %s on line 33
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(0) ""
+}
+Class X does not exist \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_export_basic1.phpt b/ext/reflection/tests/ReflectionClass_export_basic1.phpt
new file mode 100644
index 0000000..8729731
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_export_basic1.phpt
@@ -0,0 +1,62 @@
+--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 ]
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_export_basic2.phpt b/ext/reflection/tests/ReflectionClass_export_basic2.phpt
new file mode 100644
index 0000000..b664488
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_export_basic2.phpt
@@ -0,0 +1,54 @@
+--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] {
+ }
+} \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt b/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt
new file mode 100644
index 0000000..6e05111
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt
@@ -0,0 +1,41 @@
+--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:
+string(12) "hello from C"
+bool(false)
+Reflecting on class D:
+string(12) "hello from C"
+bool(false)
+Reflecting on class E:
+string(12) "hello from C"
+bool(false)
+Reflecting on class F:
+string(12) "hello from F"
+bool(false)
+Reflecting on class X:
+bool(false)
+bool(false)
diff --git a/ext/reflection/tests/ReflectionClass_getConstant_error.phpt b/ext/reflection/tests/ReflectionClass_getConstant_error.phpt
new file mode 100644
index 0000000..907d6d8
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getConstant_error.phpt
@@ -0,0 +1,37 @@
+--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, array given in %s on line 14
+NULL
+
+Warning: ReflectionClass::getConstant() expects parameter 1 to be string, object given in %s on line 15
+NULL \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt b/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt
new file mode 100644
index 0000000..9abdcc8
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt
@@ -0,0 +1,48 @@
+--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) {
+ ["a"]=>
+ string(12) "hello from C"
+}
+Constants from class D:
+array(1) {
+ ["a"]=>
+ string(12) "hello from C"
+}
+Constants from class E:
+array(1) {
+ ["a"]=>
+ string(12) "hello from C"
+}
+Constants from class F:
+array(1) {
+ ["a"]=>
+ string(12) "hello from F"
+}
+Constants from class X:
+array(0) {
+}
diff --git a/ext/reflection/tests/ReflectionClass_getConstants_error.phpt b/ext/reflection/tests/ReflectionClass_getConstants_error.phpt
new file mode 100644
index 0000000..1784d71
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getConstants_error.phpt
@@ -0,0 +1,24 @@
+--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
diff --git a/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt b/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt
new file mode 100644
index 0000000..1f5ba43
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt
@@ -0,0 +1,79 @@
+--TEST--
+ReflectionClass::getConstructor()
+--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 %d
+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
diff --git a/ext/reflection/tests/ReflectionClass_getConstructor_error.phpt b/ext/reflection/tests/ReflectionClass_getConstructor_error.phpt
new file mode 100644
index 0000000..7e8932a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getConstructor_error.phpt
@@ -0,0 +1,23 @@
+--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
diff --git a/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt b/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt
new file mode 100644
index 0000000..e19db81
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt
@@ -0,0 +1,194 @@
+--TEST--
+ReflectionClass::getDefaultProperties(), ReflectionClass::getStaticProperties()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+
+
+class A {
+ static public $statPubC = "stat pubC in A";
+ static protected $statProtC = "stat protC in A";
+ static private $statPrivC = "stat privC in A";
+
+ static public $statPubA = "stat pubA in A";
+ static protected $statProtA = "stat protA in A";
+ static private $statPrivA = "stat privA in A";
+
+ public $pubC = "pubC in A";
+ protected $protC = "protC in A";
+ private $privC = "privC in A";
+
+ public $pubA = "pubA in A";
+ protected $protA = "protA in A";
+ private $privA = "privA in A";
+}
+
+class B extends A {
+ static public $statPubC = "stat pubC in B";
+ static protected $statProtC = "stat protC in B";
+ static private $statPrivC = "stat privC in B";
+
+ static public $statPubB = "stat pubB in B";
+ static protected $statProtB = "stat protB in B";
+ static private $statPrivB = "stat privB in B";
+
+ public $pubC = "pubC in B";
+ protected $protC = "protC in B";
+ private $privC = "privC in B";
+
+ public $pubB = "pubB in B";
+ protected $protB = "protB in B";
+ private $privB = "privB in B";
+}
+
+class C extends B {
+ static public $statPubC = "stat pubC in C";
+ static protected $statProtC = "stat protC in C";
+ static private $statPrivC = "stat privC in C";
+
+ public $pubC = "pubC in C";
+ protected $protC = "protC in C";
+ private $privC = "privC in C";
+}
+
+class X {
+ static public $statPubC = "stat pubC in X";
+ static protected $statProtC = "stat protC in X";
+ static private $statPrivC = "stat privC in X";
+
+ public $pubC = "pubC in X";
+ protected $protC = "protC in X";
+ private $privC = "privC in X";
+}
+
+$classes = array('A', 'B', 'C', 'X');
+foreach ($classes as $class) {
+ $rc = new ReflectionClass($class);
+ echo "\n\n---- Static properties in $class ----\n";
+ print_r($rc->getStaticProperties());
+ echo "\n\n---- Default properties in $class ----\n";
+ print_r($rc->getDefaultProperties());
+}
+
+?>
+--EXPECTF--
+---- Static properties in A ----
+Array
+(
+ [statPubC] => stat pubC in A
+ [statProtC] => stat protC in A
+ [statPrivC] => stat privC in A
+ [statPubA] => stat pubA in A
+ [statProtA] => stat protA in A
+ [statPrivA] => stat privA in A
+)
+
+
+---- Default properties in A ----
+Array
+(
+ [statPubC] => stat pubC in A
+ [statProtC] => stat protC in A
+ [statPrivC] => stat privC in A
+ [statPubA] => stat pubA in A
+ [statProtA] => stat protA in A
+ [statPrivA] => stat privA in A
+ [pubC] => pubC in A
+ [protC] => protC in A
+ [privC] => privC in A
+ [pubA] => pubA in A
+ [protA] => protA in A
+ [privA] => privA in A
+)
+
+
+---- Static properties in B ----
+Array
+(
+ [statPubC] => stat pubC in B
+ [statProtC] => stat protC in B
+ [statPrivC] => stat privC in B
+ [statPubB] => stat pubB in B
+ [statProtB] => stat protB in B
+ [statPrivB] => stat privB in B
+ [statPubA] => stat pubA in A
+ [statProtA] => stat protA in A
+)
+
+
+---- Default properties in B ----
+Array
+(
+ [statPubC] => stat pubC in B
+ [statProtC] => stat protC in B
+ [statPrivC] => stat privC in B
+ [statPubB] => stat pubB in B
+ [statProtB] => stat protB in B
+ [statPrivB] => stat privB in B
+ [statPubA] => stat pubA in A
+ [statProtA] => stat protA in A
+ [pubC] => pubC in B
+ [protC] => protC in B
+ [privC] => privC in B
+ [pubB] => pubB in B
+ [protB] => protB in B
+ [privB] => privB in B
+ [pubA] => pubA in A
+ [protA] => protA in A
+)
+
+
+---- Static properties in C ----
+Array
+(
+ [statPubC] => stat pubC in C
+ [statProtC] => stat protC in C
+ [statPrivC] => stat privC in C
+ [statPubB] => stat pubB in B
+ [statProtB] => stat protB in B
+ [statPubA] => stat pubA in A
+ [statProtA] => stat protA in A
+)
+
+
+---- Default properties in C ----
+Array
+(
+ [statPubC] => stat pubC in C
+ [statProtC] => stat protC in C
+ [statPrivC] => stat privC in C
+ [statPubB] => stat pubB in B
+ [statProtB] => stat protB in B
+ [statPubA] => stat pubA in A
+ [statProtA] => stat protA in A
+ [pubC] => pubC in C
+ [protC] => protC in C
+ [privC] => privC in C
+ [pubB] => pubB in B
+ [protB] => protB in B
+ [pubA] => pubA in A
+ [protA] => protA in A
+)
+
+
+---- Static properties in X ----
+Array
+(
+ [statPubC] => stat pubC in X
+ [statProtC] => stat protC in X
+ [statPrivC] => stat privC in X
+)
+
+
+---- Default properties in X ----
+Array
+(
+ [statPubC] => stat pubC in X
+ [statProtC] => stat protC in X
+ [statPrivC] => stat privC in X
+ [pubC] => pubC in X
+ [protC] => protC in X
+ [privC] => privC in X
+)
diff --git a/ext/reflection/tests/ReflectionClass_getDefaultProperties_002.phpt b/ext/reflection/tests/ReflectionClass_getDefaultProperties_002.phpt
new file mode 100644
index 0000000..7c178ac
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getDefaultProperties_002.phpt
@@ -0,0 +1,44 @@
+--TEST--
+ReflectionClass::getDefaultProperties(), ReflectionClass::getStaticProperties() - wrong param count
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+interface I {}
+class C implements I {}
+$rc = new ReflectionClass('C');
+var_dump($rc->getDefaultProperties(null));
+var_dump($rc->getDefaultProperties('X'));
+var_dump($rc->getDefaultProperties(true));
+var_dump($rc->getDefaultProperties(array(1,2,3)));
+var_dump($rc->getStaticProperties(null));
+var_dump($rc->getStaticProperties('X'));
+var_dump($rc->getStaticProperties(true));
+var_dump($rc->getStaticProperties(array(1,2,3)));
+
+?>
+--EXPECTF--
+Warning: ReflectionClass::getDefaultProperties() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getDefaultProperties() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getDefaultProperties() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getDefaultProperties() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getStaticProperties() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getStaticProperties() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getStaticProperties() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getStaticProperties() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
diff --git a/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt b/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt
new file mode 100644
index 0000000..5feb560
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt
@@ -0,0 +1,98 @@
+--TEST--
+ReflectionClass::getDocComment()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+/**
+
+
+ My
+Doc
+ * Comment
+for A
+
+* */
+class A {}
+
+/** My DocComment for B */
+class B extends A { }
+
+class C extends B {}
+
+/**
+ * Interface doc comment
+ */
+
+
+
+
+interface I {}
+
+/*.*
+ * Not a doc comment
+ */
+class D implements I {}
+
+/**** Not a doc comment */
+class E extends C implements I {} {}
+
+/**?** Not a doc comment */
+class F extends C implements I {} {}
+
+/** ** Doc comment for G */
+final class G extends C implements I {} {}
+
+$classes = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'I');
+foreach ($classes as $class) {
+ echo "\n\n---> Doc comment for class $class:\n";
+ $rc = new ReflectionClass($class);
+ var_dump($rc->getDocComment());
+}
+
+
+?>
+--EXPECTF--
+
+
+---> Doc comment for class A:
+string(%d) "/**
+
+
+ My
+Doc
+ * Comment
+for A
+
+* */"
+
+
+---> Doc comment for class B:
+string(26) "/** My DocComment for B */"
+
+
+---> Doc comment for class C:
+bool(false)
+
+
+---> Doc comment for class D:
+bool(false)
+
+
+---> Doc comment for class E:
+bool(false)
+
+
+---> Doc comment for class F:
+bool(false)
+
+
+---> Doc comment for class G:
+string(27) "/** ** Doc comment for G */"
+
+
+---> Doc comment for class I:
+string(%d) "/**
+ * Interface doc comment
+ */" \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_getDocComment_002.phpt b/ext/reflection/tests/ReflectionClass_getDocComment_002.phpt
new file mode 100644
index 0000000..5bbd596
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getDocComment_002.phpt
@@ -0,0 +1,26 @@
+--TEST--
+ReflectionClass::getDocComment() - bad params
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {}
+$rc = new ReflectionClass('C');
+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: ReflectionClass::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
diff --git a/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt b/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt
new file mode 100644
index 0000000..310b22e
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt
@@ -0,0 +1,14 @@
+--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--
+string(3) "dom"
diff --git a/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt b/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt
new file mode 100644
index 0000000..998355c
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt
@@ -0,0 +1,18 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt b/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt
new file mode 100644
index 0000000..dbe157a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt
@@ -0,0 +1,17 @@
+--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) {
+ ["name"]=>
+ string(3) "dom"
+}
diff --git a/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt b/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt
new file mode 100644
index 0000000..5409504
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt
@@ -0,0 +1,18 @@
+--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
diff --git a/ext/reflection/tests/ReflectionClass_getInterfaceNames_basic.phpt b/ext/reflection/tests/ReflectionClass_getInterfaceNames_basic.phpt
new file mode 100644
index 0000000..6681c9f
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getInterfaceNames_basic.phpt
@@ -0,0 +1,23 @@
+--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]=>
+ string(3) "Foo"
+ [1]=>
+ string(3) "Bar"
+}
diff --git a/ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt b/ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt
new file mode 100644
index 0000000..4213600
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt
@@ -0,0 +1,311 @@
+--TEST--
+ReflectionClass::getInterfaces()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class A0 {}
+class B0 extends A0 {}
+abstract class A1 {}
+class B1 extends A1 {}
+
+interface I0 {}
+interface I1 {}
+interface I2 {}
+interface I3 {}
+interface I4 extends I3 {}
+interface I5 extends I4 {}
+interface I6 extends I5, I1, I2 {}
+interface I7 extends I6 {}
+
+class C0 implements I0 {}
+class C1 implements I1, I3 {}
+class C2 extends C1 {}
+class C3 extends C2 implements I1 {}
+class C4 extends C3 implements I2 {}
+class C5 extends C4 implements I7 {}
+class C6 implements I1, I2, I3, I4, I5, I6, I7 {}
+
+
+$classes = array( 'A0', 'A1', 'B0', 'B1',
+ 'I0', 'I1', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7',
+ 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6' );
+
+foreach ($classes as $class) {
+ echo "---( Interfaces implemented by $class )---\n ";
+ $rc = new ReflectionClass($class);
+ $interfaces = $rc->getInterfaces();
+ // Sort interfaces so that tests do not fail because of wrong order.
+ ksort($interfaces);
+ print_r($interfaces);
+}
+
+?>
+--EXPECTF--
+---( Interfaces implemented by A0 )---
+ Array
+(
+)
+---( Interfaces implemented by A1 )---
+ Array
+(
+)
+---( Interfaces implemented by B0 )---
+ Array
+(
+)
+---( Interfaces implemented by B1 )---
+ Array
+(
+)
+---( Interfaces implemented by I0 )---
+ Array
+(
+)
+---( Interfaces implemented by I1 )---
+ Array
+(
+)
+---( Interfaces implemented by I2 )---
+ Array
+(
+)
+---( Interfaces implemented by I3 )---
+ Array
+(
+)
+---( Interfaces implemented by I4 )---
+ Array
+(
+ [I3] => ReflectionClass Object
+ (
+ [name] => I3
+ )
+
+)
+---( Interfaces implemented by I5 )---
+ Array
+(
+ [I3] => ReflectionClass Object
+ (
+ [name] => I3
+ )
+
+ [I4] => ReflectionClass Object
+ (
+ [name] => I4
+ )
+
+)
+---( Interfaces implemented by I6 )---
+ Array
+(
+ [I1] => ReflectionClass Object
+ (
+ [name] => I1
+ )
+
+ [I2] => ReflectionClass Object
+ (
+ [name] => I2
+ )
+
+ [I3] => ReflectionClass Object
+ (
+ [name] => I3
+ )
+
+ [I4] => ReflectionClass Object
+ (
+ [name] => I4
+ )
+
+ [I5] => ReflectionClass Object
+ (
+ [name] => I5
+ )
+
+)
+---( Interfaces implemented by I7 )---
+ Array
+(
+ [I1] => ReflectionClass Object
+ (
+ [name] => I1
+ )
+
+ [I2] => ReflectionClass Object
+ (
+ [name] => I2
+ )
+
+ [I3] => ReflectionClass Object
+ (
+ [name] => I3
+ )
+
+ [I4] => ReflectionClass Object
+ (
+ [name] => I4
+ )
+
+ [I5] => ReflectionClass Object
+ (
+ [name] => I5
+ )
+
+ [I6] => ReflectionClass Object
+ (
+ [name] => I6
+ )
+
+)
+---( Interfaces implemented by C0 )---
+ Array
+(
+ [I0] => ReflectionClass Object
+ (
+ [name] => I0
+ )
+
+)
+---( Interfaces implemented by C1 )---
+ Array
+(
+ [I1] => ReflectionClass Object
+ (
+ [name] => I1
+ )
+
+ [I3] => ReflectionClass Object
+ (
+ [name] => I3
+ )
+
+)
+---( Interfaces implemented by C2 )---
+ Array
+(
+ [I1] => ReflectionClass Object
+ (
+ [name] => I1
+ )
+
+ [I3] => ReflectionClass Object
+ (
+ [name] => I3
+ )
+
+)
+---( Interfaces implemented by C3 )---
+ Array
+(
+ [I1] => ReflectionClass Object
+ (
+ [name] => I1
+ )
+
+ [I3] => ReflectionClass Object
+ (
+ [name] => I3
+ )
+
+)
+---( Interfaces implemented by C4 )---
+ Array
+(
+ [I1] => ReflectionClass Object
+ (
+ [name] => I1
+ )
+
+ [I2] => ReflectionClass Object
+ (
+ [name] => I2
+ )
+
+ [I3] => ReflectionClass Object
+ (
+ [name] => I3
+ )
+
+)
+---( Interfaces implemented by C5 )---
+ Array
+(
+ [I1] => ReflectionClass Object
+ (
+ [name] => I1
+ )
+
+ [I2] => ReflectionClass Object
+ (
+ [name] => I2
+ )
+
+ [I3] => ReflectionClass Object
+ (
+ [name] => I3
+ )
+
+ [I4] => ReflectionClass Object
+ (
+ [name] => I4
+ )
+
+ [I5] => ReflectionClass Object
+ (
+ [name] => I5
+ )
+
+ [I6] => ReflectionClass Object
+ (
+ [name] => I6
+ )
+
+ [I7] => ReflectionClass Object
+ (
+ [name] => I7
+ )
+
+)
+---( Interfaces implemented by C6 )---
+ Array
+(
+ [I1] => ReflectionClass Object
+ (
+ [name] => I1
+ )
+
+ [I2] => ReflectionClass Object
+ (
+ [name] => I2
+ )
+
+ [I3] => ReflectionClass Object
+ (
+ [name] => I3
+ )
+
+ [I4] => ReflectionClass Object
+ (
+ [name] => I4
+ )
+
+ [I5] => ReflectionClass Object
+ (
+ [name] => I5
+ )
+
+ [I6] => ReflectionClass Object
+ (
+ [name] => I6
+ )
+
+ [I7] => ReflectionClass Object
+ (
+ [name] => I7
+ )
+
+)
diff --git a/ext/reflection/tests/ReflectionClass_getInterfaces_002.phpt b/ext/reflection/tests/ReflectionClass_getInterfaces_002.phpt
new file mode 100644
index 0000000..328a7c3
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getInterfaces_002.phpt
@@ -0,0 +1,53 @@
+--TEST--
+ReflectionClass::getInterfaces() - interface ordering.
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+interface I1 {}
+interface I2 {}
+interface I3 {}
+interface I4 extends I3 {}
+interface I5 extends I4 {}
+interface I6 extends I5, I1, I2 {}
+interface I7 extends I6 {}
+
+$rc = new ReflectionClass('I7');
+$interfaces = $rc->getInterfaces();
+print_r($interfaces);
+?>
+--EXPECTF--
+Array
+(
+ [I6] => ReflectionClass Object
+ (
+ [name] => I6
+ )
+
+ [I2] => ReflectionClass Object
+ (
+ [name] => I2
+ )
+
+ [I1] => ReflectionClass Object
+ (
+ [name] => I1
+ )
+
+ [I4] => ReflectionClass Object
+ (
+ [name] => I4
+ )
+
+ [I3] => ReflectionClass Object
+ (
+ [name] => I3
+ )
+
+ [I5] => ReflectionClass Object
+ (
+ [name] => I5
+ )
+
+) \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt b/ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt
new file mode 100644
index 0000000..74044f7
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getInterfaces_003.phpt
@@ -0,0 +1,69 @@
+--TEST--
+ReflectionClass::getInterfaces() - odd ampersand behaviour.
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+
+echo "An object is in an array and is referenced. As expected, var_dumping the array shows '&':\n";
+$a = array(new stdclass);
+$b =& $a[0];
+var_dump($a);
+
+echo "Naturally, this remains true if we modify the object:\n";
+$a[0]->x = 1;
+var_dump($a);
+
+
+echo "\n\nObtain the array of interfaces implemented by C.\n";
+interface I {}
+class C implements I {}
+$rc = new ReflectionClass('C');
+$a = $rc->getInterfaces();
+echo "The result is an array in which each element is an object (an instance of ReflectionClass)\n";
+echo "Var_dumping this array shows that the elements are referenced. By what?\n";
+var_dump($a);
+
+echo "Modify the object, and it is apparently no longer referenced.\n";
+$a['I']->x = 1;
+var_dump($a);
+
+?>
+--EXPECTF--
+An object is in an array and is referenced. As expected, var_dumping the array shows '&':
+array(1) {
+ [0]=>
+ &object(stdClass)#%d (0) {
+ }
+}
+Naturally, this remains true if we modify the object:
+array(1) {
+ [0]=>
+ &object(stdClass)#%d (1) {
+ ["x"]=>
+ int(1)
+ }
+}
+
+
+Obtain the array of interfaces implemented by C.
+The result is an array in which each element is an object (an instance of ReflectionClass)
+Var_dumping this array shows that the elements are referenced. By what?
+array(1) {
+ ["I"]=>
+ &object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(1) "I"
+ }
+}
+Modify the object, and it is apparently no longer referenced.
+array(1) {
+ ["I"]=>
+ object(ReflectionClass)#%d (2) {
+ ["name"]=>
+ string(1) "I"
+ ["x"]=>
+ int(1)
+ }
+} \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_getInterfaces_004.phpt b/ext/reflection/tests/ReflectionClass_getInterfaces_004.phpt
new file mode 100644
index 0000000..f62d58c
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getInterfaces_004.phpt
@@ -0,0 +1,27 @@
+--TEST--
+ReflectionClass::getInterfaces() - wrong param count
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+interface I {}
+class C implements I {}
+$rc = new ReflectionClass('C');
+var_dump($rc->getInterfaces(null));
+var_dump($rc->getInterfaces('X'));
+var_dump($rc->getInterfaces(true));
+var_dump($rc->getInterfaces(array(1,2,3)));
+?>
+--EXPECTF--
+Warning: ReflectionClass::getInterfaces() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getInterfaces() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getInterfaces() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getInterfaces() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
diff --git a/ext/reflection/tests/ReflectionClass_getMethod_001.phpt b/ext/reflection/tests/ReflectionClass_getMethod_001.phpt
new file mode 100644
index 0000000..2f2d790
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getMethod_001.phpt
@@ -0,0 +1,168 @@
+--TEST--
+ReflectionClass::getMethod()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class pubf {
+ public function f() {}
+ static public function s() {}
+}
+class subpubf extends pubf {
+}
+
+class protf {
+ protected function f() {}
+ static protected function s() {}
+}
+class subprotf extends protf {
+}
+
+class privf {
+ private function f() {}
+ static private function s() {}
+}
+class subprivf extends privf {
+}
+
+$classes = array("pubf", "subpubf", "protf", "subprotf",
+ "privf", "subprivf");
+foreach($classes as $class) {
+ echo "Reflecting on class $class: \n";
+ $rc = new ReflectionClass($class);
+ echo " --> Check for f(): ";
+ var_dump($rc->getMethod("f"));
+ echo " --> Check for s(): ";
+ var_dump($rc->getMethod("s"));
+ echo " --> Check for F(): ";
+ var_dump($rc->getMethod("F"));
+ echo " --> Check for doesntExist(): ";
+ try {
+ var_dump($rc->getMethod("doesntExist"));
+ } catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+ }
+}
+?>
+--EXPECTF--
+Reflecting on class pubf:
+ --> Check for f(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+}
+ --> Check for s(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+}
+ --> Check for F(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+}
+ --> Check for doesntExist(): Method doesntExist does not exist
+Reflecting on class subpubf:
+ --> Check for f(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+}
+ --> Check for s(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+}
+ --> Check for F(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+}
+ --> Check for doesntExist(): Method doesntExist does not exist
+Reflecting on class protf:
+ --> Check for f(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+}
+ --> Check for s(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+}
+ --> Check for F(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+}
+ --> Check for doesntExist(): Method doesntExist does not exist
+Reflecting on class subprotf:
+ --> Check for f(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+}
+ --> Check for s(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+}
+ --> Check for F(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+}
+ --> Check for doesntExist(): Method doesntExist does not exist
+Reflecting on class privf:
+ --> Check for f(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+}
+ --> Check for s(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+}
+ --> Check for F(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+}
+ --> Check for doesntExist(): Method doesntExist does not exist
+Reflecting on class subprivf:
+ --> Check for f(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+}
+ --> Check for s(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+}
+ --> Check for F(): object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+}
+ --> Check for doesntExist(): Method doesntExist does not exist
diff --git a/ext/reflection/tests/ReflectionClass_getMethod_002.phpt b/ext/reflection/tests/ReflectionClass_getMethod_002.phpt
new file mode 100644
index 0000000..2baabde
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getMethod_002.phpt
@@ -0,0 +1,74 @@
+--TEST--
+ReflectionClass::getMethod() - error cases
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {
+ function f() {}
+}
+
+$rc = new ReflectionClass("C");
+echo "Check invalid params:\n";
+try {
+ var_dump($rc->getMethod());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getMethod("f", "f"));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getMethod(null));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getMethod(1));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getMethod(1.5));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getMethod(true));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getMethod(array(1,2,3)));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getMethod(new C));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+
+?>
+--EXPECTF--
+Check invalid params:
+
+Warning: ReflectionClass::getMethod() expects exactly 1 parameter, 0 given in %s on line 9
+NULL
+
+Warning: ReflectionClass::getMethod() expects exactly 1 parameter, 2 given in %s on line 14
+NULL
+Method does not exist
+Method 1 does not exist
+Method 1.5 does not exist
+Method 1 does not exist
+
+Warning: ReflectionClass::getMethod() expects parameter 1 to be string, array given in %s on line 39
+NULL
+
+Warning: ReflectionClass::getMethod() expects parameter 1 to be string, object given in %s on line 44
+NULL \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_getMethods_001.phpt b/ext/reflection/tests/ReflectionClass_getMethods_001.phpt
new file mode 100644
index 0000000..ce5c980
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getMethods_001.phpt
@@ -0,0 +1,140 @@
+--TEST--
+ReflectionClass::getMethods()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class pubf {
+ public function f() {}
+ static public function s() {}
+}
+class subpubf extends pubf {
+}
+
+class protf {
+ protected function f() {}
+ static protected function s() {}
+}
+class subprotf extends protf {
+}
+
+class privf {
+ private function f() {}
+ static private function s() {}
+}
+class subprivf extends privf {
+}
+
+$classes = array("pubf", "subpubf", "protf", "subprotf",
+ "privf", "subprivf");
+foreach($classes as $class) {
+ echo "Reflecting on class $class: \n";
+ $rc = new ReflectionClass($class);
+ var_dump($rc->getMethods());
+}
+
+?>
+--EXPECTF--
+Reflecting on class pubf:
+array(2) {
+ [0]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+ }
+ [1]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+ }
+}
+Reflecting on class subpubf:
+array(2) {
+ [0]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+ }
+ [1]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+ }
+}
+Reflecting on class protf:
+array(2) {
+ [0]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+ }
+ [1]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+ }
+}
+Reflecting on class subprotf:
+array(2) {
+ [0]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+ }
+ [1]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+ }
+}
+Reflecting on class privf:
+array(2) {
+ [0]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+ }
+ [1]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+ }
+}
+Reflecting on class subprivf:
+array(2) {
+ [0]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "f"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+ }
+ [1]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+ }
+}
diff --git a/ext/reflection/tests/ReflectionClass_getMethods_002.phpt b/ext/reflection/tests/ReflectionClass_getMethods_002.phpt
new file mode 100644
index 0000000..b252225
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getMethods_002.phpt
@@ -0,0 +1,18 @@
+--TEST--
+ReflectionClass::getMethods() - invalid arguments
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+$rc = new ReflectionClass("ReflectionClass");
+echo "\nTest invalid arguments:";
+$rc->getMethods('X');
+$rc->getMethods('X', true);
+
+?>
+--EXPECTF--
+Test invalid arguments:
+Warning: ReflectionClass::getMethods() expects parameter 1 to be long, string given in %s on line 4
+
+Warning: ReflectionClass::getMethods() expects at most 1 parameter, 2 given in %s on line 5
diff --git a/ext/reflection/tests/ReflectionClass_getMethods_003.phpt b/ext/reflection/tests/ReflectionClass_getMethods_003.phpt
new file mode 100644
index 0000000..435f5d2
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getMethods_003.phpt
@@ -0,0 +1,191 @@
+--TEST--
+ReflectionClass::getMethods()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {
+ public function pubf1() {}
+ public function pubf2() {}
+ private function privf1() {}
+ private function privf2() {}
+ static public function pubsf1() {}
+ static public function pubsf2() {}
+ static private function privsf1() {}
+ static private function privsf2() {}
+}
+
+$rc = new ReflectionClass("C");
+$StaticFlag = 0x01;
+$pubFlag = 0x100;
+$privFlag = 0x400;
+
+echo "No methods:";
+var_dump($rc->getMethods(0));
+
+echo "Public methods:";
+var_dump($rc->getMethods($pubFlag));
+
+echo "Private methods:";
+var_dump($rc->getMethods($privFlag));
+
+echo "Public or static methods:";
+var_dump($rc->getMethods($StaticFlag | $pubFlag));
+
+echo "Private or static methods:";
+var_dump($rc->getMethods($StaticFlag | $privFlag));
+
+
+?>
+--EXPECTF--
+No methods:array(0) {
+}
+Public methods:array(4) {
+ [0]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(5) "pubf1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [1]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(5) "pubf2"
+ ["class"]=>
+ string(1) "C"
+ }
+ [2]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(6) "pubsf1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [3]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(6) "pubsf2"
+ ["class"]=>
+ string(1) "C"
+ }
+}
+Private methods:array(4) {
+ [0]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(6) "privf1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [1]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(6) "privf2"
+ ["class"]=>
+ string(1) "C"
+ }
+ [2]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(7) "privsf1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [3]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(7) "privsf2"
+ ["class"]=>
+ string(1) "C"
+ }
+}
+Public or static methods:array(6) {
+ [0]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(5) "pubf1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [1]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(5) "pubf2"
+ ["class"]=>
+ string(1) "C"
+ }
+ [2]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(6) "pubsf1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [3]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(6) "pubsf2"
+ ["class"]=>
+ string(1) "C"
+ }
+ [4]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(7) "privsf1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [5]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(7) "privsf2"
+ ["class"]=>
+ string(1) "C"
+ }
+}
+Private or static methods:array(6) {
+ [0]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(6) "privf1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [1]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(6) "privf2"
+ ["class"]=>
+ string(1) "C"
+ }
+ [2]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(6) "pubsf1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [3]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(6) "pubsf2"
+ ["class"]=>
+ string(1) "C"
+ }
+ [4]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(7) "privsf1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [5]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(7) "privsf2"
+ ["class"]=>
+ string(1) "C"
+ }
+}
diff --git a/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt b/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt
new file mode 100644
index 0000000..91a0a18
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt
@@ -0,0 +1,139 @@
+--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--
+string(1) "a"
+array(0) {
+}
+string(1) "b"
+array(1) {
+ [0]=>
+ string(8) "abstract"
+}
+string(1) "c"
+array(1) {
+ [0]=>
+ string(5) "final"
+}
+string(14) "x::__construct"
+array(1) {
+ [0]=>
+ string(6) "public"
+}
+string(13) "x::__destruct"
+array(1) {
+ [0]=>
+ string(6) "public"
+}
+string(4) "x::a"
+array(1) {
+ [0]=>
+ string(7) "private"
+}
+string(4) "x::b"
+array(2) {
+ [0]=>
+ string(7) "private"
+ [1]=>
+ string(6) "static"
+}
+string(4) "x::c"
+array(1) {
+ [0]=>
+ string(9) "protected"
+}
+string(4) "x::d"
+array(2) {
+ [0]=>
+ string(9) "protected"
+ [1]=>
+ string(6) "static"
+}
+string(4) "x::e"
+array(1) {
+ [0]=>
+ string(6) "public"
+}
+string(4) "x::f"
+array(2) {
+ [0]=>
+ string(6) "public"
+ [1]=>
+ string(6) "static"
+}
+string(4) "x::g"
+array(2) {
+ [0]=>
+ string(5) "final"
+ [1]=>
+ string(6) "public"
+}
+string(4) "x::h"
+array(1) {
+ [0]=>
+ string(6) "public"
+}
+string(4) "y::a"
+array(2) {
+ [0]=>
+ string(8) "abstract"
+ [1]=>
+ string(6) "public"
+}
+string(4) "y::b"
+array(2) {
+ [0]=>
+ string(8) "abstract"
+ [1]=>
+ string(9) "protected"
+}
+==DONE==
diff --git a/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt
new file mode 100644
index 0000000..65f23c9
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt
@@ -0,0 +1,37 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_getName_basic.phpt b/ext/reflection/tests/ReflectionClass_getName_basic.phpt
new file mode 100644
index 0000000..158413f
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getName_basic.phpt
@@ -0,0 +1,25 @@
+--TEST--
+ReflectionClass::getName()
+--FILE--
+<?php
+class TrickClass {
+ function __toString() {
+ //Return the name of another class
+ return "Exception";
+ }
+}
+
+$r1 = new ReflectionClass("stdClass");
+
+$myInstance = new stdClass;
+$r2 = new ReflectionClass($myInstance);
+
+$r3 = new ReflectionClass("TrickClass");
+
+var_dump($r1->getName(), $r2->getName(), $r3->getName());
+
+?>
+--EXPECTF--
+string(8) "stdClass"
+string(8) "stdClass"
+string(10) "TrickClass"
diff --git a/ext/reflection/tests/ReflectionClass_getName_error.phpt b/ext/reflection/tests/ReflectionClass_getName_error.phpt
new file mode 100644
index 0000000..06cc415
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getName_error.phpt
@@ -0,0 +1,16 @@
+--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
diff --git a/ext/reflection/tests/ReflectionClass_getName_error1.phpt b/ext/reflection/tests/ReflectionClass_getName_error1.phpt
new file mode 100644
index 0000000..5590137
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getName_error1.phpt
@@ -0,0 +1,8 @@
+--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
diff --git a/ext/reflection/tests/ReflectionClass_getNamespaceName.phpt b/ext/reflection/tests/ReflectionClass_getNamespaceName.phpt
new file mode 100644
index 0000000..1c46e06
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getNamespaceName.phpt
@@ -0,0 +1,30 @@
+--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)
+string(8) "stdClass"
+string(0) ""
+string(8) "stdClass"
+bool(true)
+string(7) "A\B\Foo"
+string(3) "A\B"
+string(3) "Foo"
+
diff --git a/ext/reflection/tests/ReflectionClass_getParentClass.phpt b/ext/reflection/tests/ReflectionClass_getParentClass.phpt
new file mode 100644
index 0000000..46884ca
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getParentClass.phpt
@@ -0,0 +1,21 @@
+--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) {
+ ["name"]=>
+ string(3) "Foo"
+}
diff --git a/ext/reflection/tests/ReflectionClass_getParentClass_001.phpt b/ext/reflection/tests/ReflectionClass_getParentClass_001.phpt
new file mode 100644
index 0000000..be50dbb
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getParentClass_001.phpt
@@ -0,0 +1,38 @@
+--TEST--
+ReflectionClass::getParentClass()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class A {}
+class B extends A {}
+
+$rc = new ReflectionClass('B');
+$parent = $rc->getParentClass();
+$grandParent = $parent->getParentClass();
+var_dump($parent, $grandParent);
+
+echo "\nTest bad params:\n";
+var_dump($rc->getParentClass(null));
+var_dump($rc->getParentClass('x'));
+var_dump($rc->getParentClass('x', 123));
+
+?>
+--EXPECTF--
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(1) "A"
+}
+bool(false)
+
+Test bad params:
+
+Warning: ReflectionClass::getParentClass() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getParentClass() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getParentClass() expects exactly 0 parameters, 2 given in %s on line %d
+NULL
diff --git a/ext/reflection/tests/ReflectionClass_getProperties_001.phpt b/ext/reflection/tests/ReflectionClass_getProperties_001.phpt
new file mode 100644
index 0000000..b4f99ca
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getProperties_001.phpt
@@ -0,0 +1,126 @@
+--TEST--
+ReflectionClass::getProperties()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class pubf {
+ public $a;
+ static public $s;
+}
+class subpubf extends pubf {
+}
+
+class protf {
+ protected $a;
+ static protected $s;
+}
+class subprotf extends protf {
+}
+
+class privf {
+ private $a;
+ static private $s;
+}
+class subprivf extends privf {
+}
+
+$classes = array("pubf", "subpubf", "protf", "subprotf",
+ "privf", "subprivf");
+foreach($classes as $class) {
+ echo "Reflecting on class $class: \n";
+ $rc = new ReflectionClass($class);
+ var_dump($rc->getProperties());
+}
+
+?>
+--EXPECTF--
+Reflecting on class pubf:
+array(2) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "a"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+ }
+ [1]=>
+ &object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+ }
+}
+Reflecting on class subpubf:
+array(2) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "a"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+ }
+ [1]=>
+ &object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+ }
+}
+Reflecting on class protf:
+array(2) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "a"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+ }
+ [1]=>
+ &object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+ }
+}
+Reflecting on class subprotf:
+array(2) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "a"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+ }
+ [1]=>
+ &object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+ }
+}
+Reflecting on class privf:
+array(2) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "a"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+ }
+ [1]=>
+ &object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+ }
+}
+Reflecting on class subprivf:
+array(0) {
+}
diff --git a/ext/reflection/tests/ReflectionClass_getProperties_002.phpt b/ext/reflection/tests/ReflectionClass_getProperties_002.phpt
new file mode 100644
index 0000000..c21cff2
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getProperties_002.phpt
@@ -0,0 +1,17 @@
+--TEST--
+ReflectionClass::getProperties() - invalid arguments
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+$rc = new ReflectionClass("ReflectionClass");
+echo "\nTest invalid arguments:";
+$rc->getProperties('X');
+$rc->getProperties('X', true);
+?>
+--EXPECTF--
+Test invalid arguments:
+Warning: ReflectionClass::getProperties() expects parameter 1 to be long, string given in %s on line 4
+
+Warning: ReflectionClass::getProperties() expects at most 1 parameter, 2 given in %s on line 5
diff --git a/ext/reflection/tests/ReflectionClass_getProperties_003.phpt b/ext/reflection/tests/ReflectionClass_getProperties_003.phpt
new file mode 100644
index 0000000..b4f9a77
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getProperties_003.phpt
@@ -0,0 +1,189 @@
+--TEST--
+ReflectionClass::getProperties()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {
+ public $pub1;
+ public $pub2;
+ private $priv1;
+ private $priv2;
+ static public $pubs;
+ static public $pubs2;
+ static private $privs1;
+ static private $privs2;
+}
+
+$rc = new ReflectionClass("C");
+$StaticFlag = 0x01;
+$pubFlag = 0x100;
+$privFlag = 0x400;
+
+echo "No properties:";
+var_dump($rc->getProperties(0));
+
+echo "Public properties:";
+var_dump($rc->getProperties($pubFlag));
+
+echo "Private properties:";
+var_dump($rc->getProperties($privFlag));
+
+echo "Public or static properties:";
+var_dump($rc->getProperties($StaticFlag | $pubFlag));
+
+echo "Private or static properties:";
+var_dump($rc->getProperties($StaticFlag | $privFlag));
+?>
+--EXPECTF--
+No properties:array(0) {
+}
+Public properties:array(4) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(4) "pub1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [1]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(4) "pub2"
+ ["class"]=>
+ string(1) "C"
+ }
+ [2]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(4) "pubs"
+ ["class"]=>
+ string(1) "C"
+ }
+ [3]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "pubs2"
+ ["class"]=>
+ string(1) "C"
+ }
+}
+Private properties:array(4) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "priv1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [1]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "priv2"
+ ["class"]=>
+ string(1) "C"
+ }
+ [2]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(6) "privs1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [3]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(6) "privs2"
+ ["class"]=>
+ string(1) "C"
+ }
+}
+Public or static properties:array(6) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(4) "pub1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [1]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(4) "pub2"
+ ["class"]=>
+ string(1) "C"
+ }
+ [2]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(4) "pubs"
+ ["class"]=>
+ string(1) "C"
+ }
+ [3]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "pubs2"
+ ["class"]=>
+ string(1) "C"
+ }
+ [4]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(6) "privs1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [5]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(6) "privs2"
+ ["class"]=>
+ string(1) "C"
+ }
+}
+Private or static properties:array(6) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "priv1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [1]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "priv2"
+ ["class"]=>
+ string(1) "C"
+ }
+ [2]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(4) "pubs"
+ ["class"]=>
+ string(1) "C"
+ }
+ [3]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "pubs2"
+ ["class"]=>
+ string(1) "C"
+ }
+ [4]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(6) "privs1"
+ ["class"]=>
+ string(1) "C"
+ }
+ [5]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(6) "privs2"
+ ["class"]=>
+ string(1) "C"
+ }
+} \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_getProperty_001.phpt b/ext/reflection/tests/ReflectionClass_getProperty_001.phpt
new file mode 100644
index 0000000..9e174b7
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getProperty_001.phpt
@@ -0,0 +1,146 @@
+--TEST--
+ReflectionClass::getProperty()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class pubf {
+ public $a;
+ static public $s;
+}
+class subpubf extends pubf {
+}
+
+class protf {
+ protected $a;
+ static protected $s;
+}
+class subprotf extends protf {
+}
+
+class privf {
+ private $a;
+ static protected $s;
+}
+class subprivf extends privf {
+}
+
+$classes = array("pubf", "subpubf", "protf", "subprotf",
+ "privf", "subprivf");
+foreach($classes as $class) {
+ echo "Reflecting on class $class: \n";
+ $rc = new ReflectionClass($class);
+ try {
+ echo " --> Check for s: ";
+ var_dump($rc->getProperty("s"));
+ } catch (exception $e) {
+ echo $e->getMessage() . "\n";
+ }
+ try {
+ echo " --> Check for a: ";
+ var_dump($rc->getProperty("a"));
+ } catch (exception $e) {
+ echo $e->getMessage() . "\n";
+ }
+ try {
+ echo " --> Check for A: ";
+ var_dump($rc->getProperty("A"));
+ } catch (exception $e) {
+ echo $e->getMessage() . "\n";
+ }
+ try {
+ echo " --> Check for doesntExist: ";
+ var_dump($rc->getProperty("doesntExist"));
+ } catch (exception $e) {
+ echo $e->getMessage() . "\n";
+ }
+
+}
+?>
+--EXPECTF--
+Reflecting on class pubf:
+ --> Check for s: object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+}
+ --> Check for a: object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "a"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+}
+ --> Check for A: Property A does not exist
+ --> Check for doesntExist: Property doesntExist does not exist
+Reflecting on class subpubf:
+ --> Check for s: object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+}
+ --> Check for a: object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "a"
+ [%u|b%"class"]=>
+ %unicode|string%(4) "pubf"
+}
+ --> Check for A: Property A does not exist
+ --> Check for doesntExist: Property doesntExist does not exist
+Reflecting on class protf:
+ --> Check for s: object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+}
+ --> Check for a: object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "a"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+}
+ --> Check for A: Property A does not exist
+ --> Check for doesntExist: Property doesntExist does not exist
+Reflecting on class subprotf:
+ --> Check for s: object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+}
+ --> Check for a: object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "a"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "protf"
+}
+ --> Check for A: Property A does not exist
+ --> Check for doesntExist: Property doesntExist does not exist
+Reflecting on class privf:
+ --> Check for s: object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+}
+ --> Check for a: object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "a"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+}
+ --> Check for A: Property A does not exist
+ --> Check for doesntExist: Property doesntExist does not exist
+Reflecting on class subprivf:
+ --> Check for s: object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(1) "s"
+ [%u|b%"class"]=>
+ %unicode|string%(5) "privf"
+}
+ --> Check for a: Property a does not exist
+ --> Check for A: Property A does not exist
+ --> Check for doesntExist: Property doesntExist does not exist
diff --git a/ext/reflection/tests/ReflectionClass_getProperty_002.phpt b/ext/reflection/tests/ReflectionClass_getProperty_002.phpt
new file mode 100644
index 0000000..be7bb53
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getProperty_002.phpt
@@ -0,0 +1,72 @@
+--TEST--
+ReflectionClass::getProperty() - error cases
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {
+ public $a;
+}
+
+$rc = new ReflectionClass("C");
+echo "Check invalid params:\n";
+try {
+ var_dump($rc->getProperty());
+} catch (exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getProperty("a", "a"));
+} catch (exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getProperty(null));
+} catch (exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getProperty(1));
+} catch (exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getProperty(1.5));
+} catch (exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getProperty(true));
+} catch (exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getProperty(array(1,2,3)));
+} catch (exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getProperty(new C));
+} catch (exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+--EXPECTF--
+Check invalid params:
+
+Warning: ReflectionClass::getProperty() expects exactly 1 parameter, 0 given in %s on line 9
+NULL
+
+Warning: ReflectionClass::getProperty() expects exactly 1 parameter, 2 given in %s on line 14
+NULL
+Property does not exist
+Property 1 does not exist
+Property 1.5 does not exist
+Property 1 does not exist
+
+Warning: ReflectionClass::getProperty() expects parameter 1 to be string, array given in %s on line 39
+NULL
+
+Warning: ReflectionClass::getProperty() expects parameter 1 to be string, object given in %s on line 44
+NULL \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_getProperty_003.phpt b/ext/reflection/tests/ReflectionClass_getProperty_003.phpt
new file mode 100644
index 0000000..515d986
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getProperty_003.phpt
@@ -0,0 +1,251 @@
+--TEST--
+ReflectionClass::getProperty()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class A {
+ static public $pubC = "pubC in A";
+ static protected $protC = "protC in A";
+ static private $privC = "privC in A";
+
+ static public $pubA = "pubA in A";
+ static protected $protA = "protA in A";
+ static private $privA = "privA in A";
+}
+
+class B extends A {
+ static public $pubC = "pubC in B";
+ static protected $protC = "protC in B";
+ static private $privC = "privC in B";
+
+ static public $pubB = "pubB in B";
+ static protected $protB = "protB in B";
+ static private $privB = "privB in B";
+}
+
+class C extends B {
+ static public $pubC = "pubC in C";
+ static protected $protC = "protC in C";
+ static private $privC = "privC in C";
+}
+
+class X {
+ static public $pubC = "pubC in X";
+ static protected $protC = "protC in X";
+ static private $privC = "privC in X";
+}
+
+$myC = new C;
+$rc = new ReflectionClass("C");
+
+function showInfo($name) {
+ global $rc, $myC;
+ echo "--- (Reflecting on $name) ---\n";
+ try {
+ $rp = $rc->getProperty($name);
+ } catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+ return;
+ }
+ try {
+ var_dump($rp);
+ var_dump($rp->getValue($myC));
+ } catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+ return;
+ }
+}
+
+
+showInfo("pubA");
+showInfo("protA");
+showInfo("privA");
+
+showInfo("pubB");
+showInfo("protB");
+showInfo("privB");
+
+showInfo("pubC");
+showInfo("protC");
+showInfo("privC");
+showInfo("doesntExist");
+
+showInfo("A::pubC");
+showInfo("A::protC");
+showInfo("A::privC");
+
+showInfo("B::pubC");
+showInfo("B::protC");
+showInfo("B::privC");
+
+showInfo("c::pubC");
+showInfo("c::PUBC");
+showInfo("C::pubC");
+showInfo("C::protC");
+showInfo("C::privC");
+
+showInfo("X::pubC");
+showInfo("X::protC");
+showInfo("X::privC");
+showInfo("X::doesntExist");
+
+showInfo("doesntexist::doesntExist");
+
+?>
+--EXPECTF--
+--- (Reflecting on pubA) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubA"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "A"
+}
+%unicode|string%(9) "pubA in A"
+--- (Reflecting on protA) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "protA"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "A"
+}
+Cannot access non-public member C::protA
+--- (Reflecting on privA) ---
+Property privA does not exist
+--- (Reflecting on pubB) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubB"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "B"
+}
+%unicode|string%(9) "pubB in B"
+--- (Reflecting on protB) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "protB"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "B"
+}
+Cannot access non-public member C::protB
+--- (Reflecting on privB) ---
+Property privB does not exist
+--- (Reflecting on pubC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+%unicode|string%(9) "pubC in C"
+--- (Reflecting on protC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "protC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+Cannot access non-public member C::protC
+--- (Reflecting on privC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "privC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+Cannot access non-public member C::privC
+--- (Reflecting on doesntExist) ---
+Property doesntExist does not exist
+--- (Reflecting on A::pubC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "A"
+}
+%unicode|string%(9) "pubC in A"
+--- (Reflecting on A::protC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "protC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "A"
+}
+Cannot access non-public member A::protC
+--- (Reflecting on A::privC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "privC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "A"
+}
+Cannot access non-public member A::privC
+--- (Reflecting on B::pubC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "B"
+}
+%unicode|string%(9) "pubC in B"
+--- (Reflecting on B::protC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "protC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "B"
+}
+Cannot access non-public member B::protC
+--- (Reflecting on B::privC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "privC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "B"
+}
+Cannot access non-public member B::privC
+--- (Reflecting on c::pubC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+%unicode|string%(9) "pubC in C"
+--- (Reflecting on c::PUBC) ---
+Property PUBC does not exist
+--- (Reflecting on C::pubC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+%unicode|string%(9) "pubC in C"
+--- (Reflecting on C::protC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "protC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+Cannot access non-public member C::protC
+--- (Reflecting on C::privC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "privC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+Cannot access non-public member C::privC
+--- (Reflecting on X::pubC) ---
+Fully qualified property name X::pubC does not specify a base class of C
+--- (Reflecting on X::protC) ---
+Fully qualified property name X::protC does not specify a base class of C
+--- (Reflecting on X::privC) ---
+Fully qualified property name X::privC does not specify a base class of C
+--- (Reflecting on X::doesntExist) ---
+Fully qualified property name X::doesntExist does not specify a base class of C
+--- (Reflecting on doesntexist::doesntExist) ---
+Class doesntexist does not exist
diff --git a/ext/reflection/tests/ReflectionClass_getProperty_004.phpt b/ext/reflection/tests/ReflectionClass_getProperty_004.phpt
new file mode 100644
index 0000000..1070d57
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getProperty_004.phpt
@@ -0,0 +1,251 @@
+--TEST--
+ReflectionClass::getProperty()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class A {
+ public $pubC = "pubC in A";
+ protected $protC = "protC in A";
+ private $privC = "privC in A";
+
+ public $pubA = "pubA in A";
+ protected $protA = "protA in A";
+ private $privA = "privA in A";
+}
+
+class B extends A {
+ public $pubC = "pubC in B";
+ protected $protC = "protC in B";
+ private $privC = "privC in B";
+
+ public $pubB = "pubB in B";
+ protected $protB = "protB in B";
+ private $privB = "privB in B";
+}
+
+class C extends B {
+ public $pubC = "pubC in C";
+ protected $protC = "protC in C";
+ private $privC = "privC in C";
+}
+
+class X {
+ public $pubC = "pubC in X";
+ protected $protC = "protC in X";
+ private $privC = "privC in X";
+}
+
+$myC = new C;
+$rc = new ReflectionClass("C");
+
+function showInfo($name) {
+ global $rc, $myC;
+ echo "--- (Reflecting on $name) ---\n";
+ try {
+ $rp = $rc->getProperty($name);
+ } catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+ return;
+ }
+ try {
+ var_dump($rp);
+ var_dump($rp->getValue($myC));
+ } catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+ return;
+ }
+}
+
+
+showInfo("pubA");
+showInfo("protA");
+showInfo("privA");
+
+showInfo("pubB");
+showInfo("protB");
+showInfo("privB");
+
+showInfo("pubC");
+showInfo("protC");
+showInfo("privC");
+showInfo("doesntExist");
+
+showInfo("A::pubC");
+showInfo("A::protC");
+showInfo("A::privC");
+
+showInfo("B::pubC");
+showInfo("B::protC");
+showInfo("B::privC");
+
+showInfo("c::pubC");
+showInfo("c::PUBC");
+showInfo("C::pubC");
+showInfo("C::protC");
+showInfo("C::privC");
+
+showInfo("X::pubC");
+showInfo("X::protC");
+showInfo("X::privC");
+showInfo("X::doesntExist");
+
+showInfo("doesntexist::doesntExist");
+
+?>
+--EXPECTF--
+--- (Reflecting on pubA) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubA"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "A"
+}
+%unicode|string%(9) "pubA in A"
+--- (Reflecting on protA) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "protA"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "A"
+}
+Cannot access non-public member C::protA
+--- (Reflecting on privA) ---
+Property privA does not exist
+--- (Reflecting on pubB) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubB"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "B"
+}
+%unicode|string%(9) "pubB in B"
+--- (Reflecting on protB) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "protB"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "B"
+}
+Cannot access non-public member C::protB
+--- (Reflecting on privB) ---
+Property privB does not exist
+--- (Reflecting on pubC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+%unicode|string%(9) "pubC in C"
+--- (Reflecting on protC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "protC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+Cannot access non-public member C::protC
+--- (Reflecting on privC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "privC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+Cannot access non-public member C::privC
+--- (Reflecting on doesntExist) ---
+Property doesntExist does not exist
+--- (Reflecting on A::pubC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "A"
+}
+%unicode|string%(9) "pubC in C"
+--- (Reflecting on A::protC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "protC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "A"
+}
+Cannot access non-public member A::protC
+--- (Reflecting on A::privC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "privC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "A"
+}
+Cannot access non-public member A::privC
+--- (Reflecting on B::pubC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "B"
+}
+%unicode|string%(9) "pubC in C"
+--- (Reflecting on B::protC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "protC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "B"
+}
+Cannot access non-public member B::protC
+--- (Reflecting on B::privC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "privC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "B"
+}
+Cannot access non-public member B::privC
+--- (Reflecting on c::pubC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+%unicode|string%(9) "pubC in C"
+--- (Reflecting on c::PUBC) ---
+Property PUBC does not exist
+--- (Reflecting on C::pubC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(4) "pubC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+%unicode|string%(9) "pubC in C"
+--- (Reflecting on C::protC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "protC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+Cannot access non-public member C::protC
+--- (Reflecting on C::privC) ---
+object(ReflectionProperty)#%d (2) {
+ [%u|b%"name"]=>
+ %unicode|string%(5) "privC"
+ [%u|b%"class"]=>
+ %unicode|string%(1) "C"
+}
+Cannot access non-public member C::privC
+--- (Reflecting on X::pubC) ---
+Fully qualified property name X::pubC does not specify a base class of C
+--- (Reflecting on X::protC) ---
+Fully qualified property name X::protC does not specify a base class of C
+--- (Reflecting on X::privC) ---
+Fully qualified property name X::privC does not specify a base class of C
+--- (Reflecting on X::doesntExist) ---
+Fully qualified property name X::doesntExist does not specify a base class of C
+--- (Reflecting on doesntexist::doesntExist) ---
+Class doesntexist does not exist
diff --git a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt
new file mode 100644
index 0000000..ffd81ff
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt
@@ -0,0 +1,69 @@
+--TEST--
+ReflectionClass::getStaticPropertyValue()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--SKIPIF--
+<?php if (version_compare(zend_version(), '2.4.0', '>=')) die('skip ZendEngine 2.3 or below needed'); ?>
+--FILE--
+<?php
+class A {
+ static private $privateOverridden = "original private";
+ static protected $protectedOverridden = "original protected";
+ static public $publicOverridden = "original public";
+}
+
+class B extends A {
+ static private $privateOverridden = "changed private";
+ static protected $protectedOverridden = "changed protected";
+ static public $publicOverridden = "changed public";
+}
+
+echo "Retrieving static values from A:\n";
+$rcA = new ReflectionClass('A');
+var_dump($rcA->getStaticPropertyValue("privateOverridden", "default value"));
+var_dump($rcA->getStaticPropertyValue("\0A\0privateOverridden"));
+var_dump($rcA->getStaticPropertyValue("protectedOverridden", "default value"));
+var_dump($rcA->getStaticPropertyValue("\0*\0protectedOverridden"));
+var_dump($rcA->getStaticPropertyValue("publicOverridden"));
+
+echo "\nRetrieving static values from B:\n";
+$rcB = new ReflectionClass('B');
+var_dump($rcB->getStaticPropertyValue("\0A\0privateOverridden"));
+var_dump($rcB->getStaticPropertyValue("\0B\0privateOverridden"));
+var_dump($rcB->getStaticPropertyValue("\0*\0protectedOverridden"));
+var_dump($rcB->getStaticPropertyValue("publicOverridden"));
+
+echo "\nRetrieving non-existent values from A with no default value:\n";
+try {
+ var_dump($rcA->getStaticPropertyValue("protectedOverridden"));
+ echo "you should not see this";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ var_dump($rcA->getStaticPropertyValue("privateOverridden"));
+ echo "you should not see this";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+--EXPECTF--
+Retrieving static values from A:
+string(13) "default value"
+string(16) "original private"
+string(13) "default value"
+string(18) "original protected"
+string(15) "original public"
+
+Retrieving static values from B:
+string(16) "original private"
+string(15) "changed private"
+string(17) "changed protected"
+string(14) "changed public"
+
+Retrieving non-existent values from A with no default value:
+Class A does not have a property named protectedOverridden
+Class A does not have a property named privateOverridden
diff --git a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001_2_4.phpt b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001_2_4.phpt
new file mode 100644
index 0000000..c299412
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001_2_4.phpt
@@ -0,0 +1,61 @@
+--TEST--
+ReflectionClass::getStaticPropertyValue()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--SKIPIF--
+<?php if (version_compare(zend_version(), '2.4.0', '<')) die('skip ZendEngine 2.4 needed'); ?>
+--FILE--
+<?php
+class A {
+ static private $privateOverridden = "original private";
+ static protected $protectedOverridden = "original protected";
+ static public $publicOverridden = "original public";
+}
+
+class B extends A {
+ static private $privateOverridden = "changed private";
+ static protected $protectedOverridden = "changed protected";
+ static public $publicOverridden = "changed public";
+}
+
+echo "Retrieving static values from A:\n";
+$rcA = new ReflectionClass('A');
+var_dump($rcA->getStaticPropertyValue("privateOverridden", "default value"));
+var_dump($rcA->getStaticPropertyValue("\0A\0privateOverridden"));
+var_dump($rcA->getStaticPropertyValue("protectedOverridden", "default value"));
+var_dump($rcA->getStaticPropertyValue("\0*\0protectedOverridden"));
+var_dump($rcA->getStaticPropertyValue("publicOverridden"));
+
+echo "\nRetrieving static values from B:\n";
+$rcB = new ReflectionClass('B');
+var_dump($rcB->getStaticPropertyValue("\0A\0privateOverridden"));
+var_dump($rcB->getStaticPropertyValue("\0B\0privateOverridden"));
+var_dump($rcB->getStaticPropertyValue("\0*\0protectedOverridden"));
+var_dump($rcB->getStaticPropertyValue("publicOverridden"));
+
+echo "\nRetrieving non-existent values from A with no default value:\n";
+try {
+ var_dump($rcA->getStaticPropertyValue("protectedOverridden"));
+ echo "you should not see this";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ var_dump($rcA->getStaticPropertyValue("privateOverridden"));
+ echo "you should not see this";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+--EXPECTF--
+Retrieving static values from A:
+string(13) "default value"
+
+Fatal error: Uncaught exception 'ReflectionException' with message 'Class A does not have a property named ' in %sReflectionClass_getStaticPropertyValue_001_2_4.php:%d
+Stack trace:
+#0 %sReflectionClass_getStaticPropertyValue_001_2_4.php(%d): ReflectionClass->getStaticPropertyValue('?A?privateOverr...')
+#1 {main}
+ thrown in %sReflectionClass_getStaticPropertyValue_001_2_4.php on line %d
diff --git a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt
new file mode 100644
index 0000000..36b4744
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt
@@ -0,0 +1,52 @@
+--TEST--
+ReflectionClass::getStaticPropertyValue() - bad params
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {
+ public static $x;
+}
+
+$rc = new ReflectionClass('C');
+try {
+ var_dump($rc->getStaticPropertyValue("x", "default value", 'blah'));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getStaticPropertyValue());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getStaticPropertyValue(null));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getStaticPropertyValue(1.5, 'def'));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->getStaticPropertyValue(array(1,2,3)));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+
+?>
+--EXPECTF--
+
+Warning: ReflectionClass::getStaticPropertyValue() expects at most 2 parameters, 3 given in %s on line 8
+NULL
+
+Warning: ReflectionClass::getStaticPropertyValue() expects at least 1 parameter, 0 given in %s on line 13
+NULL
+Class C does not have a property named
+string(3) "def"
+
+Warning: ReflectionClass::getStaticPropertyValue() expects parameter 1 to be string, array given in %s on line 28
+NULL \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_hasConstant_001.phpt b/ext/reflection/tests/ReflectionClass_hasConstant_001.phpt
new file mode 100644
index 0000000..6e6d434
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_hasConstant_001.phpt
@@ -0,0 +1,36 @@
+--TEST--
+ReflectionClass::hasConstant()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {
+ const myConst = 1;
+}
+
+class D extends C {
+}
+
+
+$rc = new ReflectionClass("C");
+echo "Check existing constant: ";
+var_dump($rc->hasConstant("myConst"));
+echo "Check existing constant, different case: ";
+var_dump($rc->hasConstant("MyCoNsT"));
+echo "Check absent constant: ";
+var_dump($rc->hasConstant("doesntExist"));
+
+
+$rd = new ReflectionClass("D");
+echo "Check inherited constant: ";
+var_dump($rd->hasConstant("myConst"));
+echo "Check absent constant: ";
+var_dump($rd->hasConstant("doesntExist"));
+?>
+--EXPECTF--
+Check existing constant: bool(true)
+Check existing constant, different case: bool(false)
+Check absent constant: bool(false)
+Check inherited constant: bool(true)
+Check absent constant: bool(false) \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_hasConstant_002.phpt b/ext/reflection/tests/ReflectionClass_hasConstant_002.phpt
new file mode 100644
index 0000000..a0a76f0
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_hasConstant_002.phpt
@@ -0,0 +1,40 @@
+--TEST--
+ReflectionClass::hasConstant() - error cases
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {
+ const myConst = 1;
+}
+
+$rc = new ReflectionClass("C");
+echo "Check invalid params:\n";
+var_dump($rc->hasConstant());
+var_dump($rc->hasConstant("myConst", "myConst"));
+var_dump($rc->hasConstant(null));
+var_dump($rc->hasConstant(1));
+var_dump($rc->hasConstant(1.5));
+var_dump($rc->hasConstant(true));
+var_dump($rc->hasConstant(array(1,2,3)));
+var_dump($rc->hasConstant(new C));
+?>
+--EXPECTF--
+Check invalid params:
+
+Warning: ReflectionClass::hasConstant() expects exactly 1 parameter, 0 given in %s on line 8
+NULL
+
+Warning: ReflectionClass::hasConstant() expects exactly 1 parameter, 2 given in %s on line 9
+NULL
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: ReflectionClass::hasConstant() expects parameter 1 to be string, array given in %s on line 14
+NULL
+
+Warning: ReflectionClass::hasConstant() expects parameter 1 to be string, object given in %s on line 15
+NULL \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_hasConstant_basic.phpt b/ext/reflection/tests/ReflectionClass_hasConstant_basic.phpt
new file mode 100644
index 0000000..0ff2523
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_hasConstant_basic.phpt
@@ -0,0 +1,23 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_hasMethod_001.phpt b/ext/reflection/tests/ReflectionClass_hasMethod_001.phpt
new file mode 100644
index 0000000..81614bd
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_hasMethod_001.phpt
@@ -0,0 +1,75 @@
+--TEST--
+ReflectionClass::hasMethod()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class pubf {
+ public function f() {}
+ static public function s() {}
+}
+class subpubf extends pubf {
+}
+
+class protf {
+ protected function f() {}
+ static protected function s() {}
+}
+class subprotf extends protf {
+}
+
+class privf {
+ private function f() {}
+ static private function s() {}
+}
+class subprivf extends privf {
+}
+
+$classes = array("pubf", "subpubf", "protf", "subprotf",
+ "privf", "subprivf");
+foreach($classes as $class) {
+ echo "Reflecting on class $class: \n";
+ $rc = new ReflectionClass($class);
+ echo " --> Check for f(): ";
+ var_dump($rc->hasMethod("f"));
+ echo " --> Check for s(): ";
+ var_dump($rc->hasMethod("s"));
+ echo " --> Check for F(): ";
+ var_dump($rc->hasMethod("F"));
+ echo " --> Check for doesntExist(): ";
+ var_dump($rc->hasMethod("doesntExist"));
+}
+?>
+--EXPECTF--
+Reflecting on class pubf:
+ --> Check for f(): bool(true)
+ --> Check for s(): bool(true)
+ --> Check for F(): bool(true)
+ --> Check for doesntExist(): bool(false)
+Reflecting on class subpubf:
+ --> Check for f(): bool(true)
+ --> Check for s(): bool(true)
+ --> Check for F(): bool(true)
+ --> Check for doesntExist(): bool(false)
+Reflecting on class protf:
+ --> Check for f(): bool(true)
+ --> Check for s(): bool(true)
+ --> Check for F(): bool(true)
+ --> Check for doesntExist(): bool(false)
+Reflecting on class subprotf:
+ --> Check for f(): bool(true)
+ --> Check for s(): bool(true)
+ --> Check for F(): bool(true)
+ --> Check for doesntExist(): bool(false)
+Reflecting on class privf:
+ --> Check for f(): bool(true)
+ --> Check for s(): bool(true)
+ --> Check for F(): bool(true)
+ --> Check for doesntExist(): bool(false)
+Reflecting on class subprivf:
+ --> Check for f(): bool(true)
+ --> Check for s(): bool(true)
+ --> Check for F(): bool(true)
+ --> Check for doesntExist(): bool(false)
+ \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_hasMethod_002.phpt b/ext/reflection/tests/ReflectionClass_hasMethod_002.phpt
new file mode 100644
index 0000000..63fe879
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_hasMethod_002.phpt
@@ -0,0 +1,40 @@
+--TEST--
+ReflectionClass::hasMethod() - error cases
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {
+ function f() {}
+}
+
+$rc = new ReflectionClass("C");
+echo "Check invalid params:\n";
+var_dump($rc->hasMethod());
+var_dump($rc->hasMethod("f", "f"));
+var_dump($rc->hasMethod(null));
+var_dump($rc->hasMethod(1));
+var_dump($rc->hasMethod(1.5));
+var_dump($rc->hasMethod(true));
+var_dump($rc->hasMethod(array(1,2,3)));
+var_dump($rc->hasMethod(new C));
+?>
+--EXPECTF--
+Check invalid params:
+
+Warning: ReflectionClass::hasMethod() expects exactly 1 parameter, 0 given in %s on line 8
+NULL
+
+Warning: ReflectionClass::hasMethod() expects exactly 1 parameter, 2 given in %s on line 9
+NULL
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: ReflectionClass::hasMethod() expects parameter 1 to be string, array given in %s on line 14
+NULL
+
+Warning: ReflectionClass::hasMethod() expects parameter 1 to be string, object given in %s on line 15
+NULL
diff --git a/ext/reflection/tests/ReflectionClass_hasMethod_basic.phpt b/ext/reflection/tests/ReflectionClass_hasMethod_basic.phpt
new file mode 100644
index 0000000..fa4ee48
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_hasMethod_basic.phpt
@@ -0,0 +1,57 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_hasProperty_001.phpt b/ext/reflection/tests/ReflectionClass_hasProperty_001.phpt
new file mode 100644
index 0000000..88c4cd5
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_hasProperty_001.phpt
@@ -0,0 +1,75 @@
+--TEST--
+ReflectionClass::hasProperty()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class pubf {
+ public $a;
+ static public $s;
+}
+class subpubf extends pubf {
+}
+
+class protf {
+ protected $a;
+ static protected $s;
+}
+class subprotf extends protf {
+}
+
+class privf {
+ private $a;
+ static protected $s;
+}
+class subprivf extends privf {
+}
+
+$classes = array("pubf", "subpubf", "protf", "subprotf",
+ "privf", "subprivf");
+foreach($classes as $class) {
+ echo "Reflecting on class $class: \n";
+ $rc = new ReflectionClass($class);
+ echo " --> Check for s: ";
+ var_dump($rc->hasProperty("s"));
+ echo " --> Check for a: ";
+ var_dump($rc->hasProperty("a"));
+ echo " --> Check for A: ";
+ var_dump($rc->hasProperty("A"));
+ echo " --> Check for doesntExist: ";
+ var_dump($rc->hasProperty("doesntExist"));
+}
+?>
+--EXPECTF--
+Reflecting on class pubf:
+ --> Check for s: bool(true)
+ --> Check for a: bool(true)
+ --> Check for A: bool(false)
+ --> Check for doesntExist: bool(false)
+Reflecting on class subpubf:
+ --> Check for s: bool(true)
+ --> Check for a: bool(true)
+ --> Check for A: bool(false)
+ --> Check for doesntExist: bool(false)
+Reflecting on class protf:
+ --> Check for s: bool(true)
+ --> Check for a: bool(true)
+ --> Check for A: bool(false)
+ --> Check for doesntExist: bool(false)
+Reflecting on class subprotf:
+ --> Check for s: bool(true)
+ --> Check for a: bool(true)
+ --> Check for A: bool(false)
+ --> Check for doesntExist: bool(false)
+Reflecting on class privf:
+ --> Check for s: bool(true)
+ --> Check for a: bool(true)
+ --> Check for A: bool(false)
+ --> Check for doesntExist: bool(false)
+Reflecting on class subprivf:
+ --> Check for s: bool(true)
+ --> Check for a: bool(false)
+ --> Check for A: bool(false)
+ --> Check for doesntExist: bool(false)
+
diff --git a/ext/reflection/tests/ReflectionClass_hasProperty_002.phpt b/ext/reflection/tests/ReflectionClass_hasProperty_002.phpt
new file mode 100644
index 0000000..7538903
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_hasProperty_002.phpt
@@ -0,0 +1,40 @@
+--TEST--
+ReflectionClass::hasProperty() - error cases
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {
+ public $a;
+}
+
+$rc = new ReflectionClass("C");
+echo "Check invalid params:\n";
+var_dump($rc->hasProperty());
+var_dump($rc->hasProperty("a", "a"));
+var_dump($rc->hasProperty(null));
+var_dump($rc->hasProperty(1));
+var_dump($rc->hasProperty(1.5));
+var_dump($rc->hasProperty(true));
+var_dump($rc->hasProperty(array(1,2,3)));
+var_dump($rc->hasProperty(new C));
+?>
+--EXPECTF--
+Check invalid params:
+
+Warning: ReflectionClass::hasProperty() expects exactly 1 parameter, 0 given in %s on line 8
+NULL
+
+Warning: ReflectionClass::hasProperty() expects exactly 1 parameter, 2 given in %s on line 9
+NULL
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: ReflectionClass::hasProperty() expects parameter 1 to be string, array given in %s on line 14
+NULL
+
+Warning: ReflectionClass::hasProperty() expects parameter 1 to be string, object given in %s on line 15
+NULL
diff --git a/ext/reflection/tests/ReflectionClass_hasProperty_basic.phpt b/ext/reflection/tests/ReflectionClass_hasProperty_basic.phpt
new file mode 100644
index 0000000..d6dda7c
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_hasProperty_basic.phpt
@@ -0,0 +1,38 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt b/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt
new file mode 100644
index 0000000..9c2fded
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt
@@ -0,0 +1,155 @@
+--TEST--
+ReflectionClass::implementsInterface()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+interface I1 {}
+class A implements I1 {}
+class B extends A {}
+
+interface I2 extends I1 {}
+class C implements I2 {}
+
+$classNames = array('A', 'B', 'C', 'I1', 'I2');
+
+foreach ($classNames as $className) {
+ $rcs[$className] = new ReflectionClass($className);
+}
+
+foreach ($rcs as $childName => $child) {
+ foreach ($rcs as $parentName => $parent) {
+ echo "Does " . $childName . " implement " . $parentName . "? \n";
+ echo " - Using object argument: ";
+ try {
+ var_dump($child->implementsInterface($parent));
+ } catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+ }
+ echo " - Using string argument: ";
+ try {
+ var_dump($child->implementsInterface($parentName));
+ } catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+ }
+ }
+}
+
+
+
+echo "\n\nTest bad arguments:\n";
+try {
+ var_dump($rcs['A']->implementsInterface());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rcs['A']->implementsInterface('C', 'C'));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rcs['A']->implementsInterface(null));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rcs['A']->implementsInterface('ThisClassDoesNotExist'));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rcs['A']->implementsInterface(2));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+--EXPECTF--
+Does A implement A?
+ - Using object argument: Interface A is a Class
+ - Using string argument: Interface A is a Class
+Does A implement B?
+ - Using object argument: Interface B is a Class
+ - Using string argument: Interface B is a Class
+Does A implement C?
+ - Using object argument: Interface C is a Class
+ - Using string argument: Interface C is a Class
+Does A implement I1?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Does A implement I2?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Does B implement A?
+ - Using object argument: Interface A is a Class
+ - Using string argument: Interface A is a Class
+Does B implement B?
+ - Using object argument: Interface B is a Class
+ - Using string argument: Interface B is a Class
+Does B implement C?
+ - Using object argument: Interface C is a Class
+ - Using string argument: Interface C is a Class
+Does B implement I1?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Does B implement I2?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Does C implement A?
+ - Using object argument: Interface A is a Class
+ - Using string argument: Interface A is a Class
+Does C implement B?
+ - Using object argument: Interface B is a Class
+ - Using string argument: Interface B is a Class
+Does C implement C?
+ - Using object argument: Interface C is a Class
+ - Using string argument: Interface C is a Class
+Does C implement I1?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Does C implement I2?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Does I1 implement A?
+ - Using object argument: Interface A is a Class
+ - Using string argument: Interface A is a Class
+Does I1 implement B?
+ - Using object argument: Interface B is a Class
+ - Using string argument: Interface B is a Class
+Does I1 implement C?
+ - Using object argument: Interface C is a Class
+ - Using string argument: Interface C is a Class
+Does I1 implement I1?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Does I1 implement I2?
+ - Using object argument: bool(false)
+ - Using string argument: bool(false)
+Does I2 implement A?
+ - Using object argument: Interface A is a Class
+ - Using string argument: Interface A is a Class
+Does I2 implement B?
+ - Using object argument: Interface B is a Class
+ - Using string argument: Interface B is a Class
+Does I2 implement C?
+ - Using object argument: Interface C is a Class
+ - Using string argument: Interface C is a Class
+Does I2 implement I1?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+Does I2 implement I2?
+ - Using object argument: bool(true)
+ - Using string argument: bool(true)
+
+
+Test bad arguments:
+
+Warning: ReflectionClass::implementsInterface() expects exactly 1 parameter, 0 given in %s on line 37
+NULL
+
+Warning: ReflectionClass::implementsInterface() expects exactly 1 parameter, 2 given in %s on line 42
+NULL
+Parameter one must either be a string or a ReflectionClass object
+Interface ThisClassDoesNotExist does not exist
+Parameter one must either be a string or a ReflectionClass object
diff --git a/ext/reflection/tests/ReflectionClass_isAbstract_basic.phpt b/ext/reflection/tests/ReflectionClass_isAbstract_basic.phpt
new file mode 100644
index 0000000..a7d1982
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isAbstract_basic.phpt
@@ -0,0 +1,21 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt b/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt
new file mode 100644
index 0000000..f1042cc
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Testing ReflectionClass::isCloneable()
+--SKIPIF--
+<?php if (!extension_loaded('simplexml') || !extension_loaded('xmlwriter')) die("skip SimpleXML and XMLWriter is required for this test"); ?>
+--FILE--
+<?php
+
+class foo {
+}
+$foo = new foo;
+
+print "User class\n";
+$obj = new ReflectionClass($foo);
+var_dump($obj->isCloneable());
+$obj = new ReflectionObject($foo);
+var_dump($obj->isCloneable());
+$h = clone $foo;
+
+class bar {
+ private function __clone() {
+ }
+}
+$bar = new bar;
+print "User class - private __clone\n";
+$obj = new ReflectionClass($bar);
+var_dump($obj->isCloneable());
+$obj = new ReflectionObject($bar);
+var_dump($obj->isCloneable());
+$h = clone $foo;
+
+print "Closure\n";
+$closure = function () { };
+$obj = new ReflectionClass($closure);
+var_dump($obj->isCloneable());
+$obj = new ReflectionObject($closure);
+var_dump($obj->isCloneable());
+$h = clone $closure;
+
+print "Internal class - SimpleXMLElement\n";
+$obj = new ReflectionClass('simplexmlelement');
+var_dump($obj->isCloneable());
+$obj = new ReflectionObject(new simplexmlelement('<test></test>'));
+var_dump($obj->isCloneable());
+$h = clone new simplexmlelement('<test></test>');
+
+print "Internal class - XMLWriter\n";
+$obj = new ReflectionClass('xmlwriter');
+var_dump($obj->isCloneable());
+$obj = new ReflectionObject(new XMLWriter);
+var_dump($obj->isCloneable());
+$h = clone new xmlwriter;
+
+?>
+--EXPECTF--
+User class
+bool(true)
+bool(true)
+User class - private __clone
+bool(false)
+bool(false)
+Closure
+bool(true)
+bool(true)
+Internal class - SimpleXMLElement
+bool(true)
+bool(true)
+Internal class - XMLWriter
+bool(false)
+bool(false)
+
+Fatal error: Trying to clone an uncloneable object of class XMLWriter in %s on line %d
diff --git a/ext/reflection/tests/ReflectionClass_isCloneable_002.phpt b/ext/reflection/tests/ReflectionClass_isCloneable_002.phpt
new file mode 100644
index 0000000..7cde576
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isCloneable_002.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Testing ReflectionClass::isCloneable() with non instantiable objects
+--FILE--
+<?php
+
+trait foo {
+}
+$obj = new ReflectionClass('foo');
+var_dump($obj->isCloneable());
+
+abstract class bar {
+}
+$obj = new ReflectionClass('bar');
+var_dump($obj->isCloneable());
+
+interface baz {
+}
+$obj = new ReflectionClass('baz');
+var_dump($obj->isCloneable());
+
+?>
+--EXPECT--
+bool(false)
+bool(false)
+bool(false)
diff --git a/ext/reflection/tests/ReflectionClass_isFinal_basic.phpt b/ext/reflection/tests/ReflectionClass_isFinal_basic.phpt
new file mode 100644
index 0000000..57e577a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isFinal_basic.phpt
@@ -0,0 +1,21 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt b/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt
new file mode 100644
index 0000000..2da0944
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt
@@ -0,0 +1,51 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_isInstance_error.phpt b/ext/reflection/tests/ReflectionClass_isInstance_error.phpt
new file mode 100644
index 0000000..2c4f49b
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isInstance_error.phpt
@@ -0,0 +1,39 @@
+--TEST--
+ReflectionClass::isInstance() - invalid params
+--FILE--
+<?php
+class X {}
+
+$rc = new ReflectionClass("X");
+$instance = new X;
+
+var_dump($rc->isInstance());
+var_dump($rc->isInstance($instance, $instance));
+var_dump($rc->isInstance(1));
+var_dump($rc->isInstance(1.5));
+var_dump($rc->isInstance(true));
+var_dump($rc->isInstance('X'));
+var_dump($rc->isInstance(null));
+
+?>
+--EXPECTF--
+Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 0 given in %s on line 7
+NULL
+
+Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 2 given in %s on line 8
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, %s given in %s on line 9
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, double given in %s on line 10
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, boolean given in %s on line 11
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, string given in %s on line 12
+NULL
+
+Warning: ReflectionClass::isInstance() expects parameter 1 to be object, null given in %s on line 13
+NULL
diff --git a/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt b/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt
new file mode 100644
index 0000000..6ebcfa9
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt
@@ -0,0 +1,40 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt b/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt
new file mode 100644
index 0000000..52be239
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt
@@ -0,0 +1,19 @@
+--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
diff --git a/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt b/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt
new file mode 100644
index 0000000..1cf3e61
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt
@@ -0,0 +1,50 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_isInterface_basic.phpt b/ext/reflection/tests/ReflectionClass_isInterface_basic.phpt
new file mode 100644
index 0000000..66c9ae7
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isInterface_basic.phpt
@@ -0,0 +1,25 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt b/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt
new file mode 100644
index 0000000..2eaacb6
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt
@@ -0,0 +1,22 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_isInternal_error.phpt b/ext/reflection/tests/ReflectionClass_isInternal_error.phpt
new file mode 100644
index 0000000..ef69a4c
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isInternal_error.phpt
@@ -0,0 +1,14 @@
+--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
diff --git a/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt b/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt
new file mode 100644
index 0000000..4936413
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt
@@ -0,0 +1,89 @@
+--TEST--
+ReflectionClass::isIterateable()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+Interface ExtendsIterator extends Iterator {
+}
+Interface ExtendsIteratorAggregate extends IteratorAggregate {
+}
+Class IteratorImpl implements Iterator {
+ public function next() {}
+ public function key() {}
+ public function rewind() {}
+ public function current() {}
+ public function valid() {}
+}
+Class IterarorAggregateImpl implements IteratorAggregate {
+ public function getIterator() {}
+}
+Class ExtendsIteratorImpl extends IteratorImpl {
+}
+Class ExtendsIteratorAggregateImpl extends IterarorAggregateImpl {
+}
+Class A {
+}
+
+$classes = array('Traversable', 'Iterator', 'IteratorAggregate', 'ExtendsIterator', 'ExtendsIteratorAggregate',
+ 'IteratorImpl', 'IterarorAggregateImpl', 'ExtendsIteratorImpl', 'ExtendsIteratorAggregateImpl', 'A');
+
+foreach($classes as $class) {
+ $rc = new ReflectionClass($class);
+ echo "Is $class iterable? ";
+ var_dump($rc->isIterateable());
+}
+
+echo "\nTest invalid params:\n";
+$rc = new ReflectionClass('IteratorImpl');
+var_dump($rc->isIterateable(null));
+var_dump($rc->isIterateable(null, null));
+var_dump($rc->isIterateable(1));
+var_dump($rc->isIterateable(1.5));
+var_dump($rc->isIterateable(true));
+var_dump($rc->isIterateable('X'));
+var_dump($rc->isIterateable(null));
+
+echo "\nTest static invocation:\n";
+ReflectionClass::isIterateable();
+
+?>
+--EXPECTF--
+Is Traversable iterable? bool(false)
+Is Iterator iterable? bool(false)
+Is IteratorAggregate iterable? bool(false)
+Is ExtendsIterator iterable? bool(false)
+Is ExtendsIteratorAggregate iterable? bool(false)
+Is IteratorImpl iterable? bool(true)
+Is IterarorAggregateImpl iterable? bool(true)
+Is ExtendsIteratorImpl iterable? bool(true)
+Is ExtendsIteratorAggregateImpl iterable? bool(true)
+Is A iterable? bool(false)
+
+Test invalid params:
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 34
+NULL
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 2 given in %s on line 35
+NULL
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 36
+NULL
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 37
+NULL
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 38
+NULL
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 39
+NULL
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 40
+NULL
+
+Test static invocation:
+
+Fatal error: Non-static method ReflectionClass::isIterateable() cannot be called statically in %s on line 43 \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt b/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt
new file mode 100644
index 0000000..8b65b9a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt
@@ -0,0 +1,34 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt b/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt
new file mode 100644
index 0000000..f6d0d53
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt
@@ -0,0 +1,25 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt
new file mode 100644
index 0000000..083b277
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt
@@ -0,0 +1,49 @@
+--TEST--
+ReflectionObject::isSubclassOf() - bad arguments
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class A {}
+$rc = new ReflectionClass('A');
+
+echo "\n\nTest bad arguments:\n";
+try {
+ var_dump($rc->isSubclassOf());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->isSubclassOf('C', 'C'));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->isSubclassOf(null));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->isSubclassOf('ThisClassDoesNotExist'));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->isSubclassOf(2));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+--EXPECTF--
+
+Test bad arguments:
+
+Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 0 given in %s on line 7
+NULL
+
+Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 2 given in %s on line 12
+NULL
+Parameter one must either be a string or a ReflectionClass object
+Class ThisClassDoesNotExist does not exist
+Parameter one must either be a string or a ReflectionClass object \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt
new file mode 100644
index 0000000..94fcf00
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt
@@ -0,0 +1,103 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt
new file mode 100644
index 0000000..7d929fa
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isSubclassOf_error.phpt
@@ -0,0 +1,17 @@
+--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
diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt
new file mode 100644
index 0000000..2fabd02
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt
@@ -0,0 +1,16 @@
+--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
diff --git a/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt b/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt
new file mode 100644
index 0000000..af43fce
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt
@@ -0,0 +1,22 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt b/ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt
new file mode 100644
index 0000000..ac88884
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_isUserDefined_error.phpt
@@ -0,0 +1,14 @@
+--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
diff --git a/ext/reflection/tests/ReflectionClass_modifiers_001.phpt b/ext/reflection/tests/ReflectionClass_modifiers_001.phpt
new file mode 100644
index 0000000..941bfe5
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_modifiers_001.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Modifiers
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+abstract class A {}
+class B extends A {}
+class C {}
+final class D {}
+interface I {}
+
+$classes = array("A", "B", "C", "D", "I");
+
+foreach ($classes as $class) {
+ $rc = new ReflectionClass($class);
+ var_dump($rc->isFinal());
+ var_dump($rc->isInterface());
+ var_dump($rc->isAbstract());
+ var_dump($rc->getModifiers());
+}
+?>
+--EXPECTF--
+bool(false)
+bool(false)
+bool(true)
+int(32)
+bool(false)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+bool(false)
+bool(false)
+int(0)
+bool(true)
+bool(false)
+bool(false)
+int(64)
+bool(false)
+bool(true)
+bool(false)
+int(128) \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_modifiers_002.phpt b/ext/reflection/tests/ReflectionClass_modifiers_002.phpt
new file mode 100644
index 0000000..a3a567c
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_modifiers_002.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Modifiers - wrong param count
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {}
+$rc = new ReflectionClass("C");
+var_dump($rc->isFinal('X'));
+var_dump($rc->isInterface(null));
+var_dump($rc->isAbstract(true));
+var_dump($rc->getModifiers(array(1,2,3)));
+
+?>
+--EXPECTF--
+Warning: ReflectionClass::isFinal() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::isInterface() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::isAbstract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionClass::getModifiers() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
diff --git a/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt b/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt
new file mode 100644
index 0000000..981d675
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt
@@ -0,0 +1,98 @@
+--TEST--
+ReflectionClass::newInstanceArgs
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class A {
+ public function A() {
+ echo "In constructor of class A\n";
+ }
+}
+
+class B {
+ public function __construct($a, $b) {
+ echo "In constructor of class B with args $a, $b\n";
+ }
+}
+
+class C {
+ protected function __construct() {
+ echo "In constructor of class C\n";
+ }
+}
+
+class D {
+ private function __construct() {
+ echo "In constructor of class D\n";
+ }
+}
+class E {
+}
+
+
+$rcA = new ReflectionClass('A');
+$rcB = new ReflectionClass('B');
+$rcC = new ReflectionClass('C');
+$rcD = new ReflectionClass('D');
+$rcE = new ReflectionClass('E');
+
+$a1 = $rcA->newInstanceArgs();
+$a2 = $rcA->newInstanceArgs(array('x'));
+var_dump($a1, $a2);
+
+$b1 = $rcB->newInstanceArgs();
+$b2 = $rcB->newInstanceArgs(array('x', 123));
+var_dump($b1, $b2);
+
+try {
+ $rcC->newInstanceArgs();
+ echo "you should not see this\n";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $rcD->newInstanceArgs();
+ echo "you should not see this\n";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+$e1 = $rcE->newInstanceArgs();
+var_dump($e1);
+
+try {
+ $e2 = $rcE->newInstanceArgs(array('x'));
+ echo "you should not see this\n";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+--EXPECTF--
+In constructor of class A
+In constructor of class A
+object(A)#%d (0) {
+}
+object(A)#%d (0) {
+}
+
+Warning: Missing argument 1 for B::__construct() in %s on line 9
+
+Warning: Missing argument 2 for B::__construct() in %s on line 9
+
+Notice: Undefined variable: a in %s on line 10
+
+Notice: Undefined variable: b in %s on line 10
+In constructor of class B with args ,
+In constructor of class B with args x, 123
+object(B)#%d (0) {
+}
+object(B)#%d (0) {
+}
+Access to non-public constructor of class C
+Access to non-public constructor of class D
+object(E)#%d (0) {
+}
+Class E does not have a constructor, so you cannot pass any constructor arguments \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt b/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt
new file mode 100644
index 0000000..dd6f438
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt
@@ -0,0 +1,20 @@
+--TEST--
+ReflectionClass::newInstanceArgs() - wrong arg type
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class A {
+ public function __construct($a, $b) {
+ echo "In constructor of class B with arg $a\n";
+ }
+}
+$rc = new ReflectionClass('A');
+$a = $rc->newInstanceArgs('x');
+var_dump($a);
+
+?>
+--EXPECTF--
+
+Catchable fatal error: Argument 1 passed to ReflectionClass::newInstanceArgs() must be of the type array, string given in %s on line 8
diff --git a/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt b/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt
new file mode 100644
index 0000000..1932dbf
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt
@@ -0,0 +1,33 @@
+--TEST--
+ReflectionClass::newInstanceWithoutConstructor()
+--CREDITS--
+Sebastian Bergmann <sebastian@php.net>
+--FILE--
+<?php
+class Foo
+{
+ public function __construct()
+ {
+ print __METHOD__;
+ }
+}
+
+$class = new ReflectionClass('Foo');
+var_dump($class->newInstanceWithoutConstructor());
+
+$class = new ReflectionClass('StdClass');
+var_dump($class->newInstanceWithoutConstructor());
+
+$class = new ReflectionClass('DateTime');
+var_dump($class->newInstanceWithoutConstructor());
+--EXPECTF--
+object(Foo)#%d (0) {
+}
+object(stdClass)#%d (0) {
+}
+
+Fatal error: Uncaught exception 'ReflectionException' with message 'Class DateTime is an internal class that cannot be instantiated without invoking its constructor' in %sReflectionClass_newInstanceWithoutConstructor.php:%d
+Stack trace:
+#0 %sReflectionClass_newInstanceWithoutConstructor.php(%d): ReflectionClass->newInstanceWithoutConstructor()
+#1 {main}
+ thrown in %sReflectionClass_newInstanceWithoutConstructor.php on line %d
diff --git a/ext/reflection/tests/ReflectionClass_newInstance_001.phpt b/ext/reflection/tests/ReflectionClass_newInstance_001.phpt
new file mode 100644
index 0000000..3cdb5d7
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_newInstance_001.phpt
@@ -0,0 +1,98 @@
+--TEST--
+ReflectionClass::newInstance()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class A {
+ public function A() {
+ echo "In constructor of class A\n";
+ }
+}
+
+class B {
+ public function __construct($a, $b) {
+ echo "In constructor of class B with args $a, $b\n";
+ }
+}
+
+class C {
+ protected function __construct() {
+ echo "In constructor of class C\n";
+ }
+}
+
+class D {
+ private function __construct() {
+ echo "In constructor of class D\n";
+ }
+}
+class E {
+}
+
+
+$rcA = new ReflectionClass('A');
+$rcB = new ReflectionClass('B');
+$rcC = new ReflectionClass('C');
+$rcD = new ReflectionClass('D');
+$rcE = new ReflectionClass('E');
+
+$a1 = $rcA->newInstance();
+$a2 = $rcA->newInstance('x');
+var_dump($a1, $a2);
+
+$b1 = $rcB->newInstance();
+$b2 = $rcB->newInstance('x', 123);
+var_dump($b1, $b2);
+
+try {
+ $rcC->newInstance();
+ echo "you should not see this\n";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $rcD->newInstance();
+ echo "you should not see this\n";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+$e1 = $rcE->newInstance();
+var_dump($e1);
+
+try {
+ $e2 = $rcE->newInstance('x');
+ echo "you should not see this\n";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+--EXPECTF--
+In constructor of class A
+In constructor of class A
+object(A)#%d (0) {
+}
+object(A)#%d (0) {
+}
+
+Warning: Missing argument 1 for B::__construct() in %s on line 9
+
+Warning: Missing argument 2 for B::__construct() in %s on line 9
+
+Notice: Undefined variable: a in %s on line 10
+
+Notice: Undefined variable: b in %s on line 10
+In constructor of class B with args ,
+In constructor of class B with args x, 123
+object(B)#%d (0) {
+}
+object(B)#%d (0) {
+}
+Access to non-public constructor of class C
+Access to non-public constructor of class D
+object(E)#%d (0) {
+}
+Class E does not have a constructor, so you cannot pass any constructor arguments \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt
new file mode 100644
index 0000000..9e8f01e
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt
@@ -0,0 +1,79 @@
+--TEST--
+ReflectionClass::setStaticPropertyValue()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--SKIPIF--
+<?php if (version_compare(zend_version(), '2.4.0', '>=')) die('skip ZendEngine 2.3 or below needed'); ?>
+--FILE--
+<?php
+class A {
+ static private $privateOverridden = "original private";
+ static protected $protectedOverridden = "original protected";
+ static public $publicOverridden = "original public";
+}
+
+class B extends A {
+ static private $privateOverridden = "changed private";
+ static protected $protectedOverridden = "changed protected";
+ static public $publicOverridden = "changed public";
+}
+
+echo "Set static values in A:\n";
+$rcA = new ReflectionClass('A');
+$rcA->setStaticPropertyValue("\0A\0privateOverridden", "new value 1");
+$rcA->setStaticPropertyValue("\0*\0protectedOverridden", "new value 2");
+$rcA->setStaticPropertyValue("publicOverridden", "new value 3");
+print_r($rcA->getStaticProperties());
+
+echo "\nSet static values in B:\n";
+$rcB = new ReflectionClass('B');
+$rcB->setStaticPropertyValue("\0A\0privateOverridden", "new value 4");
+$rcB->setStaticPropertyValue("\0B\0privateOverridden", "new value 5");
+$rcB->setStaticPropertyValue("\0*\0protectedOverridden", "new value 6");
+$rcB->setStaticPropertyValue("publicOverridden", "new value 7");
+print_r($rcA->getStaticProperties());
+print_r($rcB->getStaticProperties());
+
+echo "\nSet non-existent values from A with no default value:\n";
+try {
+ var_dump($rcA->setStaticPropertyValue("protectedOverridden", "new value 8"));
+ echo "you should not see this";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ var_dump($rcA->setStaticPropertyValue("privateOverridden", "new value 9"));
+ echo "you should not see this";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+--EXPECTF--
+Set static values in A:
+Array
+(
+ [privateOverridden] => new value 1
+ [protectedOverridden] => new value 2
+ [publicOverridden] => new value 3
+)
+
+Set static values in B:
+Array
+(
+ [privateOverridden] => new value 4
+ [protectedOverridden] => new value 2
+ [publicOverridden] => new value 3
+)
+Array
+(
+ [privateOverridden] => new value 5
+ [protectedOverridden] => new value 6
+ [publicOverridden] => new value 7
+)
+
+Set non-existent values from A with no default value:
+Class A does not have a property named protectedOverridden
+Class A does not have a property named privateOverridden
diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001_2_4.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001_2_4.phpt
new file mode 100644
index 0000000..1092f65
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001_2_4.phpt
@@ -0,0 +1,61 @@
+--TEST--
+ReflectionClass::setStaticPropertyValue()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--SKIPIF--
+<?php if (version_compare(zend_version(), '2.4.0', '<')) die('skip ZendEngine 2.4 needed'); ?>
+--FILE--
+<?php
+class A {
+ static private $privateOverridden = "original private";
+ static protected $protectedOverridden = "original protected";
+ static public $publicOverridden = "original public";
+}
+
+class B extends A {
+ static private $privateOverridden = "changed private";
+ static protected $protectedOverridden = "changed protected";
+ static public $publicOverridden = "changed public";
+}
+
+echo "Set static values in A:\n";
+$rcA = new ReflectionClass('A');
+$rcA->setStaticPropertyValue("\0A\0privateOverridden", "new value 1");
+$rcA->setStaticPropertyValue("\0*\0protectedOverridden", "new value 2");
+$rcA->setStaticPropertyValue("publicOverridden", "new value 3");
+print_r($rcA->getStaticProperties());
+
+echo "\nSet static values in B:\n";
+$rcB = new ReflectionClass('B');
+$rcB->setStaticPropertyValue("\0A\0privateOverridden", "new value 4");
+$rcB->setStaticPropertyValue("\0B\0privateOverridden", "new value 5");
+$rcB->setStaticPropertyValue("\0*\0protectedOverridden", "new value 6");
+$rcB->setStaticPropertyValue("publicOverridden", "new value 7");
+print_r($rcA->getStaticProperties());
+print_r($rcB->getStaticProperties());
+
+echo "\nSet non-existent values from A with no default value:\n";
+try {
+ var_dump($rcA->setStaticPropertyValue("protectedOverridden", "new value 8"));
+ echo "you should not see this";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ var_dump($rcA->setStaticPropertyValue("privateOverridden", "new value 9"));
+ echo "you should not see this";
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+--EXPECTF--
+Set static values in A:
+
+Fatal error: Uncaught exception 'ReflectionException' with message 'Class A does not have a property named ' in %sReflectionClass_setStaticPropertyValue_001_2_4.php:%d
+Stack trace:
+#0 %sReflectionClass_setStaticPropertyValue_001_2_4.php(%d): ReflectionClass->setStaticPropertyValue('?A?privateOverr...', 'new value 1')
+#1 {main}
+ thrown in %sReflectionClass_setStaticPropertyValue_001_2_4.php on line %d
diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt
new file mode 100644
index 0000000..3244ec3
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt
@@ -0,0 +1,60 @@
+--TEST--
+ReflectionClass::getStaticPropertyValue() - bad params
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {
+ public static $x;
+}
+
+$rc = new ReflectionClass('C');
+try {
+ var_dump($rc->setStaticPropertyValue("x", "default value", 'blah'));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->setStaticPropertyValue());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->setStaticPropertyValue(null));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->setStaticPropertyValue(null,null));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->setStaticPropertyValue(1.5, 'def'));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($rc->setStaticPropertyValue(array(1,2,3), 'blah'));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+
+?>
+--EXPECTF--
+
+Warning: ReflectionClass::setStaticPropertyValue() expects exactly 2 parameters, 3 given in %s on line 8
+NULL
+
+Warning: ReflectionClass::setStaticPropertyValue() expects exactly 2 parameters, 0 given in %s on line 13
+NULL
+
+Warning: ReflectionClass::setStaticPropertyValue() expects exactly 2 parameters, 1 given in %s on line 18
+NULL
+Class C does not have a property named
+Class C does not have a property named 1.5
+
+Warning: ReflectionClass::setStaticPropertyValue() expects parameter 1 to be string, array given in %s on line 33
+NULL \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_toString_001.phpt b/ext/reflection/tests/ReflectionClass_toString_001.phpt
new file mode 100644
index 0000000..508530a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_toString_001.phpt
@@ -0,0 +1,350 @@
+--TEST--
+ReflectionClass::__toString()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+$rc = new ReflectionClass("ReflectionClass");
+echo $rc;
+?>
+--EXPECTF--
+Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
+
+ - Constants [3] {
+ Constant [ integer IS_IMPLICIT_ABSTRACT ] { 16 }
+ Constant [ integer IS_EXPLICIT_ABSTRACT ] { 32 }
+ Constant [ integer IS_FINAL ] { 64 }
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [1] {
+ Method [ <internal:Reflection> static public method export ] {
+
+ - Parameters [2] {
+ Parameter #0 [ <required> $argument ]
+ Parameter #1 [ <optional> $return ]
+ }
+ }
+ }
+
+ - Properties [1] {
+ Property [ <default> public $name ]
+ }
+
+ - Methods [49] {
+ Method [ <internal:Reflection> final private method __clone ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection, ctor> public method __construct ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $argument ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method __toString ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getName ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method isInternal ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method isUserDefined ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method isInstantiable ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method isCloneable ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getFileName ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getStartLine ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getEndLine ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getDocComment ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getConstructor ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method hasMethod ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $name ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method getMethod ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $name ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method getMethods ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $filter ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method hasProperty ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $name ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method getProperty ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $name ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method getProperties ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $filter ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method hasConstant ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $name ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method getConstants ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getConstant ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $name ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method getInterfaces ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getInterfaceNames ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method isInterface ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getTraits ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getTraitNames ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getTraitAliases ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method isTrait ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method isAbstract ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method isFinal ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getModifiers ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method isInstance ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $object ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method newInstance ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $args ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method newInstanceWithoutConstructor ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method newInstanceArgs ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> array $args ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method getParentClass ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method isSubclassOf ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $class ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method getStaticProperties ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getStaticPropertyValue ] {
+
+ - Parameters [2] {
+ Parameter #0 [ <required> $name ]
+ Parameter #1 [ <optional> $default ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method setStaticPropertyValue ] {
+
+ - Parameters [2] {
+ Parameter #0 [ <required> $name ]
+ Parameter #1 [ <required> $value ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method getDefaultProperties ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method isIterateable ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method implementsInterface ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $interface ]
+ }
+ }
+
+ Method [ <internal:Reflection> public method getExtension ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getExtensionName ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method inNamespace ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getNamespaceName ] {
+
+ - Parameters [0] {
+ }
+ }
+
+ Method [ <internal:Reflection> public method getShortName ] {
+
+ - Parameters [0] {
+ }
+ }
+ }
+}
diff --git a/ext/reflection/tests/ReflectionClass_toString_002.phpt b/ext/reflection/tests/ReflectionClass_toString_002.phpt
new file mode 100644
index 0000000..e9aaa50
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_toString_002.phpt
@@ -0,0 +1,123 @@
+--TEST--
+ReflectionClass::__toString() - verify 'inherits', 'overwrites' and 'prototype' parts of method representation
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+Class A {
+ function f() {}
+}
+Class B extends A {
+ function f() {}
+}
+Class C extends B {
+
+}
+Class D extends C {
+ function f() {}
+}
+foreach (array('A', 'B', 'C', 'D') as $class) {
+ echo "\n\n----( Reflection class $class: )----\n";
+ $rc = new ReflectionClass($class);
+ echo $rc;
+}
+
+?>
+--EXPECTF--
+
+
+----( Reflection class A: )----
+Class [ <user> class A ] {
+ @@ %s 2-4
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [1] {
+ Method [ <user> public method f ] {
+ @@ %s 3 - 3
+ }
+ }
+}
+
+
+----( Reflection class B: )----
+Class [ <user> class B extends A ] {
+ @@ %s 5-7
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [1] {
+ Method [ <user, overwrites A, prototype A> public method f ] {
+ @@ %s 6 - 6
+ }
+ }
+}
+
+
+----( Reflection class C: )----
+Class [ <user> class C extends B ] {
+ @@ %s 8-10
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [1] {
+ Method [ <user, inherits B, prototype A> public method f ] {
+ @@ %s 6 - 6
+ }
+ }
+}
+
+
+----( Reflection class D: )----
+Class [ <user> class D extends C ] {
+ @@ %s 11-13
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [1] {
+ Method [ <user, overwrites B, prototype A> public method f ] {
+ @@ %s 12 - 12
+ }
+ }
+} \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionClass_toString_003.phpt b/ext/reflection/tests/ReflectionClass_toString_003.phpt
new file mode 100644
index 0000000..ce5afb0
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_toString_003.phpt
@@ -0,0 +1,120 @@
+--TEST--
+ReflectionClass::__toString() - verify 'inherits', 'overwrites' and 'prototype' parts of method representation with private methods
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+Class A {
+ private function f() {}
+}
+Class B extends A {
+ private function f() {}
+}
+Class C extends B {
+
+}
+Class D extends C {
+ private function f() {}
+}
+foreach (array('A', 'B', 'C', 'D') as $class) {
+ echo "\n\n----( Reflection class $class: )----\n";
+ $rc = new ReflectionClass($class);
+ echo $rc;
+}
+
+?>
+--EXPECTF--
+
+
+----( Reflection class A: )----
+Class [ <user> class A ] {
+ @@ %s 2-4
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [1] {
+ Method [ <user> private method f ] {
+ @@ %s 3 - 3
+ }
+ }
+}
+
+
+----( Reflection class B: )----
+Class [ <user> class B extends A ] {
+ @@ %s 5-7
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [1] {
+ Method [ <user, overwrites A> private method f ] {
+ @@ %s 6 - 6
+ }
+ }
+}
+
+
+----( Reflection class C: )----
+Class [ <user> class C extends B ] {
+ @@ %s 8-10
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [0] {
+ }
+}
+
+
+----( Reflection class D: )----
+Class [ <user> class D extends C ] {
+ @@ %s 11-13
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [1] {
+ Method [ <user, overwrites B> private method f ] {
+ @@ %s 12 - 12
+ }
+ }
+}
diff --git a/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt b/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt
new file mode 100644
index 0000000..72c8ac6
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt
@@ -0,0 +1,15 @@
+--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==
diff --git a/ext/reflection/tests/ReflectionExtension_constructor_error.phpt b/ext/reflection/tests/ReflectionExtension_constructor_error.phpt
new file mode 100644
index 0000000..9eae206
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_constructor_error.phpt
@@ -0,0 +1,16 @@
+--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==
diff --git a/ext/reflection/tests/ReflectionExtension_export_basic.phpt b/ext/reflection/tests/ReflectionExtension_export_basic.phpt
new file mode 100644
index 0000000..3fa7a66
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_export_basic.phpt
@@ -0,0 +1,22 @@
+--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==
diff --git a/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt b/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt
new file mode 100644
index 0000000..465e868
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt
@@ -0,0 +1,20 @@
+--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==
diff --git a/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt b/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt
new file mode 100644
index 0000000..cd5dc0b
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt
@@ -0,0 +1,14 @@
+--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==
diff --git a/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt b/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt
new file mode 100644
index 0000000..5df9e08
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt
@@ -0,0 +1,74 @@
+--TEST--
+ReflectionExtension::getClasses();
+--CREDITS--
+Thijs Lensselink <tl@lenss.nl>
+--FILE--
+<?php
+$ext = new ReflectionExtension('reflection');
+var_dump($ext->getClasses());
+?>
+==DONE==
+--EXPECT--
+array(12) {
+ ["ReflectionException"]=>
+ &object(ReflectionClass)#2 (1) {
+ ["name"]=>
+ string(19) "ReflectionException"
+ }
+ ["Reflection"]=>
+ &object(ReflectionClass)#3 (1) {
+ ["name"]=>
+ string(10) "Reflection"
+ }
+ ["Reflector"]=>
+ &object(ReflectionClass)#4 (1) {
+ ["name"]=>
+ string(9) "Reflector"
+ }
+ ["ReflectionFunctionAbstract"]=>
+ &object(ReflectionClass)#5 (1) {
+ ["name"]=>
+ string(26) "ReflectionFunctionAbstract"
+ }
+ ["ReflectionFunction"]=>
+ &object(ReflectionClass)#6 (1) {
+ ["name"]=>
+ string(18) "ReflectionFunction"
+ }
+ ["ReflectionParameter"]=>
+ &object(ReflectionClass)#7 (1) {
+ ["name"]=>
+ string(19) "ReflectionParameter"
+ }
+ ["ReflectionMethod"]=>
+ &object(ReflectionClass)#8 (1) {
+ ["name"]=>
+ string(16) "ReflectionMethod"
+ }
+ ["ReflectionClass"]=>
+ &object(ReflectionClass)#9 (1) {
+ ["name"]=>
+ string(15) "ReflectionClass"
+ }
+ ["ReflectionObject"]=>
+ &object(ReflectionClass)#10 (1) {
+ ["name"]=>
+ string(16) "ReflectionObject"
+ }
+ ["ReflectionProperty"]=>
+ &object(ReflectionClass)#11 (1) {
+ ["name"]=>
+ string(18) "ReflectionProperty"
+ }
+ ["ReflectionExtension"]=>
+ &object(ReflectionClass)#12 (1) {
+ ["name"]=>
+ string(19) "ReflectionExtension"
+ }
+ ["ReflectionZendExtension"]=>
+ &object(ReflectionClass)#13 (1) {
+ ["name"]=>
+ string(23) "ReflectionZendExtension"
+ }
+}
+==DONE==
diff --git a/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt b/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt
new file mode 100644
index 0000000..8b5293a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt
@@ -0,0 +1,22 @@
+--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) {
+ ["libxml"]=>
+ %s(8) "Required"
+ ["domxml"]=>
+ %s(9) "Conflicts"
+}
+==DONE==
diff --git a/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt b/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt
new file mode 100644
index 0000000..5b0ade5
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt
@@ -0,0 +1,16 @@
+--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) {
+ ["session"]=>
+ %s(8) "Optional"
+}
+==DONE==
diff --git a/ext/reflection/tests/ReflectionExtension_getName_basic.phpt b/ext/reflection/tests/ReflectionExtension_getName_basic.phpt
new file mode 100644
index 0000000..9dae1f3
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_getName_basic.phpt
@@ -0,0 +1,14 @@
+--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==
+--EXPECT--
+string(10) "Reflection"
+==DONE==
diff --git a/ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt b/ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt
new file mode 100644
index 0000000..19dee82
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt
@@ -0,0 +1,16 @@
+--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==
diff --git a/ext/reflection/tests/ReflectionExtension_info_basic.phpt b/ext/reflection/tests/ReflectionExtension_info_basic.phpt
new file mode 100644
index 0000000..48f6a65
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_info_basic.phpt
@@ -0,0 +1,19 @@
+--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==
diff --git a/ext/reflection/tests/ReflectionExtension_isPersistant.phpt b/ext/reflection/tests/ReflectionExtension_isPersistant.phpt
new file mode 100644
index 0000000..a78a8bb
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_isPersistant.phpt
@@ -0,0 +1,11 @@
+--TEST--
+ReflectionExtension::isPersistent()
+--FILE--
+<?php
+$obj = new ReflectionExtension('reflection');
+var_dump($obj->isPersistent());
+?>
+==DONE==
+--EXPECT--
+bool(true)
+==DONE==
diff --git a/ext/reflection/tests/ReflectionExtension_isTemporary.phpt b/ext/reflection/tests/ReflectionExtension_isTemporary.phpt
new file mode 100644
index 0000000..be97641
--- /dev/null
+++ b/ext/reflection/tests/ReflectionExtension_isTemporary.phpt
@@ -0,0 +1,11 @@
+--TEST--
+ReflectionExtension::isTemporary()
+--FILE--
+<?php
+$obj = new ReflectionExtension('reflection');
+var_dump($obj->isTemporary());
+?>
+==DONE==
+--EXPECT--
+bool(false)
+==DONE==
diff --git a/ext/reflection/tests/ReflectionFunction_001.phpt b/ext/reflection/tests/ReflectionFunction_001.phpt
new file mode 100644
index 0000000..7c592dc
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_001.phpt
@@ -0,0 +1,67 @@
+--TEST--
+ReflectionFunction methods
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+
+/**
+ * my doc comment
+ */
+function foo () {
+ static $c;
+ static $a = 1;
+ static $b = "hello";
+ $d = 5;
+}
+
+/***
+ * not a doc comment
+ */
+function bar () {}
+
+
+function dumpFuncInfo($name) {
+ $funcInfo = new ReflectionFunction($name);
+ var_dump($funcInfo->getName());
+ var_dump($funcInfo->isInternal());
+ var_dump($funcInfo->isUserDefined());
+ var_dump($funcInfo->getStartLine());
+ var_dump($funcInfo->getEndLine());
+ var_dump($funcInfo->getStaticVariables());
+}
+
+dumpFuncInfo('foo');
+dumpFuncInfo('bar');
+dumpFuncInfo('extract');
+
+?>
+--EXPECT--
+string(3) "foo"
+bool(false)
+bool(true)
+int(6)
+int(11)
+array(3) {
+ ["c"]=>
+ NULL
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ string(5) "hello"
+}
+string(3) "bar"
+bool(false)
+bool(true)
+int(16)
+int(16)
+array(0) {
+}
+string(7) "extract"
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+array(0) {
+} \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionFunction_construct.001.phpt b/ext/reflection/tests/ReflectionFunction_construct.001.phpt
new file mode 100644
index 0000000..c8e0a17
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_construct.001.phpt
@@ -0,0 +1,23 @@
+--TEST--
+ReflectionFunction constructor errors
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+
+$a = new ReflectionFunction(array(1, 2, 3));
+try {
+ $a = new ReflectionFunction('nonExistentFunction');
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+$a = new ReflectionFunction();
+$a = new ReflectionFunction(1, 2);
+?>
+--EXPECTF--
+Warning: ReflectionFunction::__construct() expects parameter 1 to be string, array given in %s on line %d
+Function nonExistentFunction() does not exist
+Warning: ReflectionFunction::__construct() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: ReflectionFunction::__construct() expects exactly 1 parameter, 2 given in %s on line %d
diff --git a/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt b/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt
new file mode 100644
index 0000000..f725dfd
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Reflection::getClosureScopeClass()
+--SKIPIF--
+<?php
+if (!extension_loaded('reflection') || !defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50399) {
+ print 'skip';
+}
+?>
+--FILE--
+<?php
+$closure = function($param) { return "this is a closure"; };
+$rf = new ReflectionFunction($closure);
+var_dump($rf->getClosureScopeClass());
+
+Class A {
+ public static function getClosure() {
+ return function($param) { return "this is a closure"; };
+ }
+}
+
+$closure = A::getClosure();
+$rf = new ReflectionFunction($closure);
+var_dump($rf->getClosureScopeClass());
+echo "Done!\n";
+--EXPECTF--
+NULL
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(1) "A"
+}
+Done!
diff --git a/ext/reflection/tests/ReflectionFunction_getClosureThis.phpt b/ext/reflection/tests/ReflectionFunction_getClosureThis.phpt
new file mode 100644
index 0000000..776bfaf
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_getClosureThis.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Reflection::getClosureThis()
+--SKIPIF--
+<?php
+if (!extension_loaded('reflection') || !defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) {
+ print 'skip';
+}
+?>
+--FILE--
+<?php
+$closure = function($param) { return "this is a closure"; };
+$rf = new ReflectionFunction($closure);
+var_dump($rf->getClosureThis());
+echo "Done!\n";
+--EXPECTF--
+NULL
+Done!
diff --git a/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt b/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt
new file mode 100644
index 0000000..786be05
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test ReflectionFunction::getClosure() function : basic functionality
+--FILE--
+<?php
+/* Prototype : public mixed ReflectionFunction::getClosure()
+ * Description: Returns a dynamically created closure for the function
+ * Source code: ext/reflection/php_reflection.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ReflectionFunction::getClosure() : basic functionality ***\n";
+
+function foo()
+{
+ var_dump( "Inside foo function" );
+}
+
+function bar( $arg )
+{
+ var_dump( "Arg is " . $arg );
+}
+
+$func = new ReflectionFunction( 'foo' );
+$closure = $func->getClosure();
+$closure();
+
+$func = new ReflectionFunction( 'bar' );
+$closure = $func->getClosure();
+$closure( 'succeeded' );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing ReflectionFunction::getClosure() : basic functionality ***
+string(19) "Inside foo function"
+string(16) "Arg is succeeded"
+===DONE===
diff --git a/ext/reflection/tests/ReflectionFunction_getClosure_error.phpt b/ext/reflection/tests/ReflectionFunction_getClosure_error.phpt
new file mode 100644
index 0000000..9a963e4
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_getClosure_error.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Test ReflectionFunction::getClosure() function : error functionality
+--FILE--
+<?php
+/* Prototype : public mixed ReflectionFunction::getClosure()
+ * Description: Returns a dynamically created closure for the function
+ * Source code: ext/reflection/php_reflection.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ReflectionFunction::getClosure() : error conditions ***\n";
+
+function foo()
+{
+ var_dump( "Inside foo function" );
+}
+
+$func = new ReflectionFunction( 'foo' );
+$closure = $func->getClosure('bar');
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing ReflectionFunction::getClosure() : error conditions ***
+
+Warning: ReflectionFunction::getClosure() expects exactly 0 parameters, 1 given in %s on line %d
+===DONE===
diff --git a/ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt b/ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt
new file mode 100644
index 0000000..38c278d
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt
@@ -0,0 +1,41 @@
+--TEST--
+ReflectionFunction::getDocComment()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+
+/**
+ * my doc comment
+ */
+function foo () {
+ static $c;
+ static $a = 1;
+ static $b = "hello";
+ $d = 5;
+}
+
+/***
+ * not a doc comment
+ */
+function bar () {}
+
+
+function dumpFuncInfo($name) {
+ $funcInfo = new ReflectionFunction($name);
+ var_dump($funcInfo->getDocComment());
+}
+
+dumpFuncInfo('foo');
+dumpFuncInfo('bar');
+dumpFuncInfo('extract');
+
+?>
+--EXPECTF--
+string(%d) "/**
+ * my doc comment
+ */"
+bool(false)
+bool(false)
+
diff --git a/ext/reflection/tests/ReflectionFunction_getExtension.phpt b/ext/reflection/tests/ReflectionFunction_getExtension.phpt
new file mode 100644
index 0000000..1834589
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_getExtension.phpt
@@ -0,0 +1,19 @@
+--TEST--
+ReflectionFunction::getExtension()
+--FILE--
+<?php
+function foo () {}
+
+$function = new ReflectionFunction('sort');
+var_dump($function->getExtension());
+
+$function = new ReflectionFunction('foo');
+var_dump($function->getExtension());
+?>
+--EXPECTF--
+object(ReflectionExtension)#%i (1) {
+ ["name"]=>
+ string(8) "standard"
+}
+NULL
+
diff --git a/ext/reflection/tests/ReflectionFunction_getExtensionName.phpt b/ext/reflection/tests/ReflectionFunction_getExtensionName.phpt
new file mode 100644
index 0000000..7553a50
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_getExtensionName.phpt
@@ -0,0 +1,16 @@
+--TEST--
+ReflectionFunction::getExtensionName()
+--FILE--
+<?php
+function foo() {}
+
+$function = new ReflectionFunction('sort');
+var_dump($function->getExtensionName());
+
+$function = new ReflectionFunction('foo');
+var_dump($function->getExtensionName());
+?>
+--EXPECT--
+string(8) "standard"
+bool(false)
+
diff --git a/ext/reflection/tests/ReflectionFunction_getFileName.001.phpt b/ext/reflection/tests/ReflectionFunction_getFileName.001.phpt
new file mode 100644
index 0000000..5dbe7b5
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_getFileName.001.phpt
@@ -0,0 +1,18 @@
+--TEST--
+ReflectionFunction::getFileName() with function in an included file
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+
+include "included4.inc";
+
+$funcInfo = new ReflectionFunction('g');
+var_dump($funcInfo->getFileName());
+
+?>
+--EXPECTF--
+%sincluded4.inc
+%d
+string(%d) "%sincluded4.inc" \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionFunction_getFileName.002.phpt b/ext/reflection/tests/ReflectionFunction_getFileName.002.phpt
new file mode 100644
index 0000000..455935e
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_getFileName.002.phpt
@@ -0,0 +1,39 @@
+--TEST--
+ReflectionFunction::getFileName()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+
+/**
+ * my doc comment
+ */
+function foo () {
+ static $c;
+ static $a = 1;
+ static $b = "hello";
+ $d = 5;
+}
+
+/***
+ * not a doc comment
+ */
+function bar () {}
+
+
+function dumpFuncInfo($name) {
+ $funcInfo = new ReflectionFunction($name);
+ var_dump($funcInfo->getFileName());
+}
+
+dumpFuncInfo('foo');
+dumpFuncInfo('bar');
+dumpFuncInfo('extract');
+
+?>
+--EXPECTF--
+string(%d) "%sReflectionFunction_getFileName.002.php"
+string(%d) "%sReflectionFunction_getFileName.002.php"
+bool(false)
+
diff --git a/ext/reflection/tests/ReflectionFunction_getNamespaceName.phpt b/ext/reflection/tests/ReflectionFunction_getNamespaceName.phpt
new file mode 100644
index 0000000..08b3ddd
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_getNamespaceName.phpt
@@ -0,0 +1,29 @@
+--TEST--
+ReflectionFunction::getNamespaceName()
+--FILE--
+<?php
+namespace A\B;
+function foo() {}
+
+$function = new \ReflectionFunction('sort');
+var_dump($function->inNamespace());
+var_dump($function->getName());
+var_dump($function->getNamespaceName());
+var_dump($function->getShortName());
+
+$function = new \ReflectionFunction('A\\B\\foo');
+var_dump($function->inNamespace());
+var_dump($function->getName());
+var_dump($function->getNamespaceName());
+var_dump($function->getShortName());
+?>
+--EXPECT--
+bool(false)
+string(4) "sort"
+string(0) ""
+string(4) "sort"
+bool(true)
+string(7) "A\B\foo"
+string(3) "A\B"
+string(3) "foo"
+
diff --git a/ext/reflection/tests/ReflectionFunction_isClosure_basic.phpt b/ext/reflection/tests/ReflectionFunction_isClosure_basic.phpt
new file mode 100644
index 0000000..eeaf8d3
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_isClosure_basic.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Reflection::isClosure
+--CREDITS--
+Stefan Koopmanschap <stefan@phpgg.nl>
+TestFest PHP|Tek
+--SKIPIF--
+<?php
+if (!extension_loaded('reflection') || !defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) {
+ print 'skip';
+}
+?>
+--FILE--
+<?php
+$closure = function($param) { return "this is a closure"; };
+$rc = new ReflectionFunction($closure);
+echo var_dump($rc->isClosure());
+--EXPECTF--
+bool(true)
diff --git a/ext/reflection/tests/ReflectionFunction_isDeprecated_basic.phpt b/ext/reflection/tests/ReflectionFunction_isDeprecated_basic.phpt
new file mode 100644
index 0000000..31d37a8
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_isDeprecated_basic.phpt
@@ -0,0 +1,15 @@
+--TEST--
+ReflectionFunction::isDeprecated
+--CREDITS--
+Stefan Koopmanschap <stefan@phpgg.nl>
+TestFest PHP|Tek
+--SKIPIF--
+<?php
+if (!extension_loaded('reflection') || !defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) print 'skip';
+?>
+--FILE--
+<?php
+$rc = new ReflectionFunction('ereg');
+echo var_dump($rc->isDeprecated());
+--EXPECTF--
+bool(true)
diff --git a/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt b/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt
new file mode 100644
index 0000000..c71b96b
--- /dev/null
+++ b/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt
@@ -0,0 +1,17 @@
+--TEST--
+ReflectionFunction::isDisabled
+--CREDITS--
+Stefan Koopmanschap <stefan@phpgg.nl>
+TestFest PHP|Tek
+--SKIPIF--
+<?php
+if (!extension_loaded('reflection')) print 'skip';
+?>
+--INI--
+disable_functions=is_file
+--FILE--
+<?php
+$rc = new ReflectionFunction('is_file');
+echo var_dump($rc->isDisabled());
+--EXPECTF--
+bool(true)
diff --git a/ext/reflection/tests/ReflectionMethod_006.phpt b/ext/reflection/tests/ReflectionMethod_006.phpt
new file mode 100644
index 0000000..a516419
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_006.phpt
@@ -0,0 +1,100 @@
+--TEST--
+ReflectionMethod methods - wrong num args
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+
+var_dump(new ReflectionMethod());
+var_dump(new ReflectionMethod('a', 'b', 'c'));
+
+class C {
+ public function f() {}
+}
+
+$rm = new ReflectionMethod('C', 'f');
+
+var_dump($rm->isFinal(1));
+var_dump($rm->isAbstract(1));
+var_dump($rm->isPrivate(1));
+var_dump($rm->isProtected(1));
+var_dump($rm->isPublic(1));
+var_dump($rm->isStatic(1));
+var_dump($rm->isConstructor(1));
+var_dump($rm->isDestructor(1));
+var_dump($rm->getModifiers(1));
+var_dump($rm->isInternal(1));
+var_dump($rm->isUserDefined(1));
+var_dump($rm->getFileName(1));
+var_dump($rm->getStartLine(1));
+var_dump($rm->getEndLine(1));
+var_dump($rm->getStaticVariables(1));
+var_dump($rm->getName(1));
+
+
+?>
+--EXPECTF--
+Warning: ReflectionMethod::__construct() expects exactly 1 parameter, 0 given in %s on line %d
+object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(0) ""
+ ["class"]=>
+ string(0) ""
+}
+
+Warning: ReflectionMethod::__construct() expects exactly 1 parameter, 3 given in %s on line %d
+object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(0) ""
+ ["class"]=>
+ string(0) ""
+}
+
+Warning: ReflectionMethod::isFinal() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::isAbstract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::isPrivate() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::isProtected() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::isPublic() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::isStatic() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::isConstructor() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::isDestructor() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::getModifiers() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionFunctionAbstract::isInternal() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionFunctionAbstract::isUserDefined() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionFunctionAbstract::getFileName() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionFunctionAbstract::getStartLine() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionFunctionAbstract::getEndLine() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionFunctionAbstract::getStaticVariables() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionFunctionAbstract::getName() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
diff --git a/ext/reflection/tests/ReflectionMethod_basic1.phpt b/ext/reflection/tests/ReflectionMethod_basic1.phpt
new file mode 100644
index 0000000..75ab957
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_basic1.phpt
@@ -0,0 +1,298 @@
+--TEST--
+ReflectionMethod class - various methods
+--FILE--
+<?php
+
+function reflectMethod($class, $method) {
+ $methodInfo = new ReflectionMethod($class, $method);
+ echo "**********************************\n";
+ echo "Reflecting on method $class::$method()\n\n";
+ echo "\nisFinal():\n";
+ var_dump($methodInfo->isFinal());
+ echo "\nisAbstract():\n";
+ var_dump($methodInfo->isAbstract());
+ echo "\nisPublic():\n";
+ var_dump($methodInfo->isPublic());
+ echo "\nisPrivate():\n";
+ var_dump($methodInfo->isPrivate());
+ echo "\nisProtected():\n";
+ var_dump($methodInfo->isProtected());
+ echo "\nisStatic():\n";
+ var_dump($methodInfo->isStatic());
+ echo "\nisConstructor():\n";
+ var_dump($methodInfo->isConstructor());
+ echo "\nisDestructor():\n";
+ var_dump($methodInfo->isDestructor());
+ echo "\n**********************************\n";
+}
+
+class TestClass
+{
+ public function foo() {
+ echo "Called foo()\n";
+ }
+
+ static function stat() {
+ echo "Called stat()\n";
+ }
+
+ private function priv() {
+ echo "Called priv()\n";
+ }
+
+ protected function prot() {}
+
+ public function __destruct() {}
+}
+
+class DerivedClass extends TestClass {}
+
+interface TestInterface {
+ public function int();
+}
+
+reflectMethod("DerivedClass", "foo");
+reflectMethod("TestClass", "stat");
+reflectMethod("TestClass", "priv");
+reflectMethod("TestClass", "prot");
+reflectMethod("DerivedClass", "prot");
+reflectMethod("TestInterface", "int");
+reflectMethod("ReflectionProperty", "__construct");
+reflectMethod("TestClass", "__destruct");
+
+?>
+--EXPECT--
+**********************************
+Reflecting on method DerivedClass::foo()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestClass::stat()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(true)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestClass::priv()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(false)
+
+isPrivate():
+bool(true)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestClass::prot()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(false)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(true)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method DerivedClass::prot()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(false)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(true)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestInterface::int()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(true)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method ReflectionProperty::__construct()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(true)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestClass::__destruct()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(true)
+
+**********************************
+
+
diff --git a/ext/reflection/tests/ReflectionMethod_basic2.phpt b/ext/reflection/tests/ReflectionMethod_basic2.phpt
new file mode 100644
index 0000000..c91af67
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_basic2.phpt
@@ -0,0 +1,188 @@
+--TEST--
+ReflectionMethod class __toString() and export() methods
+--FILE--
+<?php
+
+function reflectMethod($class, $method) {
+ $methodInfo = new ReflectionMethod($class, $method);
+ echo "**********************************\n";
+ echo "Reflecting on method $class::$method()\n\n";
+ echo "__toString():\n";
+ var_dump($methodInfo->__toString());
+ echo "\nexport():\n";
+ var_dump(ReflectionMethod::export($class, $method, true));
+ echo "\n**********************************\n";
+}
+
+class TestClass
+{
+ public function foo() {
+ echo "Called foo()\n";
+ }
+
+ static function stat() {
+ echo "Called stat()\n";
+ }
+
+ private function priv() {
+ echo "Called priv()\n";
+ }
+
+ protected function prot() {}
+
+ public function __destruct() {}
+}
+
+class DerivedClass extends TestClass {}
+
+interface TestInterface {
+ public function int();
+}
+
+reflectMethod("DerivedClass", "foo");
+reflectMethod("TestClass", "stat");
+reflectMethod("TestClass", "priv");
+reflectMethod("TestClass", "prot");
+reflectMethod("DerivedClass", "prot");
+reflectMethod("TestInterface", "int");
+reflectMethod("ReflectionProperty", "__construct");
+reflectMethod("TestClass", "__destruct");
+
+?>
+--EXPECTF--
+**********************************
+Reflecting on method DerivedClass::foo()
+
+__toString():
+string(%d) "Method [ <user, inherits TestClass> public method foo ] {
+ @@ %s 16 - 18
+}
+"
+
+export():
+string(%d) "Method [ <user, inherits TestClass> public method foo ] {
+ @@ %s 16 - 18
+}
+"
+
+**********************************
+**********************************
+Reflecting on method TestClass::stat()
+
+__toString():
+string(%d) "Method [ <user> static public method stat ] {
+ @@ %s 20 - 22
+}
+"
+
+export():
+string(%d) "Method [ <user> static public method stat ] {
+ @@ %s 20 - 22
+}
+"
+
+**********************************
+**********************************
+Reflecting on method TestClass::priv()
+
+__toString():
+string(%d) "Method [ <user> private method priv ] {
+ @@ %s 24 - 26
+}
+"
+
+export():
+string(%d) "Method [ <user> private method priv ] {
+ @@ %s 24 - 26
+}
+"
+
+**********************************
+**********************************
+Reflecting on method TestClass::prot()
+
+__toString():
+string(%d) "Method [ <user> protected method prot ] {
+ @@ %s 28 - 28
+}
+"
+
+export():
+string(%d) "Method [ <user> protected method prot ] {
+ @@ %s 28 - 28
+}
+"
+
+**********************************
+**********************************
+Reflecting on method DerivedClass::prot()
+
+__toString():
+string(%d) "Method [ <user, inherits TestClass> protected method prot ] {
+ @@ %s 28 - 28
+}
+"
+
+export():
+string(%d) "Method [ <user, inherits TestClass> protected method prot ] {
+ @@ %s 28 - 28
+}
+"
+
+**********************************
+**********************************
+Reflecting on method TestInterface::int()
+
+__toString():
+string(%d) "Method [ <user> abstract public method int ] {
+ @@ %s 36 - 36
+}
+"
+
+export():
+string(%d) "Method [ <user> abstract public method int ] {
+ @@ %s 36 - 36
+}
+"
+
+**********************************
+**********************************
+Reflecting on method ReflectionProperty::__construct()
+
+__toString():
+string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
+
+ - Parameters [2] {
+ Parameter #0 [ <required> $class ]
+ Parameter #1 [ <required> $name ]
+ }
+}
+"
+
+export():
+string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
+
+ - Parameters [2] {
+ Parameter #0 [ <required> $class ]
+ Parameter #1 [ <required> $name ]
+ }
+}
+"
+
+**********************************
+**********************************
+Reflecting on method TestClass::__destruct()
+
+__toString():
+string(%d) "Method [ <user, dtor> public method __destruct ] {
+ @@ %s 30 - 30
+}
+"
+
+export():
+string(%d) "Method [ <user, dtor> public method __destruct ] {
+ @@ %s 30 - 30
+}
+"
+
+**********************************
diff --git a/ext/reflection/tests/ReflectionMethod_basic3.phpt b/ext/reflection/tests/ReflectionMethod_basic3.phpt
new file mode 100644
index 0000000..7b65927
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_basic3.phpt
@@ -0,0 +1,167 @@
+--TEST--
+ReflectionMethod class getName(), isInternal() and isUserDefined() methods
+--FILE--
+<?php
+
+function reflectMethod($class, $method) {
+ $methodInfo = new ReflectionMethod($class, $method);
+ echo "**********************************\n";
+ echo "Reflecting on method $class::$method()\n\n";
+ echo "\ngetName():\n";
+ var_dump($methodInfo->getName());
+ echo "\nisInternal():\n";
+ var_dump($methodInfo->isInternal());
+ echo "\nisUserDefined():\n";
+ var_dump($methodInfo->isUserDefined());
+ echo "\n**********************************\n";
+}
+
+class TestClass
+{
+ public function foo() {
+ echo "Called foo()\n";
+ }
+
+ static function stat() {
+ echo "Called stat()\n";
+ }
+
+ private function priv() {
+ echo "Called priv()\n";
+ }
+
+ protected function prot() {}
+
+ public function __destruct() {}
+}
+
+class DerivedClass extends TestClass {}
+
+interface TestInterface {
+ public function int();
+}
+
+reflectMethod("DerivedClass", "foo");
+reflectMethod("TestClass", "stat");
+reflectMethod("TestClass", "priv");
+reflectMethod("TestClass", "prot");
+reflectMethod("DerivedClass", "prot");
+reflectMethod("TestInterface", "int");
+reflectMethod("ReflectionProperty", "__construct");
+reflectMethod("TestClass", "__destruct");
+
+
+?>
+--EXPECT--
+**********************************
+Reflecting on method DerivedClass::foo()
+
+
+getName():
+string(3) "foo"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method TestClass::stat()
+
+
+getName():
+string(4) "stat"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method TestClass::priv()
+
+
+getName():
+string(4) "priv"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method TestClass::prot()
+
+
+getName():
+string(4) "prot"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method DerivedClass::prot()
+
+
+getName():
+string(4) "prot"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method TestInterface::int()
+
+
+getName():
+string(3) "int"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method ReflectionProperty::__construct()
+
+
+getName():
+string(11) "__construct"
+
+isInternal():
+bool(true)
+
+isUserDefined():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestClass::__destruct()
+
+
+getName():
+string(10) "__destruct"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
diff --git a/ext/reflection/tests/ReflectionMethod_basic4.phpt b/ext/reflection/tests/ReflectionMethod_basic4.phpt
new file mode 100644
index 0000000..82672e4
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_basic4.phpt
@@ -0,0 +1,170 @@
+--TEST--
+ReflectionMethod class getFileName(), getStartLine() and getEndLine() methods
+--FILE--
+<?php
+
+function reflectMethod($class, $method) {
+ $methodInfo = new ReflectionMethod($class, $method);
+ echo "**********************************\n";
+ echo "Reflecting on method $class::$method()\n\n";
+ echo "\ngetFileName():\n";
+ var_dump($methodInfo->getFileName());
+ echo "\ngetStartLine():\n";
+ var_dump($methodInfo->getStartLine());
+ echo "\ngetEndLine():\n";
+ var_dump($methodInfo->getEndLine());
+ echo "\n**********************************\n";
+}
+
+class TestClass
+{
+ public function foo() {
+
+
+ echo "Called foo()\n";
+
+
+ }
+
+ static function stat() {
+ echo "Called stat()\n";
+ }
+
+ private function priv() {
+ echo "Called priv()\n";
+ }
+
+ protected function prot() {}
+
+ public function __destruct() {}
+}
+
+class DerivedClass extends TestClass {}
+
+interface TestInterface {
+ public function int();
+}
+
+reflectMethod("DerivedClass", "foo");
+reflectMethod("TestClass", "stat");
+reflectMethod("TestClass", "priv");
+reflectMethod("TestClass", "prot");
+reflectMethod("DerivedClass", "prot");
+reflectMethod("TestInterface", "int");
+reflectMethod("ReflectionProperty", "__construct");
+reflectMethod("TestClass", "__destruct");
+
+?>
+--EXPECTF--
+**********************************
+Reflecting on method DerivedClass::foo()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(18)
+
+getEndLine():
+int(24)
+
+**********************************
+**********************************
+Reflecting on method TestClass::stat()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(26)
+
+getEndLine():
+int(28)
+
+**********************************
+**********************************
+Reflecting on method TestClass::priv()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(30)
+
+getEndLine():
+int(32)
+
+**********************************
+**********************************
+Reflecting on method TestClass::prot()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(34)
+
+getEndLine():
+int(34)
+
+**********************************
+**********************************
+Reflecting on method DerivedClass::prot()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(34)
+
+getEndLine():
+int(34)
+
+**********************************
+**********************************
+Reflecting on method TestInterface::int()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(42)
+
+getEndLine():
+int(42)
+
+**********************************
+**********************************
+Reflecting on method ReflectionProperty::__construct()
+
+
+getFileName():
+bool(false)
+
+getStartLine():
+bool(false)
+
+getEndLine():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestClass::__destruct()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(36)
+
+getEndLine():
+int(36)
+
+**********************************
diff --git a/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt b/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt
new file mode 100644
index 0000000..2a2f02f
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt
@@ -0,0 +1,117 @@
+--TEST--
+ReflectionMethod::isConstructor()
+--FILE--
+<?php
+
+class NewCtor {
+ function __construct() {
+ echo "In " . __METHOD__ . "\n";
+ }
+
+}
+echo "New-style constructor:\n";
+$methodInfo = new ReflectionMethod("NewCtor::__construct");
+var_dump($methodInfo->isConstructor());
+
+class ExtendsNewCtor extends NewCtor {
+}
+echo "\nInherited new-style constructor\n";
+$methodInfo = new ReflectionMethod("ExtendsNewCtor::__construct");
+var_dump($methodInfo->isConstructor());
+
+class OldCtor {
+ function OldCtor() {
+ echo "In " . __METHOD__ . "\n";
+ }
+}
+echo "\nOld-style constructor:\n";
+$methodInfo = new ReflectionMethod("OldCtor::OldCtor");
+var_dump($methodInfo->isConstructor());
+
+class ExtendsOldCtor extends OldCtor {
+}
+echo "\nInherited old-style constructor:\n";
+$methodInfo = new ReflectionMethod("ExtendsOldCtor::OldCtor");
+var_dump($methodInfo->isConstructor());
+
+class X {
+ function Y() {
+ echo "In " . __METHOD__ . "\n";
+ }
+}
+echo "\nNot a constructor:\n";
+$methodInfo = new ReflectionMethod("X::Y");
+var_dump($methodInfo->isConstructor());
+
+class Y extends X {
+}
+echo "\nInherited method of the same name as the class:\n";
+$methodInfo = new ReflectionMethod("Y::Y");
+var_dump($methodInfo->isConstructor());
+
+class OldAndNewCtor {
+ function OldAndNewCtor() {
+ echo "In " . __METHOD__ . "\n";
+ }
+
+ function __construct() {
+ echo "In " . __METHOD__ . "\n";
+ }
+}
+echo "\nOld-style constructor:\n";
+$methodInfo = new ReflectionMethod("OldAndNewCtor::OldAndNewCtor");
+var_dump($methodInfo->isConstructor());
+
+echo "\nRedefined constructor:\n";
+$methodInfo = new ReflectionMethod("OldAndNewCtor::__construct");
+var_dump($methodInfo->isConstructor());
+
+class NewAndOldCtor {
+ function __construct() {
+ echo "In " . __METHOD__ . "\n";
+ }
+
+ function NewAndOldCtor() {
+ echo "In " . __METHOD__ . "\n";
+ }
+}
+echo "\nNew-style constructor:\n";
+$methodInfo = new ReflectionMethod("NewAndOldCtor::__construct");
+var_dump($methodInfo->isConstructor());
+
+echo "\nRedefined old-style constructor:\n";
+$methodInfo = new ReflectionMethod("NewAndOldCtor::NewAndOldCtor");
+var_dump($methodInfo->isConstructor());
+
+?>
+--EXPECTF--
+Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line %d
+New-style constructor:
+bool(true)
+
+Inherited new-style constructor
+bool(true)
+
+Old-style constructor:
+bool(true)
+
+Inherited old-style constructor:
+bool(true)
+
+Not a constructor:
+bool(false)
+
+Inherited method of the same name as the class:
+bool(false)
+
+Old-style constructor:
+bool(false)
+
+Redefined constructor:
+bool(true)
+
+New-style constructor:
+bool(true)
+
+Redefined old-style constructor:
+bool(false)
diff --git a/ext/reflection/tests/ReflectionMethod_constructor_error1.phpt b/ext/reflection/tests/ReflectionMethod_constructor_error1.phpt
new file mode 100644
index 0000000..7052825
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_constructor_error1.phpt
@@ -0,0 +1,103 @@
+--TEST--
+ReflectionMethod constructor errors
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+
+class TestClass
+{
+ public function foo() {
+ }
+}
+
+
+try {
+ echo "\nWrong type of argument (bool):\n";
+ $methodInfo = new ReflectionMethod(true);
+} catch (Exception $e) {
+ print $e->__toString();
+}
+try {
+ echo "\nWrong type of argument (int):\n";
+ $methodInfo = new ReflectionMethod(3);
+} catch (Exception $e) {
+ print $e->__toString();
+}
+try {
+ echo "\nWrong type of argument (bool, string):\n";
+ $methodInfo = new ReflectionMethod(true, "foo");
+} catch (Exception $e) {
+ print $e->__toString();
+}
+try {
+ echo "\nWrong type of argument (string, bool):\n";
+ $methodInfo = new ReflectionMethod('TestClass', true);
+} catch (Exception $e) {
+ print $e->__toString();
+}
+try {
+ echo "\nNo method given:\n";
+ $methodInfo = new ReflectionMethod("TestClass");
+} catch (Exception $e) {
+ print $e->__toString();
+}
+try {
+ echo "\nClass and Method in same string, bad method name:\n";
+ $methodInfo = new ReflectionMethod("TestClass::foop::dedoop");
+} catch (Exception $e) {
+ print $e->__toString();
+}
+try {
+ echo "\nClass and Method in same string, bad class name:\n";
+ $methodInfo = new ReflectionMethod("TestCla::foo");
+} catch (Exception $e) {
+ print $e->__toString();
+}
+try {
+ echo "\nClass and Method in same string (ok):\n";
+ $methodInfo = new ReflectionMethod("TestClass::foo");
+} catch (Exception $e) {
+ print $e->__toString();
+}
+
+?>
+--EXPECTF--
+Wrong type of argument (bool):
+exception 'ReflectionException' with message 'Invalid method name 1' in %s
+Stack trace:
+#0 %s ReflectionMethod->__construct('1')
+#1 {main}
+Wrong type of argument (int):
+exception 'ReflectionException' with message 'Invalid method name 3' in %s
+Stack trace:
+#0 %s ReflectionMethod->__construct('3')
+#1 {main}
+Wrong type of argument (bool, string):
+exception 'ReflectionException' with message 'The parameter class is expected to be either a string or an object' in %s
+Stack trace:
+#0 %s ReflectionMethod->__construct(true, 'foo')
+#1 {main}
+Wrong type of argument (string, bool):
+exception 'ReflectionException' with message 'Method TestClass::1() does not exist' in %s
+Stack trace:
+#0 %s ReflectionMethod->__construct('TestClass', '1')
+#1 {main}
+No method given:
+exception 'ReflectionException' with message 'Invalid method name TestClass' in %s
+Stack trace:
+#0 %s ReflectionMethod->__construct('TestClass')
+#1 {main}
+Class and Method in same string, bad method name:
+exception 'ReflectionException' with message 'Method TestClass::foop::dedoop() does not exist' in %s
+Stack trace:
+#0 %s ReflectionMethod->__construct('TestClass::foop...')
+#1 {main}
+Class and Method in same string, bad class name:
+exception 'ReflectionException' with message 'Class TestCla does not exist' in %s
+Stack trace:
+#0 %s ReflectionMethod->__construct('TestCla::foo')
+#1 {main}
+Class and Method in same string (ok):
+
diff --git a/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt b/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt
new file mode 100644
index 0000000..1c2d3a1
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt
@@ -0,0 +1,37 @@
+--TEST--
+ReflectionMethod constructor errors
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+
+class TestClass
+{
+ public function foo() {
+ }
+}
+
+
+try {
+ echo "Too few arguments:\n";
+ $methodInfo = new ReflectionMethod();
+} catch (Exception $e) {
+ print $e->__toString();
+}
+try {
+ echo "\nToo many arguments:\n";
+ $methodInfo = new ReflectionMethod("TestClass", "foo", true);
+} catch (Exception $e) {
+ print $e->__toString();
+}
+
+?>
+--EXPECTF--
+Too few arguments:
+
+Warning: ReflectionMethod::__construct() expects exactly 1 parameter, 0 given in %s on line 12
+
+Too many arguments:
+
+Warning: ReflectionMethod::__construct() expects exactly 1 parameter, 3 given in %s on line 18
diff --git a/ext/reflection/tests/ReflectionMethod_getClosureThis.phpt b/ext/reflection/tests/ReflectionMethod_getClosureThis.phpt
new file mode 100644
index 0000000..58c0999
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getClosureThis.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Reflection::getClosureThis()
+--SKIPIF--
+<?php
+if (!extension_loaded('reflection') || !defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) {
+ print 'skip';
+}
+?>
+--FILE--
+<?php
+class StaticExample
+{
+ static function foo()
+ {
+ var_dump( "Static Example class, Hello World!" );
+ }
+}
+
+class Example
+{
+ public $bar = 42;
+ public function foo()
+ {
+ var_dump( "Example class, bar: " . $this->bar );
+ }
+}
+
+// Initialize classes
+$class = new ReflectionClass( 'Example' );
+$staticclass = new ReflectionClass( 'StaticExample' );
+$object = new Example();
+
+$method = $staticclass->getMethod( 'foo' );
+$closure = $method->getClosure();
+$rf = new ReflectionFunction($closure);
+
+var_dump($rf->getClosureThis());
+
+$method = $class->getMethod( 'foo' );
+
+$closure = $method->getClosure( $object );
+$rf = new ReflectionFunction($closure);
+
+var_dump($rf->getClosureThis());
+
+echo "Done!\n";
+--EXPECTF--
+NULL
+object(Example)#%d (1) {
+ ["bar"]=>
+ int(42)
+}
+Done!
diff --git a/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt b/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt
new file mode 100644
index 0000000..c97c41c
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Test ReflectionMethod::getClosure() function : basic functionality
+--FILE--
+<?php
+/* Prototype : public mixed ReflectionFunction::getClosure()
+ * Description: Returns a dynamically created closure for the method
+ * Source code: ext/reflection/php_reflection.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ReflectionMethod::getClosure() : basic functionality ***\n";
+
+class StaticExample
+{
+ static function foo()
+ {
+ var_dump( "Static Example class, Hello World!" );
+ }
+}
+
+class Example
+{
+ public $bar = 42;
+ public function foo()
+ {
+ var_dump( "Example class, bar: " . $this->bar );
+ }
+}
+
+// Initialize classes
+$class = new ReflectionClass( 'Example' );
+$staticclass = new ReflectionClass( 'StaticExample' );
+$object = new Example();
+$fakeobj = new StdClass();
+
+
+$method = $staticclass->getMethod( 'foo' );
+$closure = $method->getClosure();
+$closure();
+
+$method = $class->getMethod( 'foo' );
+
+$closure = $method->getClosure( $object );
+$closure();
+$object->bar = 34;
+$closure();
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing ReflectionMethod::getClosure() : basic functionality ***
+string(34) "Static Example class, Hello World!"
+string(22) "Example class, bar: 42"
+string(22) "Example class, bar: 34"
+===DONE===
diff --git a/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt b/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt
new file mode 100644
index 0000000..d3b9ca3
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt
@@ -0,0 +1,73 @@
+--TEST--
+Test ReflectionMethod::getClosure() function : error functionality
+--FILE--
+<?php
+/* Prototype : public mixed ReflectionFunction::getClosure()
+ * Description: Returns a dynamically created closure for the method
+ * Source code: ext/reflection/php_reflection.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ReflectionMethod::getClosure() : error conditions ***\n";
+
+class StaticExample
+{
+ static function foo()
+ {
+ var_dump( "Static Example class, Hello World!" );
+ }
+}
+
+class Example
+{
+ public $bar = 42;
+ public function foo()
+ {
+ var_dump( "Example class, bar: " . $this->bar );
+ }
+}
+
+// Initialize classes
+$class = new ReflectionClass( 'Example' );
+$staticclass = new ReflectionClass( 'StaticExample' );
+$method = $class->getMethod( 'foo' );
+$staticmethod = $staticclass->getMethod( 'foo' );
+$object = new Example();
+$fakeobj = new StdClass();
+
+echo "\n-- Testing ReflectionMethod::getClosure() function with more than expected no. of arguments --\n";
+var_dump( $staticmethod->getClosure( 'foobar' ) );
+var_dump( $staticmethod->getClosure( 'foo', 'bar' ) );
+var_dump( $method->getClosure( $object, 'foobar' ) );
+
+echo "\n-- Testing ReflectionMethod::getClosure() function with Zero arguments --\n";
+$closure = $method->getClosure();
+
+echo "\n-- Testing ReflectionMethod::getClosure() function with Zero arguments --\n";
+try {
+ var_dump( $method->getClosure( $fakeobj ) );
+} catch( Exception $e ) {
+ var_dump( $e->getMessage() );
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing ReflectionMethod::getClosure() : error conditions ***
+
+-- Testing ReflectionMethod::getClosure() function with more than expected no. of arguments --
+object(Closure)#%d (0) {
+}
+object(Closure)#%d (0) {
+}
+
+Warning: ReflectionMethod::getClosure() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+-- Testing ReflectionMethod::getClosure() function with Zero arguments --
+
+Warning: ReflectionMethod::getClosure() expects exactly 1 parameter, 0 given in %s on line %d
+
+-- Testing ReflectionMethod::getClosure() function with Zero arguments --
+string(72) "Given object is not an instance of the class this method was declared in"
+===DONE===
diff --git a/ext/reflection/tests/ReflectionMethod_getDeclaringClass_basic.phpt b/ext/reflection/tests/ReflectionMethod_getDeclaringClass_basic.phpt
new file mode 100644
index 0000000..6afc700
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getDeclaringClass_basic.phpt
@@ -0,0 +1,30 @@
+--TEST--
+ReflectionMethod::getDeclaringClass()
+--FILE--
+<?php
+
+class A {
+ function foo() {}
+}
+
+class B extends A {
+ function bar() {}
+}
+
+$methodInfo = new ReflectionMethod('B', 'foo');
+var_dump($methodInfo->getDeclaringClass());
+
+$methodInfo = new ReflectionMethod('B', 'bar');
+var_dump($methodInfo->getDeclaringClass());
+
+?>
+--EXPECTF--
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(1) "A"
+}
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(1) "B"
+}
+
diff --git a/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt b/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt
new file mode 100644
index 0000000..c01f689
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt
@@ -0,0 +1,113 @@
+--TEST--
+ReflectionMethod::getDocComment()
+--FILE--
+<?php
+/**
+ * My Doc Comment for A
+ */
+class A {
+ /**
+ * My Doc Comment for A::f
+ */
+ function f() {}
+
+ /**
+ * My Doc Comment for A::privf
+ */
+ private function privf() {}
+
+ /** My Doc Comment for A::protStatf */
+ protected static function protStatf() {}
+
+ /**
+
+ * My Doc Comment for A::finalStatPubf
+ */
+ final static public function finalStatPubf() {}
+
+}
+
+
+class B extends A {
+ /*** Not a doc comment */
+ function f() {}
+
+ /** *
+ * My Doc Comment for B::privf
+ */
+
+
+
+
+ private function privf() {}
+
+
+ /** My Doc Comment for B::protStatf
+
+
+
+
+ */
+ protected static function protStatf() {}
+
+}
+
+foreach (array('A', 'B') as $class) {
+ $rc = new ReflectionClass($class);
+ $rms = $rc->getMethods();
+ foreach ($rms as $rm) {
+ echo "\n\n---> Doc comment for $class::" . $rm->getName() . "():\n";
+ var_dump($rm->getDocComment());
+ }
+}
+?>
+--EXPECTF--
+
+
+---> Doc comment for A::f():
+string(%d) "/**
+ * My Doc Comment for A::f
+ */"
+
+
+---> Doc comment for A::privf():
+string(%d) "/**
+ * My Doc Comment for A::privf
+ */"
+
+
+---> Doc comment for A::protStatf():
+string(%d) "/** My Doc Comment for A::protStatf */"
+
+
+---> Doc comment for A::finalStatPubf():
+string(%d) "/**
+
+ * My Doc Comment for A::finalStatPubf
+ */"
+
+
+---> Doc comment for B::f():
+bool(false)
+
+
+---> Doc comment for B::privf():
+string(%d) "/** *
+ * My Doc Comment for B::privf
+ */"
+
+
+---> Doc comment for B::protStatf():
+string(%d) "/** My Doc Comment for B::protStatf
+
+
+
+
+ */"
+
+
+---> Doc comment for B::finalStatPubf():
+string(%d) "/**
+
+ * My Doc Comment for A::finalStatPubf
+ */"
diff --git a/ext/reflection/tests/ReflectionMethod_getDocComment_error.phpt b/ext/reflection/tests/ReflectionMethod_getDocComment_error.phpt
new file mode 100644
index 0000000..02de25b
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getDocComment_error.phpt
@@ -0,0 +1,15 @@
+--TEST--
+ReflectionMethod::getDocComment() errors
+--FILE--
+<?php
+class C { function f() {} }
+$rc = new ReflectionMethod('C::f');
+var_dump($rc->getDocComment(null));
+var_dump($rc->getDocComment('X'));
+?>
+--EXPECTF--
+Warning: ReflectionFunctionAbstract::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionFunctionAbstract::getDocComment() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
diff --git a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt
new file mode 100644
index 0000000..72baa53
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt
@@ -0,0 +1,242 @@
+--TEST--
+ReflectionMethod::getModifiers()
+--FILE--
+<?php
+
+function reflectMethodModifiers($class) {
+ $classInfo = new reflectionClass($class);
+ $methodArray = $classInfo->getMethods();
+
+ foreach ($methodArray as $method) {
+ echo "Modifiers for method $method->class::$method->name():\n";
+ printf("0x%08x\n", $method->getModifiers());
+ echo "\n\n";
+ }
+}
+
+class TestClass
+{
+ public function foo() {
+ echo "Called foo()\n";
+ }
+
+ static function stat() {
+ echo "Called stat()\n";
+ }
+
+ private function priv() {
+ echo "Called priv()\n";
+ }
+
+ protected function prot() {}
+
+ public final function fin() {}
+
+ public function __destruct() {}
+
+ public function __call($a, $b) {}
+
+ public function __clone() {}
+
+ public function __get($a) {}
+
+ public function __set($a, $b) {}
+
+ public function __unset($a) {}
+
+ public function __isset($a) {}
+
+ public function __tostring() {}
+
+ public function __sleep() {}
+
+ public function __wakeup() {}
+
+ public function __set_state() {}
+
+ public function __autoload() {}
+}
+
+class DerivedClass extends TestClass {}
+
+interface TestInterface {
+ public function int();
+ public function __clone();
+}
+
+abstract class AbstractClass {
+ public abstract function foo();
+}
+
+
+
+reflectMethodModifiers("TestClass");
+reflectMethodModifiers("DerivedClass");
+reflectMethodModifiers("TestInterface");
+reflectMethodModifiers("AbstractClass");
+
+echo "Wrong number of params:\n";
+$a = new ReflectionMethod('TestClass::foo');
+$a->getModifiers(1);
+
+$a = new ReflectionMethod('ReflectionMethod::getModifiers');
+
+echo "\nReflectionMethod::getModifiers() modifiers:\n";
+printf("0x%08x\n", $a->getModifiers());
+
+?>
+--EXPECTF--
+Modifiers for method TestClass::foo():
+0x08010100
+
+
+Modifiers for method TestClass::stat():
+0x08000101
+
+
+Modifiers for method TestClass::priv():
+0x08010400
+
+
+Modifiers for method TestClass::prot():
+0x08010200
+
+
+Modifiers for method TestClass::fin():
+0x08010104
+
+
+Modifiers for method TestClass::__destruct():
+0x08004100
+
+
+Modifiers for method TestClass::__call():
+0x08000100
+
+
+Modifiers for method TestClass::__clone():
+0x08008100
+
+
+Modifiers for method TestClass::__get():
+0x08000100
+
+
+Modifiers for method TestClass::__set():
+0x08000100
+
+
+Modifiers for method TestClass::__unset():
+0x08000100
+
+
+Modifiers for method TestClass::__isset():
+0x08000100
+
+
+Modifiers for method TestClass::__tostring():
+0x08000100
+
+
+Modifiers for method TestClass::__sleep():
+0x08010100
+
+
+Modifiers for method TestClass::__wakeup():
+0x08010100
+
+
+Modifiers for method TestClass::__set_state():
+0x08010100
+
+
+Modifiers for method TestClass::__autoload():
+0x08010100
+
+
+Modifiers for method TestClass::foo():
+0x08010100
+
+
+Modifiers for method TestClass::stat():
+0x08000101
+
+
+Modifiers for method TestClass::priv():
+0x08010400
+
+
+Modifiers for method TestClass::prot():
+0x08010200
+
+
+Modifiers for method TestClass::fin():
+0x08010104
+
+
+Modifiers for method TestClass::__destruct():
+0x08004100
+
+
+Modifiers for method TestClass::__call():
+0x08000100
+
+
+Modifiers for method TestClass::__clone():
+0x08008100
+
+
+Modifiers for method TestClass::__get():
+0x08000100
+
+
+Modifiers for method TestClass::__set():
+0x08000100
+
+
+Modifiers for method TestClass::__unset():
+0x08000100
+
+
+Modifiers for method TestClass::__isset():
+0x08000100
+
+
+Modifiers for method TestClass::__tostring():
+0x08000100
+
+
+Modifiers for method TestClass::__sleep():
+0x08010100
+
+
+Modifiers for method TestClass::__wakeup():
+0x08010100
+
+
+Modifiers for method TestClass::__set_state():
+0x08010100
+
+
+Modifiers for method TestClass::__autoload():
+0x08010100
+
+
+Modifiers for method TestInterface::int():
+0x08000102
+
+
+Modifiers for method TestInterface::__clone():
+0x08000102
+
+
+Modifiers for method AbstractClass::foo():
+0x08010102
+
+
+Wrong number of params:
+
+Warning: ReflectionMethod::getModifiers() expects exactly 0 parameters, 1 given in %sReflectionMethod_getModifiers_basic.php on line %d
+
+ReflectionMethod::getModifiers() modifiers:
+0x00000100
diff --git a/ext/reflection/tests/ReflectionMethod_getStaticVariables_basic.phpt b/ext/reflection/tests/ReflectionMethod_getStaticVariables_basic.phpt
new file mode 100644
index 0000000..4c50b96
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getStaticVariables_basic.phpt
@@ -0,0 +1,63 @@
+--TEST--
+ReflectionMethod::getStaticVariables()
+--FILE--
+<?php
+
+class TestClass {
+ public function foo() {
+ static $c;
+ static $a = 1;
+ static $b = "hello";
+ $d = 5;
+ }
+
+ private function bar() {
+ static $a = 1;
+ }
+
+ public function noStatics() {
+ $a = 54;
+ }
+}
+
+echo "Public method:\n";
+$methodInfo = new ReflectionMethod('TestClass::foo');
+var_dump($methodInfo->getStaticVariables());
+
+echo "\nPrivate method:\n";
+$methodInfo = new ReflectionMethod('TestClass::bar');
+var_dump($methodInfo->getStaticVariables());
+
+echo "\nMethod with no static variables:\n";
+$methodInfo = new ReflectionMethod('TestClass::noStatics');
+var_dump($methodInfo->getStaticVariables());
+
+echo "\nInternal Method:\n";
+$methodInfo = new ReflectionMethod('ReflectionClass::getName');
+var_dump($methodInfo->getStaticVariables());
+
+?>
+--EXPECT--
+Public method:
+array(3) {
+ ["c"]=>
+ NULL
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ string(5) "hello"
+}
+
+Private method:
+array(1) {
+ ["a"]=>
+ int(1)
+}
+
+Method with no static variables:
+array(0) {
+}
+
+Internal Method:
+array(0) {
+}
diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_basic.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_basic.phpt
new file mode 100644
index 0000000..24282cd
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_basic.phpt
@@ -0,0 +1,73 @@
+--TEST--
+ReflectionMethod::invokeArgs()
+--FILE--
+<?php
+
+class TestClass {
+ public $prop = 2;
+
+ public function foo() {
+ echo "Called foo(), property = $this->prop\n";
+ var_dump($this);
+ return "Return Val";
+ }
+
+ public function willThrow() {
+ throw new Exception("Called willThrow()");
+ }
+
+ public function methodWithArgs($a, $b) {
+ echo "Called methodWithArgs($a, $b)\n";
+ }
+}
+
+
+$testClassInstance = new TestClass();
+$testClassInstance->prop = "Hello";
+
+$foo = new ReflectionMethod($testClassInstance, 'foo');
+$methodWithArgs = new ReflectionMethod('TestClass', 'methodWithArgs');
+$methodThatThrows = new ReflectionMethod("TestClass::willThrow");
+
+
+echo "Public method:\n";
+
+var_dump($foo->invokeArgs($testClassInstance, array()));
+var_dump($foo->invokeArgs($testClassInstance, array(true)));
+
+echo "\nMethod with args:\n";
+
+var_dump($methodWithArgs->invokeArgs($testClassInstance, array(1, "arg2")));
+var_dump($methodWithArgs->invokeArgs($testClassInstance, array(1, "arg2", 3)));
+
+echo "\nMethod that throws an exception:\n";
+try {
+ $methodThatThrows->invokeArgs($testClassInstance, array());
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+Public method:
+Called foo(), property = Hello
+object(TestClass)#%d (1) {
+ ["prop"]=>
+ string(5) "Hello"
+}
+string(10) "Return Val"
+Called foo(), property = Hello
+object(TestClass)#%d (1) {
+ ["prop"]=>
+ string(5) "Hello"
+}
+string(10) "Return Val"
+
+Method with args:
+Called methodWithArgs(1, arg2)
+NULL
+Called methodWithArgs(1, arg2)
+NULL
+
+Method that throws an exception:
+string(18) "Called willThrow()"
diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt
new file mode 100644
index 0000000..ac97e3e
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt
@@ -0,0 +1,36 @@
+--TEST--
+ReflectionMethod:invokeArgs() errors
+--FILE--
+<?php
+
+class TestClass {
+
+ public function methodWithArgs($a, $b) {
+ echo "Called methodWithArgs($a, $b)\n";
+ }
+}
+
+abstract class AbstractClass {
+ abstract function foo();
+}
+
+$methodWithArgs = new ReflectionMethod('TestClass', 'methodWithArgs');
+
+$testClassInstance = new TestClass();
+
+echo "\nMethod with args:\n";
+var_dump($methodWithArgs->invokeArgs($testClassInstance, array()));
+
+?>
+--EXPECTF--
+Method with args:
+
+Warning: Missing argument 1 for TestClass::methodWithArgs() in %s on line %d
+
+Warning: Missing argument 2 for TestClass::methodWithArgs() in %s on line %d
+
+Notice: Undefined variable: a in %s on line %d
+
+Notice: Undefined variable: b in %s on line %d
+Called methodWithArgs(, )
+NULL
diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt
new file mode 100644
index 0000000..5fc7564
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt
@@ -0,0 +1,27 @@
+--TEST--
+ReflectionMethod::invokeArgs() further errors
+--FILE--
+<?php
+
+class TestClass {
+
+ public function foo() {
+ echo "Called foo()\n";
+ var_dump($this);
+ return "Return Val";
+ }
+}
+
+$foo = new ReflectionMethod('TestClass', 'foo');
+
+$testClassInstance = new TestClass();
+
+try {
+ var_dump($foo->invokeArgs($testClassInstance, true));
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+Catchable fatal error: Argument 2 passed to ReflectionMethod::invokeArgs() must be of the type array, boolean given in %s on line %d
diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt
new file mode 100644
index 0000000..513cc18
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt
@@ -0,0 +1,117 @@
+--TEST--
+ReflectionMethod::invokeArgs() further errors
+--FILE--
+<?php
+
+class TestClass {
+ public $prop = 2;
+
+ public function foo() {
+ echo "Called foo(), property = $this->prop\n";
+ var_dump($this);
+ return "Return Val";
+ }
+
+ public static function staticMethod() {
+ echo "Called staticMethod()\n";
+ var_dump($this);
+ }
+
+ private static function privateMethod() {
+ echo "Called privateMethod()\n";
+ }
+}
+
+abstract class AbstractClass {
+ abstract function foo();
+}
+
+$testClassInstance = new TestClass();
+$testClassInstance->prop = "Hello";
+
+$foo = new ReflectionMethod($testClassInstance, 'foo');
+$staticMethod = new ReflectionMethod('TestClass::staticMethod');
+$privateMethod = new ReflectionMethod("TestClass::privateMethod");
+
+echo "Wrong number of parameters:\n";
+var_dump($foo->invokeArgs());
+var_dump($foo->invokeArgs(true));
+
+echo "\nNon-instance:\n";
+try {
+ var_dump($foo->invokeArgs(new stdClass(), array()));
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+echo "\nNon-object:\n";
+var_dump($foo->invokeArgs(true, array()));
+
+echo "\nStatic method:\n";
+
+var_dump($staticMethod->invokeArgs());
+var_dump($staticMethod->invokeArgs(true));
+var_dump($staticMethod->invokeArgs(true, array()));
+var_dump($staticMethod->invokeArgs(null, array()));
+
+echo "\nPrivate method:\n";
+try {
+ var_dump($privateMethod->invokeArgs($testClassInstance, array()));
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+echo "\nAbstract method:\n";
+$abstractMethod = new ReflectionMethod("AbstractClass::foo");
+try {
+ $abstractMethod->invokeArgs($testClassInstance, array());
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+try {
+ $abstractMethod->invokeArgs(true);
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+Wrong number of parameters:
+
+Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Non-instance:
+string(72) "Given object is not an instance of the class this method was declared in"
+
+Non-object:
+
+Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, boolean given in %s on line %d
+NULL
+
+Static method:
+
+Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, boolean given in %s on line %d
+NULL
+Called staticMethod()
+
+Notice: Undefined variable: this in %s on line %d
+NULL
+NULL
+
+Private method:
+string(86) "Trying to invoke private method TestClass::privateMethod() from scope ReflectionMethod"
+
+Abstract method:
+string(53) "Trying to invoke abstract method AbstractClass::foo()"
+
+Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 1 given in %s on line %d
diff --git a/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt b/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt
new file mode 100644
index 0000000..cbf358c
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt
@@ -0,0 +1,108 @@
+--TEST--
+ReflectionMethod::invoke()
+--FILE--
+<?php
+
+class TestClass {
+ public $prop = 2;
+
+ public function foo() {
+ echo "Called foo(), property = $this->prop\n";
+ var_dump($this);
+ return "Return Val";
+ }
+
+ public function willThrow() {
+ throw new Exception("Called willThrow()");
+ }
+
+ public function methodWithArgs($a, $b) {
+ echo "Called methodWithArgs($a, $b)\n";
+ }
+
+ public static function staticMethod() {
+ echo "Called staticMethod()\n";
+ var_dump($this);
+ }
+
+ private static function privateMethod() {
+ echo "Called privateMethod()\n";
+ }
+}
+
+abstract class AbstractClass {
+ abstract function foo();
+}
+
+$foo = new ReflectionMethod('TestClass', 'foo');
+$methodWithArgs = new ReflectionMethod('TestClass', 'methodWithArgs');
+$staticMethod = new ReflectionMethod('TestClass::staticMethod');
+$privateMethod = new ReflectionMethod("TestClass::privateMethod");
+$methodThatThrows = new ReflectionMethod("TestClass::willThrow");
+
+$testClassInstance = new TestClass();
+$testClassInstance->prop = "Hello";
+
+echo "Public method:\n";
+
+var_dump($foo->invoke($testClassInstance));
+
+var_dump($foo->invoke($testClassInstance, true));
+
+echo "\nMethod with args:\n";
+
+var_dump($methodWithArgs->invoke($testClassInstance, 1, "arg2"));
+var_dump($methodWithArgs->invoke($testClassInstance, 1, "arg2", 3));
+
+echo "\nStatic method:\n";
+
+var_dump($staticMethod->invoke());
+var_dump($staticMethod->invoke(true));
+var_dump($staticMethod->invoke(new stdClass()));
+
+echo "\nMethod that throws an exception:\n";
+try {
+ var_dump($methodThatThrows->invoke($testClassInstance));
+} catch (Exception $exc) {
+ var_dump($exc->getMessage());
+}
+
+?>
+--EXPECTF--
+Public method:
+Called foo(), property = Hello
+object(TestClass)#%d (1) {
+ ["prop"]=>
+ string(5) "Hello"
+}
+string(10) "Return Val"
+Called foo(), property = Hello
+object(TestClass)#%d (1) {
+ ["prop"]=>
+ string(5) "Hello"
+}
+string(10) "Return Val"
+
+Method with args:
+Called methodWithArgs(1, arg2)
+NULL
+Called methodWithArgs(1, arg2)
+NULL
+
+Static method:
+
+Warning: ReflectionMethod::invoke() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+Called staticMethod()
+
+Notice: Undefined variable: this in %s on line %d
+NULL
+NULL
+Called staticMethod()
+
+Notice: Undefined variable: this in %s on line %d
+NULL
+NULL
+
+Method that throws an exception:
+string(18) "Called willThrow()"
diff --git a/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt b/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt
new file mode 100644
index 0000000..758f1ac
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt
@@ -0,0 +1,71 @@
+--TEST--
+ReflectionMethod::invoke() errors
+--FILE--
+<?php
+
+class TestClass {
+ public $prop = 2;
+
+ public function foo() {
+ echo "Called foo(), property = $this->prop\n";
+ var_dump($this);
+ return "Return Val";
+ }
+
+ private static function privateMethod() {
+ echo "Called privateMethod()\n";
+ }
+}
+
+abstract class AbstractClass {
+ abstract function foo();
+}
+
+$foo = new ReflectionMethod('TestClass', 'foo');
+$privateMethod = new ReflectionMethod("TestClass::privateMethod");
+
+$testClassInstance = new TestClass();
+$testClassInstance->prop = "Hello";
+
+echo "invoke() on a non-object:\n";
+try {
+ var_dump($foo->invoke(true));
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+echo "\ninvoke() on a non-instance:\n";
+try {
+ var_dump($foo->invoke(new stdClass()));
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+echo "\nPrivate method:\n";
+try {
+ var_dump($privateMethod->invoke($testClassInstance));
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+echo "\nAbstract method:\n";
+$abstractMethod = new ReflectionMethod("AbstractClass::foo");
+try {
+ $abstractMethod->invoke(true);
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+invoke() on a non-object:
+string(29) "Non-object passed to Invoke()"
+
+invoke() on a non-instance:
+string(72) "Given object is not an instance of the class this method was declared in"
+
+Private method:
+string(86) "Trying to invoke private method TestClass::privateMethod() from scope ReflectionMethod"
+
+Abstract method:
+string(53) "Trying to invoke abstract method AbstractClass::foo()"
diff --git a/ext/reflection/tests/ReflectionMethod_invoke_error2.phpt b/ext/reflection/tests/ReflectionMethod_invoke_error2.phpt
new file mode 100644
index 0000000..a070c8f
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invoke_error2.phpt
@@ -0,0 +1,32 @@
+--TEST--
+ReflectionMethod::invoke() further errors
+--FILE--
+<?php
+
+class TestClass {
+
+ public function methodWithArgs($a, $b) {
+ echo "Called methodWithArgs($a, $b)\n";
+ }
+}
+
+$methodWithArgs = new ReflectionMethod('TestClass', 'methodWithArgs');
+
+$testClassInstance = new TestClass();
+
+echo "\nMethod with args:\n";
+var_dump($methodWithArgs->invoke($testClassInstance));
+
+?>
+--EXPECTF--
+Method with args:
+
+Warning: Missing argument 1 for TestClass::methodWithArgs() in %s on line %d
+
+Warning: Missing argument 2 for TestClass::methodWithArgs() in %s on line %d
+
+Notice: Undefined variable: a in %s on line %d
+
+Notice: Undefined variable: b in %s on line %d
+Called methodWithArgs(, )
+NULL
diff --git a/ext/reflection/tests/ReflectionMethod_returnsReference_basic.phpt b/ext/reflection/tests/ReflectionMethod_returnsReference_basic.phpt
new file mode 100644
index 0000000..f1fd205
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_returnsReference_basic.phpt
@@ -0,0 +1,23 @@
+--TEST--
+ReflectionMethod::returnsReference()
+--FILE--
+<?php
+
+class TestClass {
+ public function &foo() {
+ }
+
+ private function bar() {
+ }
+}
+
+$methodInfo = new ReflectionMethod('TestClass::foo');
+var_dump($methodInfo->returnsReference());
+
+$methodInfo = new ReflectionMethod('TestClass::bar');
+var_dump($methodInfo->returnsReference());
+
+?>
+--EXPECT--
+bool(true)
+bool(false)
diff --git a/ext/reflection/tests/ReflectionMethod_setAccessible.phpt b/ext/reflection/tests/ReflectionMethod_setAccessible.phpt
new file mode 100644
index 0000000..79a8fbe
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_setAccessible.phpt
@@ -0,0 +1,111 @@
+--TEST--
+Test ReflectionMethod::setAccessible().
+--FILE--
+<?php
+class A {
+ private function aPrivate($a) { print __METHOD__ . "\n"; }
+ private static function aPrivateStatic($a) { print __METHOD__ . "\n"; }
+ protected function aProtected($a) { print __METHOD__ . "\n"; }
+ protected static function aProtectedStatic($a) { print __METHOD__ . "\n"; }
+}
+
+$private = new ReflectionMethod('A', 'aPrivate');
+$privateStatic = new ReflectionMethod('A', 'aPrivateStatic');
+$protected = new ReflectionMethod('A', 'aProtected');
+$protectedStatic = new ReflectionMethod('A', 'aProtectedStatic');
+
+try {
+ $private->invoke(new A, NULL);
+}
+
+catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ $private->invokeArgs(new A, array(NULL));
+}
+
+catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ $privateStatic->invoke(NULL, NULL);
+}
+
+catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ $privateStatic->invokeArgs(NULL, array(NULL));
+}
+
+catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ $protected->invoke(new A, NULL);
+}
+
+catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ $protected->invokeArgs(new A, array(NULL));
+}
+
+catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ $protectedStatic->invoke(NULL, NULL);
+}
+
+catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ $protectedStatic->invokeArgs(NULL, array(NULL));
+}
+
+catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+$private->setAccessible(TRUE);
+$privateStatic->setAccessible(TRUE);
+$protected->setAccessible(TRUE);
+$protectedStatic->setAccessible(TRUE);
+
+$private->invoke(new A, NULL);
+$private->invokeArgs(new A, array(NULL));
+$privateStatic->invoke(NULL, NULL);
+$privateStatic->invokeArgs(NULL, array(NULL));
+$protected->invoke(new A, NULL);
+$protected->invokeArgs(new A, array(NULL));
+$protectedStatic->invoke(NULL, NULL);
+$protectedStatic->invokeArgs(NULL, array(NULL));
+?>
+--EXPECT--
+string(73) "Trying to invoke private method A::aPrivate() from scope ReflectionMethod"
+string(73) "Trying to invoke private method A::aPrivate() from scope ReflectionMethod"
+string(79) "Trying to invoke private method A::aPrivateStatic() from scope ReflectionMethod"
+string(79) "Trying to invoke private method A::aPrivateStatic() from scope ReflectionMethod"
+string(77) "Trying to invoke protected method A::aProtected() from scope ReflectionMethod"
+string(77) "Trying to invoke protected method A::aProtected() from scope ReflectionMethod"
+string(83) "Trying to invoke protected method A::aProtectedStatic() from scope ReflectionMethod"
+string(83) "Trying to invoke protected method A::aProtectedStatic() from scope ReflectionMethod"
+A::aPrivate
+A::aPrivate
+A::aPrivateStatic
+A::aPrivateStatic
+A::aProtected
+A::aProtected
+A::aProtectedStatic
+A::aProtectedStatic
diff --git a/ext/reflection/tests/ReflectionObject_FileInfo_basic.phpt b/ext/reflection/tests/ReflectionObject_FileInfo_basic.phpt
new file mode 100644
index 0000000..00214dc
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_FileInfo_basic.phpt
@@ -0,0 +1,25 @@
+--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--
+string(%d) "%sReflectionObject_FileInfo_basic.php"
+int(12)
+int(14)
+bool(false)
+bool(false)
+bool(false)
diff --git a/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt b/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt
new file mode 100644
index 0000000..d30e677
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt
@@ -0,0 +1,37 @@
+--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--
+string(%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
diff --git a/ext/reflection/tests/ReflectionObject___toString_basic1.phpt b/ext/reflection/tests/ReflectionObject___toString_basic1.phpt
new file mode 100644
index 0000000..fefa220
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject___toString_basic1.phpt
@@ -0,0 +1,36 @@
+--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] {
+ }
+} \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionObject___toString_basic2.phpt b/ext/reflection/tests/ReflectionObject___toString_basic2.phpt
new file mode 100644
index 0000000..332386a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject___toString_basic2.phpt
@@ -0,0 +1,39 @@
+--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] {
+ }
+} \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionObject_constructor_basic.phpt b/ext/reflection/tests/ReflectionObject_constructor_basic.phpt
new file mode 100644
index 0000000..8f4a908
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_constructor_basic.phpt
@@ -0,0 +1,28 @@
+--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) {
+ ["name"]=>
+ string(8) "stdClass"
+}
+object(ReflectionObject)#%d (1) {
+ ["name"]=>
+ string(1) "C"
+}
+object(ReflectionObject)#%d (1) {
+ ["name"]=>
+ string(16) "ReflectionObject"
+}
diff --git a/ext/reflection/tests/ReflectionObject_constructor_error.phpt b/ext/reflection/tests/ReflectionObject_constructor_error.phpt
new file mode 100644
index 0000000..baa6129
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_constructor_error.phpt
@@ -0,0 +1,49 @@
+--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) {
+ ["name"]=>
+ string(0) ""
+}
+
+Warning: ReflectionObject::__construct() expects parameter 1 to be object, string given in %s on line 4
+object(ReflectionObject)#%d (1) {
+ ["name"]=>
+ string(0) ""
+}
+
+Warning: ReflectionObject::__construct() expects exactly 1 parameter, 2 given in %s on line 6
+object(ReflectionObject)#%d (1) {
+ ["name"]=>
+ string(0) ""
+}
+
+Warning: ReflectionObject::__construct() expects parameter 1 to be object, integer given in %s on line 7
+object(ReflectionObject)#%d (1) {
+ ["name"]=>
+ string(0) ""
+}
+
+Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in %s on line 8
+object(ReflectionObject)#%d (1) {
+ ["name"]=>
+ string(0) ""
+}
+
+Warning: ReflectionObject::__construct() expects parameter 1 to be object, array given in %s on line 9
+object(ReflectionObject)#%d (1) {
+ ["name"]=>
+ string(0) ""
+}
diff --git a/ext/reflection/tests/ReflectionObject_export_basic1.phpt b/ext/reflection/tests/ReflectionObject_export_basic1.phpt
new file mode 100644
index 0000000..f7dfef8
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_export_basic1.phpt
@@ -0,0 +1,36 @@
+--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] {
+ }
+} \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionObject_export_basic2.phpt b/ext/reflection/tests/ReflectionObject_export_basic2.phpt
new file mode 100644
index 0000000..277f06e
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_export_basic2.phpt
@@ -0,0 +1,39 @@
+--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] {
+ }
+} \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionObject_export_basic3.phpt b/ext/reflection/tests/ReflectionObject_export_basic3.phpt
new file mode 100644
index 0000000..7c1da34
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_export_basic3.phpt
@@ -0,0 +1,38 @@
+--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] {
+ }
+}
+
diff --git a/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt b/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt
new file mode 100644
index 0000000..3d151bc
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt
@@ -0,0 +1,41 @@
+--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:
+string(12) "hello from C"
+bool(false)
+Reflecting on instance of class D:
+string(12) "hello from C"
+bool(false)
+Reflecting on instance of class E:
+string(12) "hello from C"
+bool(false)
+Reflecting on instance of class F:
+string(12) "hello from F"
+bool(false)
+Reflecting on instance of class X:
+bool(false)
+bool(false)
diff --git a/ext/reflection/tests/ReflectionObject_getConstant_error.phpt b/ext/reflection/tests/ReflectionObject_getConstant_error.phpt
new file mode 100644
index 0000000..3f12f3a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_getConstant_error.phpt
@@ -0,0 +1,34 @@
+--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, array given in %s on line 13
+NULL
+
+Warning: ReflectionClass::getConstant() expects parameter 1 to be string, object given in %s on line 14
+NULL
diff --git a/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt b/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt
new file mode 100644
index 0000000..6479ec9
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt
@@ -0,0 +1,49 @@
+--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) {
+ ["a"]=>
+ string(12) "hello from C"
+}
+Reflecting on instance of class D:
+array(1) {
+ ["a"]=>
+ string(12) "hello from C"
+}
+Reflecting on instance of class E:
+array(1) {
+ ["a"]=>
+ string(12) "hello from C"
+}
+Reflecting on instance of class F:
+array(1) {
+ ["a"]=>
+ string(12) "hello from F"
+}
+Reflecting on instance of class X:
+array(0) {
+}
diff --git a/ext/reflection/tests/ReflectionObject_getConstants_error.phpt b/ext/reflection/tests/ReflectionObject_getConstants_error.phpt
new file mode 100644
index 0000000..d3b9080
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_getConstants_error.phpt
@@ -0,0 +1,17 @@
+--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
diff --git a/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt b/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt
new file mode 100644
index 0000000..5a0c36f
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt
@@ -0,0 +1,79 @@
+--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 %d
+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
diff --git a/ext/reflection/tests/ReflectionObject_getConstructor_error.phpt b/ext/reflection/tests/ReflectionObject_getConstructor_error.phpt
new file mode 100644
index 0000000..2f52de2
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_getConstructor_error.phpt
@@ -0,0 +1,23 @@
+--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
diff --git a/ext/reflection/tests/ReflectionObject_getName_basic.phpt b/ext/reflection/tests/ReflectionObject_getName_basic.phpt
new file mode 100644
index 0000000..db0cbfb
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_getName_basic.phpt
@@ -0,0 +1,27 @@
+--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
+string(0) ""
+string(8) "stdClass"
+string(1) "C"
+string(16) "ReflectionObject"
+
diff --git a/ext/reflection/tests/ReflectionObject_getName_error.phpt b/ext/reflection/tests/ReflectionObject_getName_error.phpt
new file mode 100644
index 0000000..ff8e279
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_getName_error.phpt
@@ -0,0 +1,23 @@
+--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
diff --git a/ext/reflection/tests/ReflectionObject_getName_error1.phpt b/ext/reflection/tests/ReflectionObject_getName_error1.phpt
new file mode 100644
index 0000000..26c342d
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_getName_error1.phpt
@@ -0,0 +1,8 @@
+--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
diff --git a/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt b/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt
new file mode 100644
index 0000000..ef605aa
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt
@@ -0,0 +1,33 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionObject_isInstance_error.phpt b/ext/reflection/tests/ReflectionObject_isInstance_error.phpt
new file mode 100644
index 0000000..692c2f8
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_isInstance_error.phpt
@@ -0,0 +1,38 @@
+--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, 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
diff --git a/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt b/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt
new file mode 100644
index 0000000..4b8a6ec
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt
@@ -0,0 +1,36 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt b/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt
new file mode 100644
index 0000000..f993367
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt
@@ -0,0 +1,22 @@
+--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
diff --git a/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt b/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt
new file mode 100644
index 0000000..ac7199c
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt
@@ -0,0 +1,78 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt b/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt
new file mode 100644
index 0000000..066bca7
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt
@@ -0,0 +1,23 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionObject_isInternal_error.phpt b/ext/reflection/tests/ReflectionObject_isInternal_error.phpt
new file mode 100644
index 0000000..996add6
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_isInternal_error.phpt
@@ -0,0 +1,15 @@
+--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
diff --git a/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt b/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt
new file mode 100644
index 0000000..2fb8cb0
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt
@@ -0,0 +1,48 @@
+--TEST--
+ReflectionObject::isSubclassOf() - bad arguments
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class C {}
+$ro = new ReflectionObject(new C);
+
+echo "\n\nTest bad arguments:\n";
+try {
+ var_dump($ro->isSubclassOf());
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($ro->isSubclassOf('C', 'C'));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($ro->isSubclassOf(null));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($ro->isSubclassOf('ThisClassDoesNotExist'));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+try {
+ var_dump($ro->isSubclassOf(2));
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+--EXPECTF--
+Test bad arguments:
+
+Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 0 given in %s on line 7
+NULL
+
+Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 2 given in %s on line 12
+NULL
+Parameter one must either be a string or a ReflectionClass object
+Class ThisClassDoesNotExist does not exist
+Parameter one must either be a string or a ReflectionClass object \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt b/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt
new file mode 100644
index 0000000..e89066a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt
@@ -0,0 +1,116 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt b/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt
new file mode 100644
index 0000000..9387b7d
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt
@@ -0,0 +1,24 @@
+--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
diff --git a/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt b/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt
new file mode 100644
index 0000000..4cb08fc
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt
@@ -0,0 +1,23 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt b/ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt
new file mode 100644
index 0000000..06be47a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionObject_isUserDefined_error.phpt
@@ -0,0 +1,15 @@
+--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
diff --git a/ext/reflection/tests/ReflectionParameter_001.phpt b/ext/reflection/tests/ReflectionParameter_001.phpt
new file mode 100644
index 0000000..dae3ac7
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_001.phpt
@@ -0,0 +1,80 @@
+--TEST--
+ReflectionParameter class - getNames() method.
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class ReflectTestClass {
+ public static function twoArgFunction($theIncrement, $anotherParam) {
+ return ++$theIncrement;
+ }
+
+ public function oneArgNonStatic($theParam) {
+ $theParam--;
+ }
+
+ public function noArgs() {
+ echo "No arg function\n";
+ }
+}
+
+// Create an instance of the Reflection_Method class
+$method = new ReflectionMethod('ReflectTestClass', 'twoArgFunction');
+// Get the parameters
+$parameters = $method->getParameters();
+echo "Parameters from twoArgMethod:\n\n";
+foreach($parameters as $parameter) {
+ var_dump($parameter);
+ $name = $parameter->getName();
+ echo "\n";
+}
+
+$method = new ReflectionMethod('ReflectTestClass', 'oneArgNonStatic');
+$parameters = $method->getParameters();
+echo "Parameters from oneArgNonStatic:\n\n";
+foreach($parameters as $parameter) {
+ var_dump($parameter);
+ $name = $parameter->getName();
+ echo "\n";
+}
+
+
+$method = new ReflectionMethod('ReflectTestClass', 'noArgs');
+$parameters = $method->getParameters();
+echo "Parameters from noArgs:\n\n";
+var_dump($parameters);
+foreach($parameters as $parameter) {
+ var_dump($parameter);
+ $name = $parameter->getName();
+ echo "\n";
+}
+
+echo "done\n";
+
+?>
+--EXPECTF--
+Parameters from twoArgMethod:
+
+object(ReflectionParameter)#%i (1) {
+ ["name"]=>
+ string(12) "theIncrement"
+}
+
+object(ReflectionParameter)#%i (1) {
+ ["name"]=>
+ string(12) "anotherParam"
+}
+
+Parameters from oneArgNonStatic:
+
+object(ReflectionParameter)#%i (1) {
+ ["name"]=>
+ string(8) "theParam"
+}
+
+Parameters from noArgs:
+
+array(0) {
+}
+done \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionParameter_002.phpt b/ext/reflection/tests/ReflectionParameter_002.phpt
new file mode 100644
index 0000000..3b7df6f
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_002.phpt
@@ -0,0 +1,80 @@
+--TEST--
+ReflectionParameter class - isPassedByReferenceMethod()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+class ReflectTestClass {
+ public static function staticMethod(&$paramOne, $anotherParam) {
+ return ++$theIncrement;
+ }
+
+ public function instanceMethod($firstParam, &$secondParam) {
+ $firstParam = "Hello\n";
+ }
+}
+
+// Create an instance of the Reflection_Method class
+$method = new ReflectionMethod('ReflectTestClass', 'staticMethod');
+// Get the parameters
+$parameters = $method->getParameters();
+echo "Parameters from staticMethod:\n\n";
+foreach($parameters as $parameter) {
+ var_dump($parameter);
+ if($parameter->isPassedByReference()) {
+ echo "This param is passed by reference\n";
+ } else {
+ echo "This param is not passed by reference\n";
+ }
+ echo "\n";
+}
+
+// Create an instance of the Reflection_Method class
+$method = new ReflectionMethod('ReflectTestClass', 'instanceMethod');
+// Get the parameters
+$parameters = $method->getParameters();
+echo "Parameters from instanceMethod:\n\n";
+foreach($parameters as $parameter) {
+ var_dump($parameter);
+ if($parameter->isPassedByReference()) {
+ echo "This param is passed by reference\n";
+ } else {
+ echo "This param is not passed by reference\n";
+ }
+ echo "\n";
+}
+
+echo "done\n";
+
+?>
+--EXPECTF--
+Parameters from staticMethod:
+
+object(ReflectionParameter)#%i (1) {
+ ["name"]=>
+ string(8) "paramOne"
+}
+This param is passed by reference
+
+object(ReflectionParameter)#%i (1) {
+ ["name"]=>
+ string(12) "anotherParam"
+}
+This param is not passed by reference
+
+Parameters from instanceMethod:
+
+object(ReflectionParameter)#%i (1) {
+ ["name"]=>
+ string(10) "firstParam"
+}
+This param is not passed by reference
+
+object(ReflectionParameter)#%i (1) {
+ ["name"]=>
+ string(11) "secondParam"
+}
+This param is passed by reference
+
+done \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionParameter_003.phpt b/ext/reflection/tests/ReflectionParameter_003.phpt
new file mode 100644
index 0000000..f7ced9a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_003.phpt
@@ -0,0 +1,88 @@
+--TEST--
+ReflectionParameter class - isOptional, isDefaultValueAvailable and getDefaultValue methods.
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+
+class ReflectTestClass {
+ public static function staticMethod($paramOne, $anotherParam = "bob",
+ &$thirdParam = "jack", $arrayParam = array('one')) {
+ echo "hello from test\n";
+ echo "third is $thirdParam\n";
+ return ++$theIncrement;
+ }
+
+}
+
+$jane = "jane";
+ReflectTestClass::staticMethod("bob", "jack");
+
+$refMethod = new ReflectionMethod('ReflectTestClass', 'staticMethod');
+$refParameters = $refMethod->getParameters();
+
+echo "parameter names from staticMethod method:\n\n";
+foreach($refParameters as $parameter) {
+ var_dump($parameter);
+ if($parameter->isOptional()) {
+ echo "this parameter is optional\n";
+ } else {
+ echo "this parameter is not optional\n";
+ }
+
+ if($parameter->isDefaultValueAvailable()) {
+ echo "this parameter has a default value\n";
+ } else {
+ echo "this parameter has no default value\n";
+ }
+
+ /*
+ $val = 0;
+ try {
+ $val = $parameter->getDefaultValue();
+ var_dump($val);
+ } catch (ReflectionException $e) {
+ print $e->getMessage();
+ echo "\n";
+ }
+ */
+
+ echo "\n";
+}
+
+?>
+--EXPECTF--
+hello from test
+third is jack
+
+Notice: Undefined variable: theIncrement in %s on line 8
+parameter names from staticMethod method:
+
+object(ReflectionParameter)#%d (1) {
+ ["name"]=>
+ string(8) "paramOne"
+}
+this parameter is not optional
+this parameter has no default value
+
+object(ReflectionParameter)#%d (1) {
+ ["name"]=>
+ string(12) "anotherParam"
+}
+this parameter is optional
+this parameter has a default value
+
+object(ReflectionParameter)#%d (1) {
+ ["name"]=>
+ string(10) "thirdParam"
+}
+this parameter is optional
+this parameter has a default value
+
+object(ReflectionParameter)#%d (1) {
+ ["name"]=>
+ string(10) "arrayParam"
+}
+this parameter is optional
+this parameter has a default value
diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt
new file mode 100644
index 0000000..cdd00d2
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt
@@ -0,0 +1,52 @@
+--TEST--
+ReflectionParameter::isDefaultValueConstant() && getDefaultValueConstantName()
+--FILE--
+<?php
+
+define("CONST_TEST_1", "const1");
+
+function ReflectionParameterTest($test1=array(), $test2 = CONST_TEST_1) {
+ echo $test;
+}
+$reflect = new ReflectionFunction('ReflectionParameterTest');
+foreach($reflect->getParameters() as $param) {
+ if($param->getName() == 'test1') {
+ var_dump($param->isDefaultValueConstant());
+ }
+ if($param->getName() == 'test2') {
+ var_dump($param->isDefaultValueConstant());
+ }
+ if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) {
+ var_dump($param->getDefaultValueConstantName());
+ }
+}
+
+class Foo2 {
+ const bar = 'Foo2::bar';
+}
+
+class Foo {
+ const bar = 'Foo::bar';
+
+ public function baz($param1 = self::bar, $param2=Foo2::bar, $param3=CONST_TEST_1) {
+ }
+}
+
+$method = new ReflectionMethod('Foo', 'baz');
+$params = $method->getParameters();
+
+foreach ($params as $param) {
+ if ($param->isDefaultValueConstant()) {
+ var_dump($param->getDefaultValueConstantName());
+ }
+}
+?>
+==DONE==
+--EXPECT--
+bool(false)
+bool(true)
+string(12) "CONST_TEST_1"
+string(9) "self::bar"
+string(9) "Foo2::bar"
+string(12) "CONST_TEST_1"
+==DONE==
diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt
new file mode 100644
index 0000000..1ee9e93
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt
@@ -0,0 +1,30 @@
+--TEST--
+ReflectionParameter::isDefaultValueConstant() && getDefaultValueConstantName() for namespace
+--FILE--
+<?php
+
+namespace ReflectionTestNamespace {
+ CONST TEST_CONST_1 = "Test Const 1";
+
+ class TestClass {
+ const TEST_CONST_2 = "Test Const 2 in class";
+ }
+}
+
+namespace {
+ function ReflectionParameterTest($test=ReflectionTestNamespace\TestClass::TEST_CONST_2, $test2 = ReflectionTestNamespace\CONST_TEST_1) {
+ echo $test;
+ }
+ $reflect = new ReflectionFunction('ReflectionParameterTest');
+ foreach($reflect->getParameters() as $param) {
+ if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) {
+ echo $param->getDefaultValueConstantName() . "\n";
+ }
+ }
+ echo "==DONE==";
+}
+?>
+--EXPECT--
+ReflectionTestNamespace\TestClass::TEST_CONST_2
+ReflectionTestNamespace\CONST_TEST_1
+==DONE==
diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt
new file mode 100644
index 0000000..a2c2d24
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt
@@ -0,0 +1,23 @@
+--TEST--
+ReflectionParameter::getDefaultValueConstant() should raise exception on non optional parameter
+--FILE--
+<?php
+
+define("CONST_TEST_1", "const1");
+
+function ReflectionParameterTest($test, $test2 = CONST_TEST_1) {
+ echo $test;
+}
+$reflect = new ReflectionFunction('ReflectionParameterTest');
+foreach($reflect->getParameters() as $param) {
+ try {
+ echo $param->getDefaultValueConstantName() . "\n";
+ }
+ catch(ReflectionException $e) {
+ echo $e->getMessage() . "\n";
+ }
+}
+?>
+--EXPECT--
+Internal error: Failed to retrieve the default value
+CONST_TEST_1
diff --git a/ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt b/ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt
new file mode 100644
index 0000000..82c6200
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt
@@ -0,0 +1,84 @@
+--TEST--
+ReflectionParameter class - canBePassedByValue() method.
+--FILE--
+<?php
+
+function aux($fun) {
+
+ $func = new ReflectionFunction($fun);
+ $parameters = $func->getParameters();
+ foreach($parameters as $parameter) {
+ echo "Name: ", $parameter->getName(), "\n";
+ echo "Is passed by reference: ", $parameter->isPassedByReference()?"yes":"no", "\n";
+ echo "Can be passed by value: ", $parameter->canBePassedByValue()?"yes":"no", "\n";
+ echo "\n";
+ }
+
+}
+
+echo "=> array_multisort:\n\n";
+
+aux('array_multisort');
+
+
+echo "=> sort:\n\n";
+
+aux('sort');
+
+echo "=> user function:\n\n";
+
+function ufunc(&$arg1, $arg2) {}
+
+aux('ufunc');
+
+echo "Done.\n";
+
+?>
+--EXPECTF--
+=> array_multisort:
+
+Name: arr1
+Is passed by reference: yes
+Can be passed by value: yes
+
+Name: SORT_ASC_or_SORT_DESC
+Is passed by reference: yes
+Can be passed by value: yes
+
+Name: SORT_REGULAR_or_SORT_NUMERIC_or_SORT_STRING
+Is passed by reference: yes
+Can be passed by value: yes
+
+Name: arr2
+Is passed by reference: yes
+Can be passed by value: yes
+
+Name: SORT_ASC_or_SORT_DESC
+Is passed by reference: yes
+Can be passed by value: yes
+
+Name: SORT_REGULAR_or_SORT_NUMERIC_or_SORT_STRING
+Is passed by reference: yes
+Can be passed by value: yes
+
+=> sort:
+
+Name: arg
+Is passed by reference: yes
+Can be passed by value: no
+
+Name: sort_flags
+Is passed by reference: no
+Can be passed by value: yes
+
+=> user function:
+
+Name: arg1
+Is passed by reference: yes
+Can be passed by value: no
+
+Name: arg2
+Is passed by reference: no
+Can be passed by value: yes
+
+Done.
diff --git a/ext/reflection/tests/ReflectionParameter_export_basic.phpt b/ext/reflection/tests/ReflectionParameter_export_basic.phpt
new file mode 100644
index 0000000..74428cc
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_export_basic.phpt
@@ -0,0 +1,19 @@
+--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==
diff --git a/ext/reflection/tests/ReflectionParameter_export_error.phpt b/ext/reflection/tests/ReflectionParameter_export_error.phpt
new file mode 100644
index 0000000..31acfe1
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_export_error.phpt
@@ -0,0 +1,21 @@
+--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==
diff --git a/ext/reflection/tests/ReflectionParameter_export_error2.phpt b/ext/reflection/tests/ReflectionParameter_export_error2.phpt
new file mode 100644
index 0000000..8bdbc6a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_export_error2.phpt
@@ -0,0 +1,31 @@
+--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
diff --git a/ext/reflection/tests/ReflectionParameter_export_error3.phpt b/ext/reflection/tests/ReflectionParameter_export_error3.phpt
new file mode 100644
index 0000000..2937853
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_export_error3.phpt
@@ -0,0 +1,22 @@
+--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
diff --git a/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt b/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt
new file mode 100644
index 0000000..59e15a7
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt
@@ -0,0 +1,37 @@
+--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==
diff --git a/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt b/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt
new file mode 100644
index 0000000..2807bdf
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt
@@ -0,0 +1,21 @@
+--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==
diff --git a/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt b/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt
new file mode 100644
index 0000000..3118c17
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt
@@ -0,0 +1,31 @@
+--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.
diff --git a/ext/reflection/tests/ReflectionParameter_isDefault.phpt b/ext/reflection/tests/ReflectionParameter_isDefault.phpt
new file mode 100644
index 0000000..6570770
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_isDefault.phpt
@@ -0,0 +1,34 @@
+--TEST--
+ReflectionParameter::isDefault()
+--FILE--
+<?php
+class A {
+public $defprop;
+}
+$a = new A;
+$a->myprop = null;
+
+$ro = new ReflectionObject($a);
+$props = $ro->getProperties();
+$prop1 = $props[0];
+var_dump($prop1->isDefault());
+$prop2 = $props[1];
+var_dump($prop2->isDefault());
+
+var_dump($ro->getProperty('defprop')->isDefault());
+var_dump($ro->getProperty('myprop')->isDefault());
+
+$prop1 = new ReflectionProperty($a, 'defprop');
+$prop2 = new ReflectionProperty($a, 'myprop');
+var_dump($prop1->isDefault());
+var_dump($prop2->isDefault());
+?>
+==DONE==
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+==DONE==
diff --git a/ext/reflection/tests/ReflectionParameter_toString_basic.phpt b/ext/reflection/tests/ReflectionParameter_toString_basic.phpt
new file mode 100644
index 0000000..268ced1
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_toString_basic.phpt
@@ -0,0 +1,20 @@
+--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==
diff --git a/ext/reflection/tests/ReflectionProperty_basic1.phpt b/ext/reflection/tests/ReflectionProperty_basic1.phpt
new file mode 100644
index 0000000..63f9542
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_basic1.phpt
@@ -0,0 +1,160 @@
+--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():
+string(35) "Property [ <default> public $pub ]
+"
+export():
+string(35) "Property [ <default> public $pub ]
+"
+export():
+Property [ <default> public $pub ]
+
+NULL
+getName():
+string(3) "pub"
+isPublic():
+bool(true)
+isPrivate():
+bool(false)
+isProtected():
+bool(false)
+isStatic():
+bool(false)
+getValue():
+NULL
+getValue() after a setValue():
+string(8) "NewValue"
+
+**********************************
+**********************************
+Reflecting on property TestClass::stat
+
+__toString():
+string(33) "Property [ public static $stat ]
+"
+export():
+string(33) "Property [ public static $stat ]
+"
+export():
+Property [ public static $stat ]
+
+NULL
+getName():
+string(4) "stat"
+isPublic():
+bool(true)
+isPrivate():
+bool(false)
+isProtected():
+bool(false)
+isStatic():
+bool(true)
+getValue():
+string(15) "static property"
+getValue() after a setValue():
+string(8) "NewValue"
+
+**********************************
+**********************************
+Reflecting on property TestClass::prot
+
+__toString():
+string(39) "Property [ <default> protected $prot ]
+"
+export():
+string(39) "Property [ <default> protected $prot ]
+"
+export():
+Property [ <default> protected $prot ]
+
+NULL
+getName():
+string(4) "prot"
+isPublic():
+bool(false)
+isPrivate():
+bool(false)
+isProtected():
+bool(true)
+isStatic():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on property TestClass::priv
+
+__toString():
+string(37) "Property [ <default> private $priv ]
+"
+export():
+string(37) "Property [ <default> private $priv ]
+"
+export():
+Property [ <default> private $priv ]
+
+NULL
+getName():
+string(4) "priv"
+isPublic():
+bool(false)
+isPrivate():
+bool(true)
+isProtected():
+bool(false)
+isStatic():
+bool(false)
+
+**********************************
+
+
diff --git a/ext/reflection/tests/ReflectionProperty_basic2.phpt b/ext/reflection/tests/ReflectionProperty_basic2.phpt
new file mode 100644
index 0000000..b7b2133
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_basic2.phpt
@@ -0,0 +1,103 @@
+--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) {
+ ["name"]=>
+ string(9) "TestClass"
+}
+getDocComment():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on property TestClass::stat
+
+isDefault():
+bool(true)
+getModifiers():
+int(257)
+getDeclaringClass():
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(9) "TestClass"
+}
+getDocComment():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on property TestClass::prot
+
+isDefault():
+bool(true)
+getModifiers():
+int(512)
+getDeclaringClass():
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(9) "TestClass"
+}
+getDocComment():
+string(%d) "/**
+ * This property has a comment.
+ */"
+
+**********************************
+**********************************
+Reflecting on property TestClass::priv
+
+isDefault():
+bool(true)
+getModifiers():
+int(1024)
+getDeclaringClass():
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(9) "TestClass"
+}
+getDocComment():
+bool(false)
+
+**********************************
diff --git a/ext/reflection/tests/ReflectionProperty_constructor_error.phpt b/ext/reflection/tests/ReflectionProperty_constructor_error.phpt
new file mode 100644
index 0000000..38a3468
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_constructor_error.phpt
@@ -0,0 +1,44 @@
+--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
diff --git a/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt b/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt
new file mode 100644
index 0000000..d614803
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt
@@ -0,0 +1,58 @@
+--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 \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionProperty_error.phpt b/ext/reflection/tests/ReflectionProperty_error.phpt
new file mode 100644
index 0000000..56de6e1
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_error.phpt
@@ -0,0 +1,67 @@
+--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) {
+ ["name"]=>
+ string(0) ""
+ ["class"]=>
+ string(0) ""
+}
+
+Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 1 given in %s on line %d
+object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(0) ""
+ ["class"]=>
+ string(0) ""
+}
+
+Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 3 given in %s on line %d
+object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(0) ""
+ ["class"]=>
+ string(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
diff --git a/ext/reflection/tests/ReflectionProperty_export_basic.phpt b/ext/reflection/tests/ReflectionProperty_export_basic.phpt
new file mode 100644
index 0000000..e77a3b7
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_export_basic.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Test ReflectionProperty::export() usage.
+--FILE--
+<?php
+
+class TestClass {
+ public $proper = 5;
+}
+
+var_dump(ReflectionProperty::export('TestClass', 'proper'));
+
+?>
+--EXPECT--
+Property [ <default> public $proper ]
+
+NULL
diff --git a/ext/reflection/tests/ReflectionProperty_export_error.phpt b/ext/reflection/tests/ReflectionProperty_export_error.phpt
new file mode 100644
index 0000000..ab09ed0
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_export_error.phpt
@@ -0,0 +1,54 @@
+--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
diff --git a/ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt b/ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt
new file mode 100644
index 0000000..bf525e1
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt
@@ -0,0 +1,27 @@
+--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) {
+ ["name"]=>
+ string(1) "A"
+}
+Wrong number of params:
+
+Warning: ReflectionProperty::getDeclaringClass() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/reflection/tests/ReflectionProperty_getDocComment_basic.phpt b/ext/reflection/tests/ReflectionProperty_getDocComment_basic.phpt
new file mode 100644
index 0000000..2c4815a
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_getDocComment_basic.phpt
@@ -0,0 +1,100 @@
+--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:
+string(%d) "/**
+ * My Doc Comment for $a
+ *
+ */"
+
+
+---> Doc comment for A::$b:
+bool(false)
+
+
+---> Doc comment for A::$c:
+bool(false)
+
+
+---> Doc comment for A::$d:
+string(%d) "/**
+ * My Doc Comment for $d
+ */"
+
+
+---> Doc comment for A::$e:
+bool(false)
+
+
+---> Doc comment for A::$f:
+string(%d) "/**
+ * Doc comment for $f
+ */"
+
+
+---> Doc comment for B::$a:
+bool(false)
+
+
+---> Doc comment for B::$b:
+string(%d) "/** A doc comment for $b */"
+
+
+---> Doc comment for B::$c:
+bool(false)
+
+
+---> Doc comment for B::$e:
+string(%d) "/** A doc comment for $e */"
+
+
+---> Doc comment for B::$d:
+string(%d) "/**
+ * My Doc Comment for $d
+ */"
+
+
+---> Doc comment for B::$f:
+string(%d) "/**
+ * Doc comment for $f
+ */"
diff --git a/ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt b/ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt
new file mode 100644
index 0000000..dae7be2
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_getDocComment_error.phpt
@@ -0,0 +1,28 @@
+--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
diff --git a/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt b/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt
new file mode 100644
index 0000000..fe888a8
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt
@@ -0,0 +1,66 @@
+--TEST--
+ReflectionProperty::getModifiers()
+--CREDITS--
+Robin Fernandes <robinf@php.net>
+Steve Seear <stevseea@php.net>
+--FILE--
+<?php
+
+function reflectProperty($class, $property) {
+ $propInfo = new ReflectionProperty($class, $property);
+
+ echo "**********************************\n";
+ echo "Reflecting on property $class::$property\n\n";
+
+ echo "getModifiers():\n";
+ var_dump($propInfo->getModifiers());
+
+ 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");
+
+?>
+--EXPECT--
+**********************************
+Reflecting on property TestClass::pub
+
+getModifiers():
+int(256)
+
+**********************************
+**********************************
+Reflecting on property TestClass::stat
+
+getModifiers():
+int(257)
+
+**********************************
+**********************************
+Reflecting on property TestClass::prot
+
+getModifiers():
+int(512)
+
+**********************************
+**********************************
+Reflecting on property TestClass::priv
+
+getModifiers():
+int(1024)
+
+**********************************
diff --git a/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt
new file mode 100644
index 0000000..0d1b6bd
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt
@@ -0,0 +1,46 @@
+--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)
diff --git a/ext/reflection/tests/ReflectionProperty_getValue_error.phpt b/ext/reflection/tests/ReflectionProperty_getValue_error.phpt
new file mode 100644
index 0000000..c2152e9
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_getValue_error.phpt
@@ -0,0 +1,81 @@
+--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:
+string(15) "static property"
+
+Static property / wrong type of arg:
+string(15) "static property"
+
+Protected property:
+Cannot access non-public member TestClass::prot
+
+Instance without property:
+NULL
diff --git a/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt b/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt
new file mode 100644
index 0000000..22ee117
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt
@@ -0,0 +1,63 @@
+--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
diff --git a/ext/reflection/tests/ReflectionProperty_setAccessible.phpt b/ext/reflection/tests/ReflectionProperty_setAccessible.phpt
new file mode 100644
index 0000000..cc184c1
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_setAccessible.phpt
@@ -0,0 +1,139 @@
+--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--
+string(44) "Cannot access non-public member A::protected"
+string(50) "Cannot access non-public member A::protectedStatic"
+string(42) "Cannot access non-public member A::private"
+string(48) "Cannot access non-public member A::privateStatic"
+string(1) "a"
+string(1) "b"
+string(1) "c"
+string(1) "d"
+string(1) "e"
+string(1) "f"
+string(1) "g"
+string(1) "h"
+string(44) "Cannot access non-public member B::protected"
+string(50) "Cannot access non-public member B::protectedStatic"
+string(42) "Cannot access non-public member A::private"
+string(1) "a"
+string(1) "f"
+string(1) "c"
+string(1) "e"
+string(1) "f"
+string(1) "g"
diff --git a/ext/reflection/tests/ReflectionProperty_setValue_error.phpt b/ext/reflection/tests/ReflectionProperty_setValue_error.phpt
new file mode 100644
index 0000000..7161c53
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_setValue_error.phpt
@@ -0,0 +1,100 @@
+--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
+string(11) "A new value"
+
+Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+string(11) "A new value"
+
+Static property / wrong type of arg:
+NULL
+string(17) "Another new value"
+
+Protected property:
+Cannot access non-public member TestClass::prot
+
+Instance without property:
+NULL
+string(8) "NewValue"
diff --git a/ext/reflection/tests/bug26640.phpt b/ext/reflection/tests/bug26640.phpt
new file mode 100644
index 0000000..e375fd4
--- /dev/null
+++ b/ext/reflection/tests/bug26640.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Reflection Bug #26640 (__autoload() not invoked by Reflection classes)
+--FILE--
+<?php
+
+function __autoload($c)
+{
+ class autoload_class
+ {
+ public function __construct()
+ {
+ print "autoload success\n";
+ }
+ }
+}
+
+$a = new ReflectionClass('autoload_class');
+
+if (is_object($a)) {
+ echo "OK\n";
+}
+
+?>
+--EXPECT--
+OK
diff --git a/ext/reflection/tests/bug26695.phpt b/ext/reflection/tests/bug26695.phpt
new file mode 100644
index 0000000..e429f76
--- /dev/null
+++ b/ext/reflection/tests/bug26695.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Reflection Bug #26695 (Reflection API does not recognize mixed-case class hints)
+--FILE--
+<?php
+
+class Foo {
+}
+
+class Bar {
+ function demo(foo $f) {
+ }
+}
+
+$class = new ReflectionClass('bar');
+$methods = $class->getMethods();
+$params = $methods[0]->getParameters();
+
+$class = $params[0]->getClass();
+
+var_dump($class->getName());
+?>
+===DONE===
+--EXPECT--
+string(3) "Foo"
+===DONE===
diff --git a/ext/reflection/tests/bug29268.phpt b/ext/reflection/tests/bug29268.phpt
new file mode 100644
index 0000000..d8efc0b
--- /dev/null
+++ b/ext/reflection/tests/bug29268.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Reflection Bug #29268 (__autoload() not called with reflectionProperty->getClass())
+--FILE--
+<?php
+function __autoload($classname) {
+ echo "__autoload($classname)\n";
+ eval("class $classname {}");
+}
+
+class B{
+ public function doit(A $a){
+ }
+}
+
+$ref = new reflectionMethod('B','doit');
+$parameters = $ref->getParameters();
+foreach($parameters as $parameter)
+{
+ $class = $parameter->getClass();
+ echo $class->name."\n";
+}
+echo "ok\n";
+?>
+--EXPECT--
+__autoload(A)
+A
+ok
diff --git a/ext/reflection/tests/bug29523.phpt b/ext/reflection/tests/bug29523.phpt
new file mode 100644
index 0000000..e74403c
--- /dev/null
+++ b/ext/reflection/tests/bug29523.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Reflection Bug #29523 (ReflectionParameter::isOptional() is incorrect)
+--FILE--
+<?php
+
+class TestClass
+{
+}
+
+function optionalTest(TestClass $a, TestClass $b, $c = 3)
+{
+}
+
+$function = new ReflectionFunction('optionalTest');
+$numberOfNotOptionalParameters = 0;
+$numberOfOptionalParameters = 0;
+foreach($function->getParameters() as $parameter)
+{
+ var_dump($parameter->isOptional());
+ if ($parameter->isOptional())
+ {
+ ++$numberOfOptionalParameters;
+ }
+ else
+ {
+ ++$numberOfNotOptionalParameters;
+ }
+}
+var_dump($function->getNumberOfRequiredParameters());
+var_dump($numberOfNotOptionalParameters);
+
+?>
+--EXPECT--
+bool(false)
+bool(false)
+bool(true)
+int(2)
+int(2)
diff --git a/ext/reflection/tests/bug29828.phpt b/ext/reflection/tests/bug29828.phpt
new file mode 100644
index 0000000..43e32d2
--- /dev/null
+++ b/ext/reflection/tests/bug29828.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Reflection Bug #29828 (Interfaces no longer work)
+--FILE--
+<?php
+
+interface Bla
+{
+ function bla();
+}
+
+class BlaMore implements Bla
+{
+ function bla()
+ {
+ echo "Hello\n";
+ }
+}
+
+$r = new ReflectionClass('BlaMore');
+
+var_dump(count($r->getMethods()));
+var_dump($r->getMethod('bla')->isConstructor());
+var_dump($r->getMethod('bla')->isAbstract());
+
+$o=new BlaMore;
+$o->bla();
+
+?>
+===DONE===
+--EXPECT--
+int(1)
+bool(false)
+bool(false)
+Hello
+===DONE===
diff --git a/ext/reflection/tests/bug29986.phpt b/ext/reflection/tests/bug29986.phpt
new file mode 100644
index 0000000..d30b3a6
--- /dev/null
+++ b/ext/reflection/tests/bug29986.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Reflection Bug #29986 (Class constants won't work with predefined constants when using ReflectionClass)
+--INI--
+precision=14
+--FILE--
+<?php
+class just_constants
+{
+ const BOOLEAN_CONSTANT = true;
+ const NULL_CONSTANT = null;
+ const STRING_CONSTANT = 'This is a string';
+ const INTEGER_CONSTANT = 1000;
+ const FLOAT_CONSTANT = 3.14159265;
+}
+
+Reflection::export(new ReflectionClass('just_constants'));
+?>
+--EXPECTF--
+Class [ <user> class just_constants ] {
+ @@ %s %d-%d
+
+ - Constants [5] {
+ Constant [ boolean BOOLEAN_CONSTANT ] { 1 }
+ Constant [ null NULL_CONSTANT ] { }
+ Constant [ string STRING_CONSTANT ] { This is a string }
+ Constant [ integer INTEGER_CONSTANT ] { 1000 }
+ Constant [ double FLOAT_CONSTANT ] { 3.14159265 }
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [0] {
+ }
+}
diff --git a/ext/reflection/tests/bug30146.phpt b/ext/reflection/tests/bug30146.phpt
new file mode 100644
index 0000000..3f62141
--- /dev/null
+++ b/ext/reflection/tests/bug30146.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Reflection Bug #30146 (ReflectionProperty->getValue() requires instance for static property)
+--FILE--
+<?php
+class test {
+ static public $a = 1;
+}
+
+$r = new ReflectionProperty('test', 'a');
+var_dump($r->getValue(null));
+
+$r->setValue(NULL, 2);
+var_dump($r->getValue());
+
+$r->setValue(3);
+var_dump($r->getValue());
+?>
+===DONE===
+--EXPECT--
+int(1)
+int(2)
+int(3)
+===DONE===
diff --git a/ext/reflection/tests/bug30148.phpt b/ext/reflection/tests/bug30148.phpt
new file mode 100644
index 0000000..aa5841e
--- /dev/null
+++ b/ext/reflection/tests/bug30148.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Reflection Bug #30148 (ReflectionMethod->isConstructor() fails for inherited classes)
+--FILE--
+<?php
+
+class Root
+{
+ function Root() {}
+}
+class Base extends Root
+{
+ function __construct() {}
+}
+class Derived extends Base
+{
+}
+$a = new ReflectionMethod('Root','Root');
+$b = new ReflectionMethod('Base','Root');
+$c = new ReflectionMethod('Base','__construct');
+$d = new ReflectionMethod('Derived','Root');
+$e = new ReflectionMethod('Derived','__construct');
+var_dump($a->isConstructor());
+var_dump($b->isConstructor());
+var_dump($c->isConstructor());
+var_dump($d->isConstructor());
+var_dump($e->isConstructor());
+?>
+===DONE===
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/reflection/tests/bug30209.phpt b/ext/reflection/tests/bug30209.phpt
new file mode 100644
index 0000000..2735a74
--- /dev/null
+++ b/ext/reflection/tests/bug30209.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Reflection Bug #30209 (ReflectionClass::getMethod() lowercases attribute)
+--FILE--
+<?php
+
+class Foo
+{
+ private $name = 'testBAR';
+
+ public function testBAR()
+ {
+ try
+ {
+ $class = new ReflectionClass($this);
+ var_dump($this->name);
+ $method = $class->getMethod($this->name);
+ var_dump($this->name);
+ }
+
+ catch (Exception $e) {}
+ }
+}
+
+$foo = new Foo;
+$foo->testBAR();
+?>
+===DONE===
+--EXPECTF--
+string(7) "testBAR"
+string(7) "testBAR"
+===DONE===
diff --git a/ext/reflection/tests/bug30856.phpt b/ext/reflection/tests/bug30856.phpt
new file mode 100644
index 0000000..39fc110
--- /dev/null
+++ b/ext/reflection/tests/bug30856.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Reflection Bug #30856 (ReflectionClass::getStaticProperties segfaults)
+--FILE--
+<?php
+class bogus {
+ const C = 'test';
+ static $a = bogus::C;
+}
+
+$class = new ReflectionClass('bogus');
+
+var_dump($class->getStaticProperties());
+?>
+===DONE===
+--EXPECT--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+===DONE===
diff --git a/ext/reflection/tests/bug30961.phpt b/ext/reflection/tests/bug30961.phpt
new file mode 100644
index 0000000..a61c992
--- /dev/null
+++ b/ext/reflection/tests/bug30961.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Reflection Bug #30961 (Wrong linenumber in ReflectionClass getStartLine())
+--FILE--
+<?php
+ class a
+ {
+ }
+
+ class b extends a
+ {
+ }
+
+ $ref1 = new ReflectionClass('a');
+ $ref2 = new ReflectionClass('b');
+ echo $ref1->getStartLine() . "\n";
+ echo $ref2->getStartLine() . "\n";
+?>
+--EXPECT--
+2
+6
diff --git a/ext/reflection/tests/bug31651.phpt b/ext/reflection/tests/bug31651.phpt
new file mode 100644
index 0000000..59f19ea
--- /dev/null
+++ b/ext/reflection/tests/bug31651.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Reflection Bug #31651 (ReflectionClass::getDefaultProperties segfaults with arrays.)
+--FILE--
+<?php
+
+class Test
+{
+ public $a = array('a' => 1);
+}
+
+$ref = new ReflectionClass('Test');
+
+print_r($ref->getDefaultProperties());
+
+?>
+--EXPECT--
+Array
+(
+ [a] => Array
+ (
+ [a] => 1
+ )
+
+)
diff --git a/ext/reflection/tests/bug32981.phpt b/ext/reflection/tests/bug32981.phpt
new file mode 100644
index 0000000..5735674
--- /dev/null
+++ b/ext/reflection/tests/bug32981.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Reflection Bug #32981 (ReflectionMethod::getStaticVariables() causes apache2.0.54 seg fault)
+--FILE--
+<?php
+
+class TestClass
+{
+ static function test()
+ {
+ static $enabled = true;
+ }
+}
+
+$class = new ReflectionClass('TestClass');
+foreach ($class->getMethods() as $method)
+{
+ var_dump($method->getName());
+ $arr_static_vars[] = $method->getStaticVariables();
+}
+
+var_dump($arr_static_vars);
+
+?>
+===DONE===
+--EXPECT--
+string(4) "test"
+array(1) {
+ [0]=>
+ array(1) {
+ ["enabled"]=>
+ bool(true)
+ }
+}
+===DONE===
diff --git a/ext/reflection/tests/bug33312.phpt b/ext/reflection/tests/bug33312.phpt
new file mode 100644
index 0000000..ffa9180
--- /dev/null
+++ b/ext/reflection/tests/bug33312.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Reflection Bug #33312 (ReflectionParameter methods do not work correctly)
+--FILE--
+<?php
+class Foo {
+ public function bar(Foo $foo, $bar = 'bar') {
+ }
+}
+
+$class = new ReflectionClass('Foo');
+$method = $class->getMethod('bar');
+
+foreach ($method->getParameters() as $parameter) {
+ if ($parameter->isDefaultValueAvailable()) {
+ print $parameter->getDefaultValue()."\n";
+ }
+}
+?>
+--EXPECT--
+bar
diff --git a/ext/reflection/tests/bug33389.phpt b/ext/reflection/tests/bug33389.phpt
new file mode 100644
index 0000000..f1997a3
--- /dev/null
+++ b/ext/reflection/tests/bug33389.phpt
@@ -0,0 +1,97 @@
+--TEST--
+Reflection Bug #33389 (double free() when exporting a ReflectionClass)
+--FILE--
+<?php
+define ('foobar', 1);
+class Test {
+ function foo1($arg=foobar) {
+ }
+ function foo2($arg=null) {
+ }
+ function foo3($arg=false) {
+ }
+ function foo4($arg='foo') {
+ }
+ function foo5($arg=1) {
+ }
+ function bar($arg) {
+ }
+ function foo() {
+ }
+}
+Reflection::export(new ReflectionClass('Test'));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Class [ <user> class Test ] {
+ @@ %sbug33389.php 3-18
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [7] {
+ Method [ <user> public method foo1 ] {
+ @@ %sbug33389.php 4 - 5
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $arg = 1 ]
+ }
+ }
+
+ Method [ <user> public method foo2 ] {
+ @@ %sbug33389.php 6 - 7
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $arg = NULL ]
+ }
+ }
+
+ Method [ <user> public method foo3 ] {
+ @@ %sbug33389.php 8 - 9
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $arg = false ]
+ }
+ }
+
+ Method [ <user> public method foo4 ] {
+ @@ %sbug33389.php 10 - 11
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $arg = 'foo' ]
+ }
+ }
+
+ Method [ <user> public method foo5 ] {
+ @@ %sbug33389.php 12 - 13
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $arg = 1 ]
+ }
+ }
+
+ Method [ <user> public method bar ] {
+ @@ %sbug33389.php 14 - 15
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $arg ]
+ }
+ }
+
+ Method [ <user> public method foo ] {
+ @@ %sbug33389.php 16 - 17
+ }
+ }
+}
+
+===DONE===
diff --git a/ext/reflection/tests/bug36308.phpt b/ext/reflection/tests/bug36308.phpt
new file mode 100644
index 0000000..79aa5f8
--- /dev/null
+++ b/ext/reflection/tests/bug36308.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Reflection Bug #36308 (ReflectionProperty::getDocComment() does not reflect extended class commentary)
+--FILE--
+<?php
+class Base {
+ /** Base comment block */
+ public $foo = 'bar';
+}
+
+class Extended extends Base {
+ /** Extended commentary */
+ public $foo = 'zim';
+}
+
+$reflect = new ReflectionClass('Extended');
+$props = $reflect->getProperties();
+echo $props[0]->getDocComment();
+?>
+--EXPECT--
+/** Extended commentary */
diff --git a/ext/reflection/tests/bug36337.phpt b/ext/reflection/tests/bug36337.phpt
new file mode 100644
index 0000000..369d5be
--- /dev/null
+++ b/ext/reflection/tests/bug36337.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Reflection Bug #36337 (ReflectionProperty fails to return correct visibility)
+--FILE--
+<?php
+
+abstract class enum {
+ protected $_values;
+
+ public function __construct() {
+ $property = new ReflectionProperty(get_class($this),'_values');
+ var_dump($property->isProtected());
+ }
+
+}
+
+final class myEnum extends enum {
+ public $_values = array(
+ 0 => 'No value',
+ );
+}
+
+$x = new myEnum();
+
+echo "Done\n";
+?>
+--EXPECT--
+bool(false)
+Done
diff --git a/ext/reflection/tests/bug36434.phpt b/ext/reflection/tests/bug36434.phpt
new file mode 100644
index 0000000..218055d
--- /dev/null
+++ b/ext/reflection/tests/bug36434.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Reflection Bug #36434 (Properties from parent class fail to indetify their true origin)
+--FILE--
+<?php
+class ancester
+{
+public $ancester = 0;
+ function ancester()
+ {
+ return $this->ancester;
+ }
+}
+class foo extends ancester
+{
+public $bar = "1";
+ function foo()
+ {
+ return $this->bar;
+ }
+}
+
+$r = new ReflectionClass('foo');
+foreach ($r->GetProperties() as $p)
+{
+ echo $p->getName(). " ". $p->getDeclaringClass()->getName()."\n";
+}
+
+?>
+--EXPECT--
+bar foo
+ancester ancester
diff --git a/ext/reflection/tests/bug37816.phpt b/ext/reflection/tests/bug37816.phpt
new file mode 100644
index 0000000..18a4904
--- /dev/null
+++ b/ext/reflection/tests/bug37816.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #37816 (ReflectionProperty does not throw exception when accessing protected attribute)
+--FILE--
+<?php
+
+class TestClass
+{
+ protected $p = 2;
+}
+
+$o = new TestClass;
+
+$r = new ReflectionProperty($o, 'p');
+
+try
+{
+ $x = $r->getValue($o);
+}
+catch (Exception $e)
+{
+ echo 'Caught: ' . $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+Caught: Cannot access non-public member TestClass::p
+===DONE===
diff --git a/ext/reflection/tests/bug37964.phpt b/ext/reflection/tests/bug37964.phpt
new file mode 100644
index 0000000..9351193
--- /dev/null
+++ b/ext/reflection/tests/bug37964.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Reflection Bug #37964 (Reflection shows private methods of parent class)
+--FILE--
+<?php
+
+abstract class foobar {
+ private function test2() {
+ }
+}
+class foo extends foobar {
+ private $foo = 1;
+ private function test() {
+ }
+ protected function test3() {
+ }
+}
+class bar extends foo {
+ private function foobar() {
+ }
+}
+
+Reflection::export(new ReflectionClass(new bar));
+
+?>
+--EXPECTF--
+Class [ <user> class bar extends foo ] {
+ @@ %s %s
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [2] {
+ Method [ <user> private method foobar ] {
+ @@ %s %d - %d
+ }
+
+ Method [ <user, inherits foo> protected method test3 ] {
+ @@ %s %d - %d
+ }
+ }
+}
diff --git a/ext/reflection/tests/bug38132.phpt b/ext/reflection/tests/bug38132.phpt
new file mode 100644
index 0000000..16e5641
--- /dev/null
+++ b/ext/reflection/tests/bug38132.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Reflection Bug #38132 (ReflectionClass::getStaticProperties() retains \0 in key names)
+--FILE--
+<?php
+class foo {
+ static protected $bar = 'baz';
+ static public $a = 'a';
+}
+
+$class = new ReflectionClass('foo');
+$properties = $class->getStaticProperties();
+var_dump($properties, array_keys($properties));
+var_dump(isset($properties['*bar']));
+var_dump(isset($properties["\0*\0bar"]));
+var_dump(isset($properties["bar"]));
+?>
+--EXPECT--
+array(2) {
+ ["bar"]=>
+ string(3) "baz"
+ ["a"]=>
+ string(1) "a"
+}
+array(2) {
+ [0]=>
+ string(3) "bar"
+ [1]=>
+ string(1) "a"
+}
+bool(false)
+bool(false)
+bool(true)
diff --git a/ext/reflection/tests/bug38194.phpt b/ext/reflection/tests/bug38194.phpt
new file mode 100644
index 0000000..d12f4e4
--- /dev/null
+++ b/ext/reflection/tests/bug38194.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Reflection Bug #38194 (ReflectionClass::isSubclassOf() returns TRUE for the class itself)
+--FILE--
+<?php
+class Object { }
+
+$objectClass= new ReflectionClass('Object');
+var_dump($objectClass->isSubclassOf($objectClass));
+?>
+--EXPECT--
+bool(false)
diff --git a/ext/reflection/tests/bug38217.phpt b/ext/reflection/tests/bug38217.phpt
new file mode 100644
index 0000000..cf007d9
--- /dev/null
+++ b/ext/reflection/tests/bug38217.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #38217 (ReflectionClass::newInstanceArgs() tries to allocate too much memory)
+--FILE--
+<?php
+
+class Object {
+ public function __construct() {
+ }
+}
+
+$class= new ReflectionClass('Object');
+var_dump($class->newInstanceArgs());
+
+class Object1 {
+ public function __construct($var) {
+ var_dump($var);
+ }
+}
+
+$class= new ReflectionClass('Object1');
+var_dump($class->newInstanceArgs());
+var_dump($class->newInstanceArgs(array('test')));
+
+
+echo "Done\n";
+?>
+--EXPECTF--
+object(Object)#%d (0) {
+}
+
+Warning: Missing argument 1 for Object1::__construct() in %s on line %d
+
+Notice: Undefined variable: var in %s on line %d
+NULL
+object(Object1)#%d (0) {
+}
+string(4) "test"
+object(Object1)#%d (0) {
+}
+Done
diff --git a/ext/reflection/tests/bug38465.phpt b/ext/reflection/tests/bug38465.phpt
new file mode 100644
index 0000000..f40d487
--- /dev/null
+++ b/ext/reflection/tests/bug38465.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Bug #38465 (ReflectionParameter fails on access to self::)
+--FILE--
+<?php
+class Baz {
+ const B = 3;
+}
+
+class Foo {
+ const X = 1;
+ public function x($a = self::X, $b = Baz::B, $c = 99) {}
+}
+
+class Bar extends Foo {
+ const Y = 2;
+ public function y($a = self::Y, $b = Baz::B, $c = 99) {}
+}
+
+
+echo "From global scope:\n";
+
+$clazz = new ReflectionClass('Bar');
+foreach ($clazz->getMethods() as $method) {
+ foreach ($method->getParameters() as $param) {
+ if ($param->isDefaultValueAvailable()) {
+ echo $method->getDeclaringClass()->getName(), '::', $method->getName(), '($', $param->getName(), ' = ', $param->getDefaultValue(), ")\n";
+ }
+ }
+}
+
+echo "\nFrom class context:\n";
+
+class Test {
+ function __construct() {
+ $clazz = new ReflectionClass('Bar');
+ foreach ($clazz->getMethods() as $method) {
+ foreach ($method->getParameters() as $param) {
+ if ($param->isDefaultValueAvailable()) {
+ echo $method->getDeclaringClass()->getName(), '::', $method->getName(), '($', $param->getName(), ' = ', $param->getDefaultValue(), ")\n";
+ }
+ }
+ }
+ }
+}
+
+new Test();
+
+?>
+--EXPECT--
+From global scope:
+Bar::y($a = 2)
+Bar::y($b = 3)
+Bar::y($c = 99)
+Foo::x($a = 1)
+Foo::x($b = 3)
+Foo::x($c = 99)
+
+From class context:
+Bar::y($a = 2)
+Bar::y($b = 3)
+Bar::y($c = 99)
+Foo::x($a = 1)
+Foo::x($b = 3)
+Foo::x($c = 99)
diff --git a/ext/reflection/tests/bug38653.phpt b/ext/reflection/tests/bug38653.phpt
new file mode 100644
index 0000000..68781d2
--- /dev/null
+++ b/ext/reflection/tests/bug38653.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #38653 (memory leak in ReflectionClass::getConstant())
+--FILE--
+<?php
+
+class foo {
+ const cons = 10;
+ const cons1 = "";
+ const cons2 = "test";
+}
+
+class bar extends foo {
+}
+
+$foo = new ReflectionClass("foo");
+var_dump($foo->getConstant("cons"));
+var_dump($foo->getConstant("cons1"));
+var_dump($foo->getConstant("cons2"));
+var_dump($foo->getConstant("no such const"));
+
+echo "Done\n";
+?>
+--EXPECTF--
+int(10)
+string(0) ""
+string(4) "test"
+bool(false)
+Done
diff --git a/ext/reflection/tests/bug38942.phpt b/ext/reflection/tests/bug38942.phpt
new file mode 100644
index 0000000..817190c
--- /dev/null
+++ b/ext/reflection/tests/bug38942.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Bug #38942 (Double old-style-ctor inheritance)
+--FILE--
+<?php
+class foo {
+ public function foo() {}
+}
+
+class bar extends foo {
+}
+ReflectionClass::export("bar");
+?>
+--EXPECTF--
+Class [ <user> class bar extends foo ] {
+ @@ %sbug38942.php 6-7
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [1] {
+ Method [ <user, inherits foo, ctor> public method foo ] {
+ @@ %sbug38942.php 3 - 3
+ }
+ }
+}
diff --git a/ext/reflection/tests/bug39001.phpt b/ext/reflection/tests/bug39001.phpt
new file mode 100644
index 0000000..1ed675f
--- /dev/null
+++ b/ext/reflection/tests/bug39001.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #39001 (ReflectionProperty returns incorrect declaring class for protected properties)
+--FILE--
+<?php
+
+class Meta {
+}
+
+class CParent extends Meta {
+ public $publicVar;
+ protected $protectedVar;
+}
+
+class Child extends CParent {
+}
+
+$r = new ReflectionClass('Child');
+
+var_dump($r->getProperty('publicVar')->getDeclaringClass()->getName());
+var_dump($r->getProperty('protectedVar')->getDeclaringClass()->getName());
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(7) "CParent"
+string(7) "CParent"
+Done
diff --git a/ext/reflection/tests/bug39067.phpt b/ext/reflection/tests/bug39067.phpt
new file mode 100644
index 0000000..8a7a604
--- /dev/null
+++ b/ext/reflection/tests/bug39067.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Bug #39067 (getDeclaringClass() and private properties)
+--FILE--
+<?php
+
+class A {
+ private $x;
+}
+
+class B extends A {
+ private $x;
+}
+
+class C extends B {
+ private $x;
+}
+
+$rc = new ReflectionClass('C');
+var_dump($rc->getProperty('x')->getDeclaringClass()->getName());
+
+$rc = new ReflectionClass('B');
+var_dump($rc->getProperty('x')->getDeclaringClass()->getName());
+
+$rc = new ReflectionClass('A');
+var_dump($rc->getProperty('x')->getDeclaringClass()->getName());
+
+class Test {
+ private $x;
+}
+
+class Test2 extends Test {
+ public $x;
+}
+
+$rc = new ReflectionClass('Test2');
+var_dump($rc->getProperty('x')->getDeclaringClass()->getName());
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(1) "C"
+string(1) "B"
+string(1) "A"
+string(5) "Test2"
+Done
diff --git a/ext/reflection/tests/bug39884.phpt b/ext/reflection/tests/bug39884.phpt
new file mode 100644
index 0000000..dbc57ee
--- /dev/null
+++ b/ext/reflection/tests/bug39884.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #39884 (ReflectionParameter::getClass() throws exception for type hint self)
+--FILE--
+<?php
+class stubParamTest
+{
+ function paramTest(self $param)
+ {
+ // nothing to do
+ }
+}
+$test1 = new stubParamTest();
+$test2 = new stubParamTest();
+$test1->paramTest($test2);
+$refParam = new ReflectionParameter(array('stubParamTest', 'paramTest'), 'param');
+var_dump($refParam->getClass());
+?>
+--EXPECT--
+object(ReflectionClass)#4 (1) {
+ ["name"]=>
+ string(13) "stubParamTest"
+}
diff --git a/ext/reflection/tests/bug40431.phpt b/ext/reflection/tests/bug40431.phpt
new file mode 100644
index 0000000..863df7a
--- /dev/null
+++ b/ext/reflection/tests/bug40431.phpt
@@ -0,0 +1,136 @@
+--TEST--
+Bug #40431 (dynamic properties may cause crash in ReflectionProperty methods)
+--FILE--
+<?php
+
+echo "=== 1st test ===\n";
+$Obj = new stdClass;
+$Obj->value = 'value';
+$RefObj = new ReflectionObject($Obj);
+
+$props = $RefObj->getProperties();
+
+var_dump($props);
+var_dump($props[0]->isStatic());
+var_dump($props[0]->isPrivate());
+var_dump($props[0]->isPublic());
+var_dump($props[0]->isProtected());
+
+echo "=== 2nd test ===\n";
+
+class test1 {
+}
+
+class test2 extends test1{
+}
+
+$Obj = new test2;
+$Obj->value = 'value';
+$RefObj = new ReflectionObject($Obj);
+
+$props = $RefObj->getProperties();
+
+var_dump($props);
+var_dump($props[0]->isStatic());
+var_dump($props[0]->isPrivate());
+var_dump($props[0]->isPublic());
+var_dump($props[0]->isProtected());
+
+echo "=== 3rd test ===\n";
+
+class test3 {
+}
+
+$Obj = new test3;
+$Obj->value = 'value';
+$RefObj = new ReflectionObject($Obj);
+
+$props = $RefObj->getProperties();
+
+var_dump($props);
+var_dump($props[0]->isStatic());
+var_dump($props[0]->isPrivate());
+var_dump($props[0]->isPublic());
+var_dump($props[0]->isProtected());
+
+echo "=== 4th test ===\n";
+
+class test5 {
+ private $value = 1;
+}
+
+class test4 extends test5{
+}
+
+$Obj = new test4;
+$Obj->value = 'value';
+$RefObj = new ReflectionObject($Obj);
+
+$props = $RefObj->getProperties();
+
+var_dump($props);
+var_dump($props[0]->isStatic());
+var_dump($props[0]->isPrivate());
+var_dump($props[0]->isPublic());
+var_dump($props[0]->isProtected());
+
+echo "Done\n";
+?>
+--EXPECTF--
+=== 1st test ===
+array(1) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "value"
+ ["class"]=>
+ string(8) "stdClass"
+ }
+}
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+=== 2nd test ===
+array(1) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "value"
+ ["class"]=>
+ string(5) "test2"
+ }
+}
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+=== 3rd test ===
+array(1) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "value"
+ ["class"]=>
+ string(5) "test3"
+ }
+}
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+=== 4th test ===
+array(1) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "value"
+ ["class"]=>
+ string(5) "test4"
+ }
+}
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+Done
diff --git a/ext/reflection/tests/bug40794.phpt b/ext/reflection/tests/bug40794.phpt
new file mode 100644
index 0000000..bb93b91
--- /dev/null
+++ b/ext/reflection/tests/bug40794.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #40794 (ReflectionObject::getValues() may crash when used with dynamic properties)
+--FILE--
+<?php
+
+$obj = new stdClass();
+$obj->prop1 = '1';
+$obj->prop2 = '2';
+$obj->prop3 = '3';
+
+$reflect = new ReflectionObject($obj);
+
+$array = array();
+foreach($reflect->getProperties() as $prop)
+{
+ $array[$prop->getName()] = $prop->getValue($obj);
+}
+
+var_dump($array);
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(3) {
+ ["prop1"]=>
+ string(1) "1"
+ ["prop2"]=>
+ string(1) "2"
+ ["prop3"]=>
+ string(1) "3"
+}
+Done
diff --git a/ext/reflection/tests/bug41061.phpt b/ext/reflection/tests/bug41061.phpt
new file mode 100644
index 0000000..771cd40
--- /dev/null
+++ b/ext/reflection/tests/bug41061.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Reflection Bug #41061 ("visibility error" in ReflectionFunction::export())
+--FILE--
+<?php
+
+function foo() {
+}
+
+class bar {
+ private function foo() {
+ }
+}
+
+Reflection::export(new ReflectionFunction('foo'));
+Reflection::export(new ReflectionMethod('bar', 'foo'));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Function [ <user> function foo ] {
+ @@ %sbug41061.php 3 - 4
+}
+
+Method [ <user> private method foo ] {
+ @@ %sbug41061.php 7 - 8
+}
+
+===DONE===
diff --git a/ext/reflection/tests/bug41884.phpt b/ext/reflection/tests/bug41884.phpt
new file mode 100644
index 0000000..f8c0a0a
--- /dev/null
+++ b/ext/reflection/tests/bug41884.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #41884 (ReflectionClass::getDefaultProperties() does not handle static attributes)
+--FILE--
+<?php
+
+class Foo
+{
+ protected static $fooStatic = 'foo';
+ protected $foo = 'foo';
+}
+
+$class = new ReflectionClass('Foo');
+
+var_dump($class->getDefaultProperties());
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(2) {
+ ["fooStatic"]=>
+ string(3) "foo"
+ ["foo"]=>
+ string(3) "foo"
+}
+Done
diff --git a/ext/reflection/tests/bug42976.phpt b/ext/reflection/tests/bug42976.phpt
new file mode 100644
index 0000000..2e4ade2
--- /dev/null
+++ b/ext/reflection/tests/bug42976.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Bug #42976 (Crash when constructor for newInstance() or newInstanceArgs() fails)
+--FILE--
+<?php
+
+Class C {
+ function __construct(&$x) {
+ $x = "x.changed";
+ }
+}
+
+$x = "x.original";
+new C($x); // OK
+var_dump($x);
+
+$rc = new ReflectionClass('C');
+$x = "x.original";
+$rc->newInstance($x); // causes crash
+var_dump($x);
+$x = "x.original";
+$rc->newInstanceArgs(array($x)); // causes crash
+var_dump($x);
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(9) "x.changed"
+
+Warning: Parameter 1 to C::__construct() expected to be a reference, value given in %sbug42976.php on line 15
+
+Warning: ReflectionClass::newInstance(): Invocation of C's constructor failed in %sbug42976.php on line 15
+string(10) "x.original"
+
+Warning: Parameter 1 to C::__construct() expected to be a reference, value given in %sbug42976.php on line 18
+
+Warning: ReflectionClass::newInstanceArgs(): Invocation of C's constructor failed in %sbug42976.php on line 18
+string(10) "x.original"
+Done
diff --git a/ext/reflection/tests/bug43926.phpt b/ext/reflection/tests/bug43926.phpt
new file mode 100644
index 0000000..95bdb9e
--- /dev/null
+++ b/ext/reflection/tests/bug43926.phpt
@@ -0,0 +1,67 @@
+--TEST--
+Bug #43926 (isInstance() isn't equivalent to instanceof operator)
+--FILE--
+<?php
+
+class E {
+}
+class D extends E {
+}
+
+class A extends D {
+}
+
+class C extends A {
+}
+
+$ra = new ReflectionClass('A');
+$rc = new ReflectionClass('C');
+$rd = new ReflectionClass('D');
+$re = new ReflectionClass('E');
+
+$ca = $ra->newInstance();
+$cc = $rc->newInstance();
+$cd = $rd->newInstance();
+$ce = $re->newInstance();
+
+print("Is? A ". ($ra->isInstance($ca) ? 'true' : 'false') .", instanceof: ". (($ca instanceof A) ? 'true' : 'false') ."\n");
+print("Is? C ". ($rc->isInstance($ca) ? 'true' : 'false') .", instanceof: ". (($ca instanceof C) ? 'true' : 'false') ."\n");
+print("Is? D ". ($rd->isInstance($ca) ? 'true' : 'false') .", instanceof: ". (($ca instanceof D) ? 'true' : 'false') ."\n");
+print("Is? E ". ($re->isInstance($ca) ? 'true' : 'false') .", instanceof: ". (($ca instanceof E) ? 'true' : 'false') ."\n");
+print "-\n";
+print("Is? A ". ($ra->isInstance($cc) ? 'true' : 'false') .", instanceof: ". (($cc instanceof A) ? 'true' : 'false') ."\n");
+print("Is? C ". ($rc->isInstance($cc) ? 'true' : 'false') .", instanceof: ". (($cc instanceof C) ? 'true' : 'false') ."\n");
+print("Is? D ". ($rd->isInstance($cc) ? 'true' : 'false') .", instanceof: ". (($cc instanceof D) ? 'true' : 'false') ."\n");
+print("Is? E ". ($re->isInstance($cc) ? 'true' : 'false') .", instanceof: ". (($cc instanceof E) ? 'true' : 'false') ."\n");
+print "-\n";
+print("Is? A ". ($ra->isInstance($cd) ? 'true' : 'false') .", instanceof: ". (($cd instanceof A) ? 'true' : 'false') ."\n");
+print("Is? C ". ($rc->isInstance($cd) ? 'true' : 'false') .", instanceof: ". (($cd instanceof C) ? 'true' : 'false') ."\n");
+print("Is? D ". ($rd->isInstance($cd) ? 'true' : 'false') .", instanceof: ". (($cd instanceof D) ? 'true' : 'false') ."\n");
+print("Is? E ". ($re->isInstance($cd) ? 'true' : 'false') .", instanceof: ". (($cd instanceof E) ? 'true' : 'false') ."\n");
+print "-\n";
+print("Is? A ". ($ra->isInstance($ce) ? 'true' : 'false') .", instanceof: ". (($ce instanceof A) ? 'true' : 'false') ."\n");
+print("Is? C ". ($rc->isInstance($ce) ? 'true' : 'false') .", instanceof: ". (($ce instanceof C) ? 'true' : 'false') ."\n");
+print("Is? D ". ($rd->isInstance($ce) ? 'true' : 'false') .", instanceof: ". (($ce instanceof D) ? 'true' : 'false') ."\n");
+print("Is? E ". ($re->isInstance($ce) ? 'true' : 'false') .", instanceof: ". (($ce instanceof E) ? 'true' : 'false') ."\n");
+
+?>
+--EXPECT--
+Is? A true, instanceof: true
+Is? C false, instanceof: false
+Is? D true, instanceof: true
+Is? E true, instanceof: true
+-
+Is? A true, instanceof: true
+Is? C true, instanceof: true
+Is? D true, instanceof: true
+Is? E true, instanceof: true
+-
+Is? A false, instanceof: false
+Is? C false, instanceof: false
+Is? D true, instanceof: true
+Is? E true, instanceof: true
+-
+Is? A false, instanceof: false
+Is? C false, instanceof: false
+Is? D false, instanceof: false
+Is? E true, instanceof: true
diff --git a/ext/reflection/tests/bug45139.phpt b/ext/reflection/tests/bug45139.phpt
new file mode 100644
index 0000000..6aa8426
--- /dev/null
+++ b/ext/reflection/tests/bug45139.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Bug #45139 (ReflectionProperty returns incorrect declaring class)
+--FILE--
+<?php
+
+class A {
+ private $foo;
+}
+
+class B extends A {
+ protected $bar;
+ private $baz;
+ private $quux;
+}
+
+class C extends B {
+ public $foo;
+ private $baz;
+ protected $quux;
+}
+
+$rc = new ReflectionClass('C');
+$rp = $rc->getProperty('foo');
+var_dump($rp->getDeclaringClass()->getName()); // c
+
+$rc = new ReflectionClass('A');
+$rp = $rc->getProperty('foo');
+var_dump($rp->getDeclaringClass()->getName()); // A
+
+$rc = new ReflectionClass('B');
+$rp = $rc->getProperty('bar');
+var_dump($rp->getDeclaringClass()->getName()); // B
+
+$rc = new ReflectionClass('C');
+$rp = $rc->getProperty('bar');
+var_dump($rp->getDeclaringClass()->getName()); // B
+
+$rc = new ReflectionClass('C');
+$rp = $rc->getProperty('baz');
+var_dump($rp->getDeclaringClass()->getName()); // C
+
+$rc = new ReflectionClass('B');
+$rp = $rc->getProperty('baz');
+var_dump($rp->getDeclaringClass()->getName()); // B
+
+$rc = new ReflectionClass('C');
+$rp = $rc->getProperty('quux');
+var_dump($rp->getDeclaringClass()->getName()); // C
+
+?>
+--EXPECT--
+string(1) "C"
+string(1) "A"
+string(1) "B"
+string(1) "B"
+string(1) "C"
+string(1) "B"
+string(1) "C"
diff --git a/ext/reflection/tests/bug45571.phpt b/ext/reflection/tests/bug45571.phpt
new file mode 100644
index 0000000..4df542e
--- /dev/null
+++ b/ext/reflection/tests/bug45571.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #45571 (ReflectionClass::export() shows superclasses' private static methods.)
+--FILE--
+<?php
+
+Class A {
+ static private $a = 0;
+ static protected $b = 1;
+ static public $c = 2;
+
+ private function f() {}
+ private static function sf() {}
+}
+
+Class C extends A { }
+
+ReflectionClass::export("C");
+
+?>
+--EXPECTF--
+Class [ <user> class C extends A ] {
+ @@ %s 12-12
+
+ - Constants [0] {
+ }
+
+ - Static properties [2] {
+ Property [ protected static $b ]
+ Property [ public static $c ]
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [0] {
+ }
+}
diff --git a/ext/reflection/tests/bug45765.phpt b/ext/reflection/tests/bug45765.phpt
new file mode 100644
index 0000000..b0c1be2
--- /dev/null
+++ b/ext/reflection/tests/bug45765.phpt
@@ -0,0 +1,82 @@
+--TEST--
+Fixed bug #45765 (ReflectionObject with default parameters of self::xxx cause an error)
+--FILE--
+<?php
+
+class foo2 {
+ const BAR = 'foobar';
+}
+
+class foo extends foo2 {
+ const BAR = "foo's bar";
+
+ function test($a = self::BAR) {
+ }
+
+ function test2($a = parent::BAR) {
+ }
+
+ function test3($a = foo::BAR) {
+ }
+
+ function test4($a = foo2::BAR) {
+ }
+}
+
+ReflectionObject::export(new foo);
+
+?>
+--EXPECTF--
+Object of class [ <user> class foo extends foo2 ] {
+ @@ %s 7-21
+
+ - Constants [1] {
+ Constant [ string BAR ] { foo's bar }
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Dynamic properties [0] {
+ }
+
+ - Methods [4] {
+ Method [ <user> public method test ] {
+ @@ %s 10 - 11
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $a = 'foo's bar' ]
+ }
+ }
+
+ Method [ <user> public method test2 ] {
+ @@ %s 13 - 14
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $a = 'foobar' ]
+ }
+ }
+
+ Method [ <user> public method test3 ] {
+ @@ %s 16 - 17
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $a = 'foo's bar' ]
+ }
+ }
+
+ Method [ <user> public method test4 ] {
+ @@ %s 19 - 20
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $a = 'foobar' ]
+ }
+ }
+ }
+}
diff --git a/ext/reflection/tests/bug46064.phpt b/ext/reflection/tests/bug46064.phpt
new file mode 100644
index 0000000..510e71b
--- /dev/null
+++ b/ext/reflection/tests/bug46064.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Bug #46064 (Exception when creating ReflectionProperty object on dynamicly created property)
+--FILE--
+<?php
+
+class x {
+ public $zzz = 2;
+}
+
+$o = new x;
+$o->z = 1000;
+$o->zzz = 3;
+
+var_dump($h = new reflectionproperty($o, 'z'));
+var_dump($h->isDefault());
+var_dump($h->isPublic());
+var_dump($h->isStatic());
+var_dump($h->getName());
+var_dump(Reflection::getModifierNames($h->getModifiers()));
+var_dump($h->getValue($o));
+
+print "---------------------------\n";
+try {
+ var_dump(new reflectionproperty($o, 'zz'));
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+var_dump(new reflectionproperty($o, 'zzz'));
+
+class test {
+ protected $a = 1;
+}
+
+class bar extends test {
+ public function __construct() {
+ $this->foobar = 2;
+ $this->a = 200;
+
+ $p = new reflectionproperty($this, 'foobar');
+ var_dump($p->getValue($this), $p->isDefault(), $p->isPublic());
+ }
+}
+
+new bar;
+
+?>
+===DONE===
+--EXPECTF--
+object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(1) "z"
+ ["class"]=>
+ string(1) "x"
+}
+bool(false)
+bool(true)
+bool(false)
+string(1) "z"
+array(1) {
+ [0]=>
+ string(6) "public"
+}
+int(1000)
+---------------------------
+string(30) "Property x::$zz does not exist"
+object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(3) "zzz"
+ ["class"]=>
+ string(1) "x"
+}
+int(2)
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/reflection/tests/bug46064_2.phpt b/ext/reflection/tests/bug46064_2.phpt
new file mode 100644
index 0000000..da14148
--- /dev/null
+++ b/ext/reflection/tests/bug46064_2.phpt
@@ -0,0 +1,74 @@
+--TEST--
+Bug #46064.2 (Exception when creating ReflectionProperty object on dynamicly created property)
+--FILE--
+<?php
+
+class foo {
+}
+
+$x = new foo;
+$x->test = 2000;
+
+
+$p = new ReflectionObject($x);
+var_dump($p->getProperty('test'));
+
+
+class bar {
+ public function __construct() {
+ $this->a = 1;
+ }
+}
+
+class test extends bar {
+ private $b = 2;
+
+ public function __construct() {
+ parent::__construct();
+
+ $p = new reflectionobject($this);
+ var_dump($h = $p->getProperty('a'));
+ var_dump($h->isDefault(), $h->isProtected(), $h->isPrivate(), $h->isPublic(), $h->isStatic());
+ var_dump($p->getProperties());
+ }
+}
+
+new test;
+
+?>
+===DONE===
+--EXPECTF--
+object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(4) "test"
+ ["class"]=>
+ string(3) "foo"
+}
+object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(1) "a"
+ ["class"]=>
+ string(4) "test"
+}
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+array(2) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(1) "b"
+ ["class"]=>
+ string(4) "test"
+ }
+ [1]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(1) "a"
+ ["class"]=>
+ string(4) "test"
+ }
+}
+===DONE=== \ No newline at end of file
diff --git a/ext/reflection/tests/bug46205.phpt b/ext/reflection/tests/bug46205.phpt
new file mode 100644
index 0000000..ef7a692
--- /dev/null
+++ b/ext/reflection/tests/bug46205.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #46205 (Closure - Memory leaks when ReflectionException is thrown)
+--FILE--
+<?php
+$x = new reflectionmethod('reflectionparameter', 'export');
+$y = function() { };
+
+try {
+ $x->invokeArgs(new reflectionparameter('trim', 'str'), array($y, 1));
+} catch (Exception $e) { }
+?>
+ok
+--EXPECT--
+ok
diff --git a/ext/reflection/tests/bug47254.phpt b/ext/reflection/tests/bug47254.phpt
new file mode 100644
index 0000000..83593a4
--- /dev/null
+++ b/ext/reflection/tests/bug47254.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Bug #47254
+--CREDITS--
+Sebastian Schürmann
+sebs@php.net
+Testfest 2009 Munich
+--FILE--
+<?php
+class A
+{
+ protected function a() {}
+
+}
+
+class B extends A
+{
+ public function b() {}
+}
+
+$B = new B();
+$R = new ReflectionObject($B);
+$m = $R->getMethods();
+print_r($m);
+
+?>
+--EXPECT--
+Array
+(
+ [0] => ReflectionMethod Object
+ (
+ [name] => b
+ [class] => B
+ )
+
+ [1] => ReflectionMethod Object
+ (
+ [name] => a
+ [class] => A
+ )
+
+)
diff --git a/ext/reflection/tests/bug48336.phpt b/ext/reflection/tests/bug48336.phpt
new file mode 100644
index 0000000..ee90675
--- /dev/null
+++ b/ext/reflection/tests/bug48336.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Bug #48286 (ReflectionProperty::getDeclaringClass() does not work with redeclared properties)
+--FILE--
+<?php
+class A {
+}
+
+class B extends A {
+ static protected $prop;
+}
+
+class C extends B {
+ static protected $prop;
+}
+
+class D extends C {
+}
+
+class E extends D {
+}
+
+class F extends E {
+ static protected $prop;
+}
+
+$class = 'A';
+for($class = 'A'; $class <= 'F'; $class ++) {
+ print($class.' => ');
+ try {
+ $rp = new ReflectionProperty($class, 'prop');
+ print($rp->getDeclaringClass()->getName());
+ } catch(Exception $e) {
+ print('N/A');
+ }
+ print("\n");
+}
+?>
+--EXPECT--
+A => N/A
+B => B
+C => C
+D => C
+E => C
+F => F
diff --git a/ext/reflection/tests/bug48757.phpt b/ext/reflection/tests/bug48757.phpt
new file mode 100644
index 0000000..a5ced91
--- /dev/null
+++ b/ext/reflection/tests/bug48757.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #48757 (ReflectionFunction::invoke() parameter issues)
+--FILE--
+<?php
+function test() {
+ echo "Hello World\n";
+}
+
+function another_test($parameter) {
+ var_dump($parameter);
+}
+
+$func = new ReflectionFunction('test');
+$func->invoke();
+
+$func = new ReflectionFunction('another_test');
+$func->invoke('testing');
+?>
+--EXPECT--
+Hello World
+string(7) "testing"
diff --git a/ext/reflection/tests/bug49074.phpt b/ext/reflection/tests/bug49074.phpt
new file mode 100644
index 0000000..7ce23b4
--- /dev/null
+++ b/ext/reflection/tests/bug49074.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #49074 (private class static fields can be modified by using reflection)
+--FILE--
+<?php
+class Test {
+ private static $data1 = 1;
+ private static $data4 = 4;
+}
+
+class Test2 extends Test {
+ private static $data2 = 2;
+ public static $data3 = 3;
+}
+
+$r = new ReflectionClass('Test2');
+$m = $r->getStaticProperties();
+
+$m['data1'] = 100;
+$m['data2'] = 200;
+$m['data3'] = 300;
+$m['data4'] = 400;
+
+var_dump($r->getStaticProperties());
+?>
+--EXPECT--
+array(2) {
+ ["data2"]=>
+ int(2)
+ ["data3"]=>
+ int(3)
+}
diff --git a/ext/reflection/tests/bug49092.phpt b/ext/reflection/tests/bug49092.phpt
new file mode 100644
index 0000000..460a131
--- /dev/null
+++ b/ext/reflection/tests/bug49092.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #49092 (ReflectionFunction fails to work with functions in fully qualified namespaces)
+--FILE--
+<?php
+namespace ns;
+function func(){}
+new \ReflectionFunction('ns\func');
+new \ReflectionFunction('\ns\func');
+echo "Ok\n"
+?>
+--EXPECT--
+Ok
diff --git a/ext/reflection/tests/bug49719.phpt b/ext/reflection/tests/bug49719.phpt
new file mode 100644
index 0000000..215140a
--- /dev/null
+++ b/ext/reflection/tests/bug49719.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Bug #49719 (ReflectionClass::hasProperty returns true for a private property in base class)
+--FILE--
+<?php
+
+class A {
+ private $a;
+}
+class B extends A {
+ private $b;
+}
+
+try {
+ $b = new B;
+ $ref = new ReflectionClass($b);
+
+ var_dump(property_exists('b', 'a'));
+ var_dump(property_exists($b, 'a'));
+ var_dump($ref->hasProperty('a'));
+ var_dump($ref->getProperty('a'));
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+class A2 {
+ private $a = 1;
+}
+
+class B2 extends A2 {
+ private $a = 2;
+}
+
+$b2 = new ReflectionClass('B2');
+$prop = $b2->getProperty('a');
+$prop->setAccessible(true);
+var_dump($prop->getValue(new b2));
+
+?>
+--EXPECTF--
+bool(false)
+bool(false)
+bool(false)
+%string|unicode%(25) "Property a does not exist"
+int(2)
diff --git a/ext/reflection/tests/bug51905.phpt b/ext/reflection/tests/bug51905.phpt
new file mode 100644
index 0000000..8969924
--- /dev/null
+++ b/ext/reflection/tests/bug51905.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #51905 (ReflectionParameter fails if default value is an array with an access to self::)
+--FILE--
+<?php
+
+class Bar {
+ const Y = 20;
+}
+
+class Foo extends Bar {
+ const X = 12;
+ public function x($x = 1, $y = array(self::X), $z = parent::Y) {}
+}
+
+$clazz = new ReflectionClass('Foo');
+$method = $clazz->getMethod('x');
+foreach ($method->getParameters() as $param) {
+ if ( $param->isDefaultValueAvailable())
+ echo '$', $param->getName(), ' : ', var_export($param->getDefaultValue(), 1), "\n";
+}
+
+?>
+--EXPECT--
+$x : 1
+$y : array (
+ 0 => 12,
+)
+$z : 20
diff --git a/ext/reflection/tests/bug51911.phpt b/ext/reflection/tests/bug51911.phpt
new file mode 100644
index 0000000..12eb459
--- /dev/null
+++ b/ext/reflection/tests/bug51911.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with constant array)
+--FILE--
+<?php
+
+class Foo {
+ const X = 1;
+ public function x($x = array(1)) {}
+}
+
+$clazz = new ReflectionClass('Foo');
+$method = $clazz->getMethod('x');
+foreach ($method->getParameters() as $param) {
+ if ( $param->isDefaultValueAvailable())
+ echo '$', $param->getName(), ' : ', var_export($param->getDefaultValue(), 1), "\n";
+}
+
+?>
+--EXPECT--
+$x : array (
+ 0 => 1,
+)
diff --git a/ext/reflection/tests/bug52057.phpt b/ext/reflection/tests/bug52057.phpt
new file mode 100644
index 0000000..b807035
--- /dev/null
+++ b/ext/reflection/tests/bug52057.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Bug #52057 (ReflectionClass fails on Closure class)
+--FILE--
+<?php
+
+$closure = function($a) { echo $a; };
+
+$reflection = new ReflectionClass('closure');
+var_dump($reflection->hasMethod('__invoke')); // true
+
+$reflection = new ReflectionClass($closure);
+var_dump($reflection->hasMethod('__invoke')); // true
+
+$reflection = new ReflectionObject($closure);
+var_dump($reflection->hasMethod('__invoke')); // true
+
+$reflection = new ReflectionClass('closure');
+var_dump($h = $reflection->getMethod('__invoke')); // true
+var_dump($h->class.'::'.$h->getName());
+
+$reflection = new ReflectionClass($closure);
+var_dump($h = $reflection->getMethod('__invoke')); // true
+var_dump($h->class.'::'.$h->getName());
+
+$reflection = new ReflectionObject($closure);
+var_dump($h = $reflection->getMethod('__invoke')); // true
+var_dump($h->class.'::'.$h->getName());
+
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(8) "__invoke"
+ ["class"]=>
+ string(7) "Closure"
+}
+string(17) "Closure::__invoke"
+object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(8) "__invoke"
+ ["class"]=>
+ string(7) "Closure"
+}
+string(17) "Closure::__invoke"
+object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(8) "__invoke"
+ ["class"]=>
+ string(7) "Closure"
+}
+string(17) "Closure::__invoke"
diff --git a/ext/reflection/tests/bug52854.phpt b/ext/reflection/tests/bug52854.phpt
new file mode 100644
index 0000000..255522d
--- /dev/null
+++ b/ext/reflection/tests/bug52854.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #52854: ReflectionClass::newInstanceArgs does not work for classes without constructors
+--FILE--
+<?php
+class Test {
+}
+$c = new ReflectionClass('Test');
+var_dump(new Test);
+var_dump(new Test());
+var_dump($c->newInstance());
+var_dump($c->newInstanceArgs(array()));
+
+try {
+ var_dump($c->newInstanceArgs(array(1)));
+} catch(ReflectionException $e) {
+ echo $e->getMessage()."\n";
+}
+?>
+--EXPECTF--
+object(Test)#%d (0) {
+}
+object(Test)#%d (0) {
+}
+object(Test)#%d (0) {
+}
+object(Test)#%d (0) {
+}
+Class Test does not have a constructor, so you cannot pass any constructor arguments
diff --git a/ext/reflection/tests/bug53366.phpt b/ext/reflection/tests/bug53366.phpt
new file mode 100644
index 0000000..5fb119d
--- /dev/null
+++ b/ext/reflection/tests/bug53366.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #53366 (Reflection doesnt get dynamic property value from getProperty())
+--FILE--
+<?php
+
+class UserClass {
+}
+
+$myClass = new UserClass;
+$myClass->id = 1000;
+
+$reflect = new ReflectionObject($myClass);
+
+var_dump($reflect->getProperty('id'));
+var_dump($reflect->getProperty('id')->getValue($myClass));
+
+?>
+--EXPECTF--
+object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(2) "id"
+ ["class"]=>
+ string(9) "UserClass"
+}
+int(1000)
diff --git a/ext/reflection/tests/bug53915.phpt b/ext/reflection/tests/bug53915.phpt
new file mode 100644
index 0000000..f2f2ae5
--- /dev/null
+++ b/ext/reflection/tests/bug53915.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #53915 - ReflectionClass::getConstant(s) emits fatal error on selfreferencing constants
+--FILE--
+<?php
+Class Foo
+{
+ const A = 1;
+ const B = self::A;
+}
+
+$rc = new ReflectionClass('Foo');
+print_r($rc->getConstants());
+
+Class Foo2
+{
+ const A = 1;
+ const B = self::A;
+}
+
+$rc = new ReflectionClass('Foo2');
+print_r($rc->getConstant('B'));
+--EXPECT--
+Array
+(
+ [A] => 1
+ [B] => 1
+)
+1
diff --git a/ext/reflection/tests/bug60357.phpt b/ext/reflection/tests/bug60357.phpt
new file mode 100644
index 0000000..a5ddd40
--- /dev/null
+++ b/ext/reflection/tests/bug60357.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #60357 (__toString() method triggers E_NOTICE "Array to string conversion")
+--FILE--
+<?php
+function foo( array $x = array( 'a', 'b' ) ) {}
+$r = new ReflectionParameter( 'foo', 0 );
+echo $r->__toString();
+?>
+--EXPECTF--
+Parameter #0 [ <optional> array $x = Array ]
diff --git a/ext/reflection/tests/bug60367.phpt b/ext/reflection/tests/bug60367.phpt
new file mode 100644
index 0000000..5c4a098
--- /dev/null
+++ b/ext/reflection/tests/bug60367.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #60367 (Reflection and Late Static Binding)
+--FILE--
+<?php
+abstract class A {
+
+ const WHAT = 'A';
+
+ public static function call() {
+ echo static::WHAT;
+ }
+
+}
+
+class B extends A {
+
+ const WHAT = 'B';
+
+}
+
+$method = new ReflectionMethod("b::call");
+$method->invoke(null);
+$method->invokeArgs(null, array());
+$method = new ReflectionMethod("A::call");
+$method->invoke(null);
+$method->invokeArgs(null, array());
+--EXPECTF--
+BBAA
diff --git a/ext/reflection/tests/bug61388.phpt b/ext/reflection/tests/bug61388.phpt
new file mode 100644
index 0000000..75c0300
--- /dev/null
+++ b/ext/reflection/tests/bug61388.phpt
@@ -0,0 +1,32 @@
+--TEST--
+ReflectionObject:getProperties() issues invalid reads when it get_properties returns a hash table with (inaccessible) dynamic numeric properties
+--FILE--
+<?php
+$x = new ArrayObject();
+$x[0] = 'test string 2';
+$x['test'] = 'test string 3';
+$reflObj = new ReflectionObject($x);
+print_r($reflObj->getProperties(ReflectionProperty::IS_PUBLIC));
+
+$x = (object)array("a", "oo" => "b");
+$reflObj = new ReflectionObject($x);
+print_r($reflObj->getProperties(ReflectionProperty::IS_PUBLIC));
+--EXPECT--
+Array
+(
+ [0] => ReflectionProperty Object
+ (
+ [name] => test
+ [class] => ArrayObject
+ )
+
+)
+Array
+(
+ [0] => ReflectionProperty Object
+ (
+ [name] => oo
+ [class] => stdClass
+ )
+
+)
diff --git a/ext/reflection/tests/bug62384.phpt b/ext/reflection/tests/bug62384.phpt
new file mode 100644
index 0000000..90a871f
--- /dev/null
+++ b/ext/reflection/tests/bug62384.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #62384 (Attempting to invoke a Closure more than once causes segfaul)
+--FILE--
+<?php
+
+$closure1 = function($val){ return $val; };
+$closure2 = function($val){ return $val; };
+
+$reflection_class = new ReflectionClass($closure1);
+$reflection_method = $reflection_class->getMethod('__invoke');
+
+$arguments1 = array('hello');
+$arguments2 = array('world');
+
+var_dump($reflection_method->invokeArgs($closure1, $arguments1));
+var_dump($reflection_method->invokeArgs($closure2, $arguments2));
+
+?>
+--EXPECT--
+string(5) "hello"
+string(5) "world"
diff --git a/ext/reflection/tests/bug62715.phpt b/ext/reflection/tests/bug62715.phpt
new file mode 100644
index 0000000..feb67f6
--- /dev/null
+++ b/ext/reflection/tests/bug62715.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #62715 (ReflectionParameter::isDefaultValueAvailable() wrong result)
+--FILE--
+<?php
+
+function test(PDO $a = null, $b = 0, array $c) {}
+$r = new ReflectionFunction('test');
+
+foreach ($r->getParameters() as $p) {
+ var_dump($p->isDefaultValueAvailable());
+}
+
+foreach ($r->getParameters() as $p) {
+ if ($p->isDefaultValueAvailable()) {
+ var_dump($p->getDefaultValue());
+ }
+}
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+NULL
+int(0)
diff --git a/ext/reflection/tests/bug63399.phpt b/ext/reflection/tests/bug63399.phpt
new file mode 100644
index 0000000..393b861
--- /dev/null
+++ b/ext/reflection/tests/bug63399.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Bug #63399 (ReflectionClass::getTraitAliases() incorrectly resolves traitnames)
+--FILE--
+<?php
+trait Trait1 {
+ public function run() {}
+ public function say() {}
+}
+
+trait Trait2 {
+ public function run() {}
+ public function say() {}
+}
+
+class MyClass
+{
+ use Trait1, Trait2 {
+ Trait1::run as execute;
+ Trait1::say insteadof Trait2;
+ Trait2::run insteadof Trait1;
+ Trait2::say as talk;
+ }
+}
+
+$ref = new ReflectionClass('MyClass');
+
+print_r($ref->getTraitAliases());
+print_r($ref->getTraits());
+
+?>
+--EXPECT--
+Array
+(
+ [execute] => Trait1::run
+ [talk] => Trait2::say
+)
+Array
+(
+ [Trait1] => ReflectionClass Object
+ (
+ [name] => Trait1
+ )
+
+ [Trait2] => ReflectionClass Object
+ (
+ [name] => Trait2
+ )
+
+)
diff --git a/ext/reflection/tests/bug63614.phpt b/ext/reflection/tests/bug63614.phpt
new file mode 100644
index 0000000..c13ff4b
--- /dev/null
+++ b/ext/reflection/tests/bug63614.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Bug #63614 (Fatal error on Reflection)
+--FILE--
+<?php
+function dummy() {
+ static $a = array();
+}
+
+class Test
+{
+ const A = 0;
+
+ public function func()
+ {
+ static $a = array(
+ self::A => 'a'
+ );
+ }
+}
+
+$reflect = new ReflectionFunction("dummy");
+print_r($reflect->getStaticVariables());
+$reflect = new ReflectionMethod('Test', 'func');
+print_r($reflect->getStaticVariables());
+?>
+--EXPECT--
+Array
+(
+ [a] => Array
+ (
+ )
+
+)
+Array
+(
+ [a] => Array
+ (
+ [0] => a
+ )
+
+)
diff --git a/ext/reflection/tests/closures_001.phpt b/ext/reflection/tests/closures_001.phpt
new file mode 100644
index 0000000..6cc7e67
--- /dev/null
+++ b/ext/reflection/tests/closures_001.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Reflection on closures
+--FILE--
+<?php
+
+$closure = function($a, $b = 0) { };
+
+$ro = new ReflectionObject($closure);
+$rm = $ro->getMethod('__invoke');
+var_dump($rm->getNumberOfParameters());
+var_dump($rm->getNumberOfRequiredParameters());
+$rms = $ro->getMethods();
+foreach($rms as $rm) {
+ if ($rm->getName() == '__invoke') {
+ var_dump($rm->getNumberOfParameters());
+ var_dump($rm->getNumberOfRequiredParameters());
+ }
+}
+
+echo "---\n";
+
+$rm = new ReflectionMethod($closure, '__invoke');
+var_dump($rm->getName());
+var_dump($rm->getNumberOfParameters());
+var_dump($rm->getNumberOfRequiredParameters());
+
+echo "---\n";
+
+$rp = new ReflectionParameter(array($closure, '__invoke'), 0);
+var_dump($rp->isOptional());
+$rp = new ReflectionParameter(array($closure, '__invoke'), 1);
+var_dump($rp->isOptional());
+$rp = new ReflectionParameter(array($closure, '__invoke'), 'a');
+var_dump($rp->isOptional());
+$rp = new ReflectionParameter(array($closure, '__invoke'), 'b');
+var_dump($rp->isOptional());
+
+echo "---\n";
+
+$rp = new ReflectionParameter($closure, 0);
+var_dump($rp->isOptional());
+$rp = new ReflectionParameter($closure, 1);
+var_dump($rp->isOptional());
+$rp = new ReflectionParameter($closure, 'a');
+var_dump($rp->isOptional());
+$rp = new ReflectionParameter($closure, 'b');
+var_dump($rp->isOptional());
+
+?>
+===DONE===
+--EXPECTF--
+int(2)
+int(1)
+int(2)
+int(1)
+---
+string(8) "__invoke"
+int(2)
+int(1)
+---
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+---
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/reflection/tests/closures_002.phpt b/ext/reflection/tests/closures_002.phpt
new file mode 100644
index 0000000..e8b080f
--- /dev/null
+++ b/ext/reflection/tests/closures_002.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Reflection on invokable objects
+--FILE--
+<?php
+
+class Test {
+ function __invoke($a, $b = 0) { }
+}
+
+$rm = new ReflectionMethod(new Test, '__invoke');
+var_dump($rm->getName());
+var_dump($rm->getNumberOfParameters());
+var_dump($rm->getNumberOfRequiredParameters());
+
+$rp = new ReflectionParameter(array(new Test, '__invoke'), 0);
+var_dump($rp->isOptional());
+
+$rp = new ReflectionParameter(array(new Test, '__invoke'), 1);
+var_dump($rp->isOptional());
+
+?>
+===DONE===
+--EXPECTF--
+string(8) "__invoke"
+int(2)
+int(1)
+bool(false)
+bool(true)
+===DONE===
diff --git a/ext/reflection/tests/closures_003.phpt b/ext/reflection/tests/closures_003.phpt
new file mode 100644
index 0000000..4483dc0
--- /dev/null
+++ b/ext/reflection/tests/closures_003.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Reflection on closures: Segfaults with getParameters() and getDeclaringFunction()
+--FILE--
+<?php
+
+$closure = function($a, $b = 0) { };
+
+$method = new ReflectionMethod ($closure, '__invoke');
+$params = $method->getParameters ();
+unset ($method);
+$method = $params[0]->getDeclaringFunction ();
+unset ($params);
+echo $method->getName ()."\n";
+
+$parameter = new ReflectionParameter (array ($closure, '__invoke'), 'b');
+$method = $parameter->getDeclaringFunction ();
+unset ($parameter);
+echo $method->getName ()."\n";
+
+?>
+===DONE===
+--EXPECTF--
+__invoke
+__invoke
+===DONE===
diff --git a/ext/reflection/tests/closures_003_v1.phpt b/ext/reflection/tests/closures_003_v1.phpt
new file mode 100644
index 0000000..1b8e1c4
--- /dev/null
+++ b/ext/reflection/tests/closures_003_v1.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Reflection on closures: Segfaults with getParameters() and getDeclaringFunction()
+--FILE--
+<?php
+
+$closure = function($a, $b = 0) { };
+
+$method = new ReflectionFunction ($closure);
+$params = $method->getParameters ();
+unset ($method);
+$method = $params[0]->getDeclaringFunction ();
+unset ($params);
+echo $method->getName ()."\n";
+
+$parameter = new ReflectionParameter ($closure, 'b');
+$method = $parameter->getDeclaringFunction ();
+unset ($parameter);
+echo $method->getName ()."\n";
+
+?>
+===DONE===
+--EXPECTF--
+{closure}
+{closure}
+===DONE===
diff --git a/ext/reflection/tests/closures_004.phpt b/ext/reflection/tests/closures_004.phpt
new file mode 100644
index 0000000..807aea1
--- /dev/null
+++ b/ext/reflection/tests/closures_004.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Reflection on closures: Segfault with getClosure() on closure itself
+--FILE--
+<?php
+$closure = function() { echo "Invoked!\n"; };
+
+$method = new ReflectionFunction ($closure);
+
+$closure2 = $method->getClosure ();
+
+$closure2 ();
+$closure2->__invoke ();
+
+unset ($closure);
+
+$closure2 ();
+$closure2->__invoke ();
+
+$closure = function() { echo "Invoked!\n"; };
+
+$method = new ReflectionMethod ($closure, '__invoke');
+$closure2 = $method->getClosure ($closure);
+
+$closure2 ();
+$closure2->__invoke ();
+
+unset ($closure);
+
+$closure2 ();
+$closure2->__invoke ();
+
+?>
+===DONE===
+--EXPECTF--
+Invoked!
+Invoked!
+Invoked!
+Invoked!
+Invoked!
+Invoked!
+Invoked!
+Invoked!
+===DONE===
diff --git a/ext/reflection/tests/exception.inc b/ext/reflection/tests/exception.inc
new file mode 100644
index 0000000..e403339
--- /dev/null
+++ b/ext/reflection/tests/exception.inc
@@ -0,0 +1,16 @@
+<?php
+class ReflectionExceptionEx extends ReflectionException {
+ function MyException($_errno, $_errmsg) {
+ $this->errno = $_errno;
+ $this->errmsg = $_errmsg;
+ }
+
+ function getErrno() {
+ return $this->errno;
+ }
+
+ function getErrmsg() {
+ return $this->errmsg;
+ }
+}
+?>
diff --git a/ext/reflection/tests/included4.inc b/ext/reflection/tests/included4.inc
new file mode 100644
index 0000000..8894725
--- /dev/null
+++ b/ext/reflection/tests/included4.inc
@@ -0,0 +1,9 @@
+<?php
+echo __FILE__ . "\n";
+echo __LINE__ . "\n";
+
+function g() {
+ echo __FILE__ . "\n";
+ echo __LINE__ . "\n";
+}
+?> \ No newline at end of file
diff --git a/ext/reflection/tests/parameters_001.phpt b/ext/reflection/tests/parameters_001.phpt
new file mode 100644
index 0000000..972b97c
--- /dev/null
+++ b/ext/reflection/tests/parameters_001.phpt
@@ -0,0 +1,38 @@
+--TEST--
+ReflectionParameter Check for parameter being optional
+--FILE--
+<?php
+
+class Test {
+ function func($x, $y = NULL){
+ }
+}
+
+
+$f = new ReflectionMethod('Test', 'func');
+var_dump($f->getNumberOfParameters());
+var_dump($f->getNumberOfRequiredParameters());
+
+$p = new ReflectionParameter(array('Test', 'func'), 'x');
+var_dump($p->isOptional());
+
+$p = new ReflectionParameter(array('Test', 'func'), 'y');
+var_dump($p->isOptional());
+
+try {
+ $p = new ReflectionParameter(array('Test', 'func'), 'z');
+ var_dump($p->isOptional());
+}
+catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+===DONE===
+--EXPECT--
+int(2)
+int(1)
+bool(false)
+bool(true)
+string(54) "The parameter specified by its name could not be found"
+===DONE===
diff --git a/ext/reflection/tests/parameters_002.phpt b/ext/reflection/tests/parameters_002.phpt
new file mode 100644
index 0000000..a861910
--- /dev/null
+++ b/ext/reflection/tests/parameters_002.phpt
@@ -0,0 +1,207 @@
+--TEST--
+ReflectionParameter::getClass(), getDeclaringClass(), getDeclaringFunction()
+--FILE--
+<?php
+
+function test($nix, Array $ar, &$ref, stdClass $std, NonExistingClass $na, stdClass &$opt = NULL, $def = "FooBar")
+{
+}
+
+class test
+{
+ function test($nix, Array $ar, &$ref, stdClass $std, NonExistingClass $na, stdClass $opt = NULL, $def = "FooBar")
+ {
+ }
+}
+
+function check_params_decl_func($r, $f)
+{
+ $c = $r->$f();
+ echo $f . ': ' . ($c ? ($c instanceof ReflectionMethod ? $c->class . '::' : '') . $c->name : 'NULL') . "()\n";
+}
+
+function check_params_decl_class($r, $f)
+{
+ $c = $r->$f();
+ echo $f . ': ' . ($c ? $c->name : 'NULL') . "\n";
+}
+
+function check_params_func($r, $f)
+{
+ echo $f . ': ';
+ $v = $r->$f();
+ var_dump($v);
+}
+
+function check_params($r)
+{
+ echo "#####" . ($r instanceof ReflectionMethod ? $r->class . '::' : '') . $r->name . "()#####\n";
+ $i = 0;
+ foreach($r->getParameters() as $p)
+ {
+ echo "===" . $i . "===\n";
+ $i++;
+ check_params_func($p, 'getName');
+ check_params_func($p, 'isPassedByReference');
+ try
+ {
+ check_params_decl_class($p, 'getClass');
+ }
+ catch(ReflectionException $e)
+ {
+ echo $e->getMessage() . "\n";
+ }
+ check_params_decl_class($p, 'getDeclaringClass');
+// check_params_decl_func($p, 'getDeclaringFunction');
+ check_params_func($p, 'isArray');
+ check_params_func($p, 'allowsNull');
+ check_params_func($p, 'isOptional');
+ check_params_func($p, 'isDefaultValueAvailable');
+ if ($p->isOptional())
+ {
+ check_params_func($p, 'getDefaultValue');
+ }
+ }
+}
+
+check_params(new ReflectionFunction('test'));
+
+check_params(new ReflectionMethod('test::test'));
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+#####test()#####
+===0===
+getName: string(3) "nix"
+isPassedByReference: bool(false)
+getClass: NULL
+getDeclaringClass: NULL
+isArray: bool(false)
+allowsNull: bool(true)
+isOptional: bool(false)
+isDefaultValueAvailable: bool(false)
+===1===
+getName: string(2) "ar"
+isPassedByReference: bool(false)
+getClass: NULL
+getDeclaringClass: NULL
+isArray: bool(true)
+allowsNull: bool(false)
+isOptional: bool(false)
+isDefaultValueAvailable: bool(false)
+===2===
+getName: string(3) "ref"
+isPassedByReference: bool(true)
+getClass: NULL
+getDeclaringClass: NULL
+isArray: bool(false)
+allowsNull: bool(true)
+isOptional: bool(false)
+isDefaultValueAvailable: bool(false)
+===3===
+getName: string(3) "std"
+isPassedByReference: bool(false)
+getClass: stdClass
+getDeclaringClass: NULL
+isArray: bool(false)
+allowsNull: bool(false)
+isOptional: bool(false)
+isDefaultValueAvailable: bool(false)
+===4===
+getName: string(2) "na"
+isPassedByReference: bool(false)
+Class NonExistingClass does not exist
+getDeclaringClass: NULL
+isArray: bool(false)
+allowsNull: bool(false)
+isOptional: bool(false)
+isDefaultValueAvailable: bool(false)
+===5===
+getName: string(3) "opt"
+isPassedByReference: bool(true)
+getClass: stdClass
+getDeclaringClass: NULL
+isArray: bool(false)
+allowsNull: bool(true)
+isOptional: bool(true)
+isDefaultValueAvailable: bool(true)
+getDefaultValue: NULL
+===6===
+getName: string(3) "def"
+isPassedByReference: bool(false)
+getClass: NULL
+getDeclaringClass: NULL
+isArray: bool(false)
+allowsNull: bool(true)
+isOptional: bool(true)
+isDefaultValueAvailable: bool(true)
+getDefaultValue: string(6) "FooBar"
+#####test::test()#####
+===0===
+getName: string(3) "nix"
+isPassedByReference: bool(false)
+getClass: NULL
+getDeclaringClass: test
+isArray: bool(false)
+allowsNull: bool(true)
+isOptional: bool(false)
+isDefaultValueAvailable: bool(false)
+===1===
+getName: string(2) "ar"
+isPassedByReference: bool(false)
+getClass: NULL
+getDeclaringClass: test
+isArray: bool(true)
+allowsNull: bool(false)
+isOptional: bool(false)
+isDefaultValueAvailable: bool(false)
+===2===
+getName: string(3) "ref"
+isPassedByReference: bool(true)
+getClass: NULL
+getDeclaringClass: test
+isArray: bool(false)
+allowsNull: bool(true)
+isOptional: bool(false)
+isDefaultValueAvailable: bool(false)
+===3===
+getName: string(3) "std"
+isPassedByReference: bool(false)
+getClass: stdClass
+getDeclaringClass: test
+isArray: bool(false)
+allowsNull: bool(false)
+isOptional: bool(false)
+isDefaultValueAvailable: bool(false)
+===4===
+getName: string(2) "na"
+isPassedByReference: bool(false)
+Class NonExistingClass does not exist
+getDeclaringClass: test
+isArray: bool(false)
+allowsNull: bool(false)
+isOptional: bool(false)
+isDefaultValueAvailable: bool(false)
+===5===
+getName: string(3) "opt"
+isPassedByReference: bool(false)
+getClass: stdClass
+getDeclaringClass: test
+isArray: bool(false)
+allowsNull: bool(true)
+isOptional: bool(true)
+isDefaultValueAvailable: bool(true)
+getDefaultValue: NULL
+===6===
+getName: string(3) "def"
+isPassedByReference: bool(false)
+getClass: NULL
+getDeclaringClass: test
+isArray: bool(false)
+allowsNull: bool(true)
+isOptional: bool(true)
+isDefaultValueAvailable: bool(true)
+getDefaultValue: string(6) "FooBar"
+===DONE===
diff --git a/ext/reflection/tests/property_exists.phpt b/ext/reflection/tests/property_exists.phpt
new file mode 100644
index 0000000..c74b775
--- /dev/null
+++ b/ext/reflection/tests/property_exists.phpt
@@ -0,0 +1,222 @@
+--TEST--
+Reflection and property_exists()
+--FILE--
+<?php
+
+class A
+{
+ public $a = 1;
+ protected $b = 2;
+ private $c = 3;
+
+ public $empty;
+ public $init = 1;
+
+ function __toString()
+ {
+ return 'obj(' . get_class($this) . ')';
+ }
+
+ static function test($oc, $props)
+ {
+ echo '===' . __CLASS__ . "===\n";
+ foreach($props as $p2) {
+ echo $oc, '::$' , $p2, "\n";
+ var_dump(property_exists($oc, $p2));
+ }
+ }
+}
+
+class B extends A
+{
+ private $c = 4;
+
+ static function test($oc, $props)
+ {
+ echo '===' . __CLASS__ . "===\n";
+ foreach($props as $p2) {
+ echo $oc, '::$' , $p2, "\n";
+ var_dump(property_exists($oc, $p2));
+ }
+ }
+}
+
+class C extends B
+{
+ private $d = 5;
+
+ static function test($oc, $props)
+ {
+ echo '===' . __CLASS__ . "===\n";
+ foreach($props as $p2) {
+ echo $oc, '::$' , $p2, "\n";
+ var_dump(property_exists($oc, $p2));
+ }
+ }
+}
+
+$oA = new A;
+$oA->e = 6;
+
+$oC = new C;
+
+$pc = array($oA, 'A', 'B', 'C', $oC);
+$pr = array('a', 'b', 'c', 'd', 'e');
+
+foreach($pc as $p1) {
+ if (is_object($p1)) {
+ $p1->test($p1, $pr);
+ } else {
+ $r = new ReflectionMethod($p1, 'test');
+ $r->invoke(NULL, $p1, $pr);
+ }
+ echo "===GLOBAL===\n";
+ foreach($pr as $p2) {
+ echo $p1, '::$' , $p2, "\n";
+ var_dump(property_exists($p1, $p2));
+ }
+}
+
+echo "===PROBLEMS===\n";
+var_dump(property_exists(NULL, 'empty'));
+var_dump(property_exists(25,'empty'));
+var_dump(property_exists('',''));
+var_dump(property_exists('A',''));
+var_dump(property_exists('A','123'));
+var_dump(property_exists('A','init'));
+var_dump(property_exists('A','empty'));
+var_dump(property_exists(new A, ''));
+var_dump(property_exists(new A, '123'));
+var_dump(property_exists(new A, 'init'));
+var_dump(property_exists(new A, 'empty'));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===A===
+obj(A)::$a
+bool(true)
+obj(A)::$b
+bool(true)
+obj(A)::$c
+bool(true)
+obj(A)::$d
+bool(false)
+obj(A)::$e
+bool(true)
+===GLOBAL===
+obj(A)::$a
+bool(true)
+obj(A)::$b
+bool(true)
+obj(A)::$c
+bool(true)
+obj(A)::$d
+bool(false)
+obj(A)::$e
+bool(true)
+===A===
+A::$a
+bool(true)
+A::$b
+bool(true)
+A::$c
+bool(true)
+A::$d
+bool(false)
+A::$e
+bool(false)
+===GLOBAL===
+A::$a
+bool(true)
+A::$b
+bool(true)
+A::$c
+bool(true)
+A::$d
+bool(false)
+A::$e
+bool(false)
+===B===
+B::$a
+bool(true)
+B::$b
+bool(true)
+B::$c
+bool(true)
+B::$d
+bool(false)
+B::$e
+bool(false)
+===GLOBAL===
+B::$a
+bool(true)
+B::$b
+bool(true)
+B::$c
+bool(true)
+B::$d
+bool(false)
+B::$e
+bool(false)
+===C===
+C::$a
+bool(true)
+C::$b
+bool(true)
+C::$c
+bool(false)
+C::$d
+bool(true)
+C::$e
+bool(false)
+===GLOBAL===
+C::$a
+bool(true)
+C::$b
+bool(true)
+C::$c
+bool(false)
+C::$d
+bool(true)
+C::$e
+bool(false)
+===C===
+obj(C)::$a
+bool(true)
+obj(C)::$b
+bool(true)
+obj(C)::$c
+bool(false)
+obj(C)::$d
+bool(true)
+obj(C)::$e
+bool(false)
+===GLOBAL===
+obj(C)::$a
+bool(true)
+obj(C)::$b
+bool(true)
+obj(C)::$c
+bool(false)
+obj(C)::$d
+bool(true)
+obj(C)::$e
+bool(false)
+===PROBLEMS===
+
+Warning: First parameter must either be an object or the name of an existing class in %sproperty_exists.php on line %d
+NULL
+
+Warning: First parameter must either be an object or the name of an existing class in %sproperty_exists.php on line %d
+NULL
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+===DONE===
diff --git a/ext/reflection/tests/static_properties_002.phpt b/ext/reflection/tests/static_properties_002.phpt
new file mode 100644
index 0000000..218c629
--- /dev/null
+++ b/ext/reflection/tests/static_properties_002.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Reflection and inheriting static properties
+--FILE--
+<?php
+
+class base {
+ static protected $prop = 2;
+
+ static function show() {
+ echo __METHOD__ . '(' . self::$prop . ")\n";
+ }
+
+ static function inc() {
+ base::$prop++;
+ echo __METHOD__ . "()\n";
+ }
+}
+
+class derived extends base {
+ static public $prop = 2;
+
+ static function show() {
+ echo __METHOD__ . '(' . self::$prop . ")\n";
+ }
+
+ static function inc() {
+ derived::$prop++;
+ echo __METHOD__ . "()\n";
+ }
+}
+
+base::show();
+derived::show();
+
+base::inc();
+
+base::show();
+derived::show();
+
+derived::inc();
+
+base::show();
+derived::show();
+
+$r = new ReflectionClass('derived');
+echo 'Number of properties: '. count($r->getStaticProperties()) . "\n";
+
+echo "Done\n";
+?>
+--EXPECTF--
+base::show(2)
+derived::show(2)
+base::inc()
+base::show(3)
+derived::show(2)
+derived::inc()
+base::show(3)
+derived::show(3)
+Number of properties: 1
+Done
diff --git a/ext/reflection/tests/traits001.phpt b/ext/reflection/tests/traits001.phpt
new file mode 100644
index 0000000..4e36cee
--- /dev/null
+++ b/ext/reflection/tests/traits001.phpt
@@ -0,0 +1,70 @@
+--TEST--
+ReflectionClass and Traits
+--FILE--
+<?php
+trait Foo {
+ public function someMethod() { }
+}
+
+class Bar {
+ use Foo;
+
+ public function someOtherMethod() { }
+}
+
+$rFoo = new ReflectionClass('Foo');
+$rBar = new ReflectionClass('Bar');
+
+var_dump($rFoo->isTrait());
+var_dump($rBar->isTrait());
+echo $rFoo;
+echo $rBar;
+--EXPECTF--
+bool(true)
+bool(false)
+Trait [ <user> trait Foo ] {
+ @@ %straits001.php 2-4
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [1] {
+ Method [ <user> public method someMethod ] {
+ @@ %straits001.php 3 - 3
+ }
+ }
+}
+Class [ <user> class Bar ] {
+ @@ %straits001.php 6-10
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [2] {
+ Method [ <user> public method someOtherMethod ] {
+ @@ %straits001.php 9 - 9
+ }
+
+ Method [ <user> public method someMethod ] {
+ @@ %straits001.php 3 - 3
+ }
+ }
+}
diff --git a/ext/reflection/tests/traits002.phpt b/ext/reflection/tests/traits002.phpt
new file mode 100644
index 0000000..b55b288
--- /dev/null
+++ b/ext/reflection/tests/traits002.phpt
@@ -0,0 +1,54 @@
+--TEST--
+ReflectionClass and Traits
+--FILE--
+<?php
+
+abstract class foo {
+}
+
+trait bar {
+
+}
+
+reflectionclass::export('foo');
+reflectionclass::export('bar');
+
+?>
+--EXPECTF--
+Class [ <user> abstract class foo ] {
+ @@ %s 3-4
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [0] {
+ }
+}
+
+Trait [ <user> trait bar ] {
+ @@ %s 6-8
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [0] {
+ }
+}
diff --git a/ext/reflection/tests/traits003.phpt b/ext/reflection/tests/traits003.phpt
new file mode 100644
index 0000000..c569a8e
--- /dev/null
+++ b/ext/reflection/tests/traits003.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Reflection and Traits
+--FILE--
+<?php
+
+abstract class foo {
+}
+
+trait bar {
+
+}
+
+final class baz {
+
+}
+
+$x = new ReflectionClass('foo');
+var_dump($x->isTrait());
+
+$x = new ReflectionClass('bar');
+var_dump($x->isTrait());
+
+$x = new ReflectionClass('baz');
+var_dump($x->isTrait());
+
+?>
+--EXPECT--
+bool(false)
+bool(true)
+bool(false)
diff --git a/ext/reflection/tests/traits004.phpt b/ext/reflection/tests/traits004.phpt
new file mode 100644
index 0000000..c9367c1
--- /dev/null
+++ b/ext/reflection/tests/traits004.phpt
@@ -0,0 +1,58 @@
+--TEST--
+ReflectionClass::getTraits() and ReflectionClass::getTraitNames
+--FILE--
+<?php
+trait T1 { }
+trait T2 { }
+
+class C1 { }
+class C2 { use T1; }
+class C3 { use T1; use T2; }
+
+for ($c = "C1"; $c <= "C3"; $c++) {
+ echo "class $c:\n";
+ $r = new ReflectionClass($c);
+ var_dump($r->getTraitNames());
+ var_dump($r->getTraits());
+ echo "\n";
+}
+--EXPECT--
+class C1:
+array(0) {
+}
+array(0) {
+}
+
+class C2:
+array(1) {
+ [0]=>
+ string(2) "T1"
+}
+array(1) {
+ ["T1"]=>
+ &object(ReflectionClass)#1 (1) {
+ ["name"]=>
+ string(2) "T1"
+ }
+}
+
+class C3:
+array(2) {
+ [0]=>
+ string(2) "T1"
+ [1]=>
+ string(2) "T2"
+}
+array(2) {
+ ["T1"]=>
+ &object(ReflectionClass)#2 (1) {
+ ["name"]=>
+ string(2) "T1"
+ }
+ ["T2"]=>
+ &object(ReflectionClass)#3 (1) {
+ ["name"]=>
+ string(2) "T2"
+ }
+}
+
diff --git a/ext/reflection/tests/traits005.phpt b/ext/reflection/tests/traits005.phpt
new file mode 100644
index 0000000..4cfa6c0
--- /dev/null
+++ b/ext/reflection/tests/traits005.phpt
@@ -0,0 +1,41 @@
+--TEST--
+ReflectionClass::getTraitAlias
+--FILE--
+<?php
+trait T1 { function m1() { } function m2() { } }
+
+class C1 { }
+class C2 { use T1; }
+class C3 { use T1 { m1 as a1; } }
+class C4 { use T1 { m1 as a1; m2 as a2; } }
+
+for ($c = "C1"; $c <= "C4"; $c++) {
+ echo "class $c:\n";
+ $r = new ReflectionClass($c);
+ var_dump($r->getTraitAliases());
+ echo "\n";
+}
+?>
+--EXPECT--
+class C1:
+array(0) {
+}
+
+class C2:
+array(0) {
+}
+
+class C3:
+array(1) {
+ ["a1"]=>
+ string(6) "T1::m1"
+}
+
+class C4:
+array(2) {
+ ["a1"]=>
+ string(6) "T1::m1"
+ ["a2"]=>
+ string(6) "T1::m2"
+}
+