summaryrefslogtreecommitdiff
path: root/ext/reflection
diff options
context:
space:
mode:
Diffstat (limited to 'ext/reflection')
-rw-r--r--ext/reflection/php_reflection.c4274
-rw-r--r--ext/reflection/php_reflection.h3
-rw-r--r--ext/reflection/php_reflection.stub.php667
-rw-r--r--ext/reflection/php_reflection_arginfo.h996
-rw-r--r--ext/reflection/tests/001.phpt31
-rw-r--r--ext/reflection/tests/002.phpt20
-rw-r--r--ext/reflection/tests/003.phpt18
-rw-r--r--ext/reflection/tests/004.phpt14
-rw-r--r--ext/reflection/tests/005.phpt18
-rw-r--r--ext/reflection/tests/006.phpt105
-rw-r--r--ext/reflection/tests/007.phpt120
-rw-r--r--ext/reflection/tests/008.phpt38
-rw-r--r--ext/reflection/tests/009.phpt2
-rw-r--r--ext/reflection/tests/010.phpt10
-rw-r--r--ext/reflection/tests/012.phpt2
-rw-r--r--ext/reflection/tests/017.phpt2
-rw-r--r--ext/reflection/tests/020.phpt14
-rw-r--r--ext/reflection/tests/021.phpt2
-rw-r--r--ext/reflection/tests/022.phpt2
-rw-r--r--ext/reflection/tests/023.phpt12
-rw-r--r--ext/reflection/tests/024.phpt12
-rw-r--r--ext/reflection/tests/025.phpt2
-rw-r--r--ext/reflection/tests/027.phpt6
-rw-r--r--ext/reflection/tests/028.phpt6
-rw-r--r--ext/reflection/tests/ReflectionAttribute_final.phpt10
-rw-r--r--ext/reflection/tests/ReflectionClassConstant_basic1.phpt52
-rw-r--r--ext/reflection/tests/ReflectionClassConstant_toString_error.phpt2
-rw-r--r--ext/reflection/tests/ReflectionClass_constructor_001.phpt8
-rw-r--r--ext/reflection/tests/ReflectionClass_constructor_002.phpt61
-rw-r--r--ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt4
-rw-r--r--ext/reflection/tests/ReflectionClass_export_basic1.phpt22
-rw-r--r--ext/reflection/tests/ReflectionClass_export_basic2.phpt22
-rw-r--r--ext/reflection/tests/ReflectionClass_getConstant_basic.phpt24
-rw-r--r--ext/reflection/tests/ReflectionClass_getConstant_error.phpt20
-rw-r--r--ext/reflection/tests/ReflectionClass_getConstants_basic.phpt10
-rw-r--r--ext/reflection/tests/ReflectionClass_getConstants_filter.phpt53
-rw-r--r--ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt76
-rw-r--r--ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt82
-rw-r--r--ext/reflection/tests/ReflectionClass_getDocComment_001.phpt14
-rw-r--r--ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt4
-rw-r--r--ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt14
-rw-r--r--ext/reflection/tests/ReflectionClass_getExtension_basic.phpt4
-rw-r--r--ext/reflection/tests/ReflectionClass_getExtension_variation.phpt14
-rw-r--r--ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt16
-rw-r--r--ext/reflection/tests/ReflectionClass_getMethod_001.phpt54
-rw-r--r--ext/reflection/tests/ReflectionClass_getMethod_002.phpt68
-rw-r--r--ext/reflection/tests/ReflectionClass_getMethods_001.phpt36
-rw-r--r--ext/reflection/tests/ReflectionClass_getMethods_003.phpt16
-rw-r--r--ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt38
-rw-r--r--ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt4
-rw-r--r--ext/reflection/tests/ReflectionClass_getName_basic.phpt8
-rw-r--r--ext/reflection/tests/ReflectionClass_getParentClass.phpt7
-rw-r--r--ext/reflection/tests/ReflectionClass_getParentClass_001.phpt38
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperties_001.phpt20
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperties_003.phpt16
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperty_001.phpt92
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperty_002.phpt68
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperty_003.phpt116
-rw-r--r--ext/reflection/tests/ReflectionClass_getProperty_004.phpt116
-rw-r--r--ext/reflection/tests/ReflectionClass_getReflectionConstants_filter.phpt83
-rw-r--r--ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt28
-rw-r--r--ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt43
-rw-r--r--ext/reflection/tests/ReflectionClass_hasConstant_001.phpt6
-rw-r--r--ext/reflection/tests/ReflectionClass_hasConstant_002.phpt20
-rw-r--r--ext/reflection/tests/ReflectionClass_hasMethod_001.phpt46
-rw-r--r--ext/reflection/tests/ReflectionClass_hasMethod_002.phpt20
-rw-r--r--ext/reflection/tests/ReflectionClass_hasProperty_001.phpt46
-rw-r--r--ext/reflection/tests/ReflectionClass_hasProperty_002.phpt20
-rw-r--r--ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt128
-rw-r--r--ext/reflection/tests/ReflectionClass_isArray.phpt17
-rw-r--r--ext/reflection/tests/ReflectionClass_isCloneable_001.phpt4
-rw-r--r--ext/reflection/tests/ReflectionClass_isInstance_basic.phpt16
-rw-r--r--ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt16
-rw-r--r--ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt41
-rw-r--r--ext/reflection/tests/ReflectionClass_isInternal_basic.phpt2
-rw-r--r--ext/reflection/tests/ReflectionClass_isIterateable_001.phpt63
-rw-r--r--ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt20
-rw-r--r--ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt4
-rw-r--r--ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt46
-rw-r--r--ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt16
-rw-r--r--ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt2
-rw-r--r--ext/reflection/tests/ReflectionClass_isSubclassOf_error2.phpt4
-rw-r--r--ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt2
-rw-r--r--ext/reflection/tests/ReflectionClass_modifiers_001.phpt10
-rw-r--r--ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt69
-rw-r--r--ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt10
-rw-r--r--ext/reflection/tests/ReflectionClass_newInstance_001.phpt63
-rw-r--r--ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt24
-rw-r--r--ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt51
-rw-r--r--ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt6
-rw-r--r--ext/reflection/tests/ReflectionClass_toString_001.phpt72
-rw-r--r--ext/reflection/tests/ReflectionClass_toString_002.phpt12
-rw-r--r--ext/reflection/tests/ReflectionClass_toString_003.phpt12
-rw-r--r--ext/reflection/tests/ReflectionClass_toString_004.phpt2
-rw-r--r--ext/reflection/tests/ReflectionExtension_bug66218.phpt1
-rw-r--r--ext/reflection/tests/ReflectionExtension_constructor_basic.phpt2
-rw-r--r--ext/reflection/tests/ReflectionExtension_constructor_error.phpt22
-rw-r--r--ext/reflection/tests/ReflectionExtension_export_basic.phpt18
-rw-r--r--ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt2
-rw-r--r--ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt2
-rw-r--r--ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt30
-rw-r--r--ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt2
-rw-r--r--ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt2
-rw-r--r--ext/reflection/tests/ReflectionExtension_getName_basic.phpt2
-rw-r--r--ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt9
-rw-r--r--ext/reflection/tests/ReflectionExtension_info_basic.phpt2
-rw-r--r--ext/reflection/tests/ReflectionExtension_isPersistant.phpt2
-rw-r--r--ext/reflection/tests/ReflectionExtension_isTemporary.phpt2
-rw-r--r--ext/reflection/tests/ReflectionFunction_001.phpt22
-rw-r--r--ext/reflection/tests/ReflectionFunction_construct.001.phpt30
-rw-r--r--ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt6
-rw-r--r--ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt12
-rw-r--r--ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt12
-rw-r--r--ext/reflection/tests/ReflectionFunction_getFileName.002.phpt12
-rw-r--r--ext/reflection/tests/ReflectionFunction_isDeprecated_basic.phpt1
-rw-r--r--ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt18
-rw-r--r--ext/reflection/tests/ReflectionFunction_isGenerator_basic.phpt18
-rw-r--r--ext/reflection/tests/ReflectionGenerator_basic.phpt38
-rw-r--r--ext/reflection/tests/ReflectionGenerator_getTrace.phpt4
-rw-r--r--ext/reflection/tests/ReflectionGenerator_in_Generator.phpt34
-rw-r--r--ext/reflection/tests/ReflectionMethod_006.phpt90
-rw-r--r--ext/reflection/tests/ReflectionMethod_basic1.phpt128
-rw-r--r--ext/reflection/tests/ReflectionMethod_basic2.phpt92
-rw-r--r--ext/reflection/tests/ReflectionMethod_constructor_basic.phpt70
-rw-r--r--ext/reflection/tests/ReflectionMethod_constructor_error1.phpt64
-rw-r--r--ext/reflection/tests/ReflectionMethod_constructor_error2.phpt46
-rw-r--r--ext/reflection/tests/ReflectionMethod_defaultArg.phpt6
-rw-r--r--ext/reflection/tests/ReflectionMethod_getClosureThis.phpt18
-rw-r--r--ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt26
-rw-r--r--ext/reflection/tests/ReflectionMethod_getClosure_error.phpt53
-rw-r--r--ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt2
-rw-r--r--ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt88
-rw-r--r--ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt2
-rw-r--r--ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt42
-rw-r--r--ext/reflection/tests/ReflectionMethod_invoke_basic.phpt32
-rw-r--r--ext/reflection/tests/ReflectionMethod_invoke_error1.phpt8
-rw-r--r--ext/reflection/tests/ReflectionNamedType.phpt22
-rw-r--r--ext/reflection/tests/ReflectionObject___toString_basic1.phpt4
-rw-r--r--ext/reflection/tests/ReflectionObject___toString_basic2.phpt4
-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.phpt2
-rw-r--r--ext/reflection/tests/ReflectionObject_getConstant_basic.phpt12
-rw-r--r--ext/reflection/tests/ReflectionObject_getConstants_basic.phpt10
-rw-r--r--ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt62
-rw-r--r--ext/reflection/tests/ReflectionObject_getName_basic.phpt6
-rw-r--r--ext/reflection/tests/ReflectionObject_isInstance_basic.phpt14
-rw-r--r--ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt16
-rw-r--r--ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt83
-rw-r--r--ext/reflection/tests/ReflectionObject_isInternal_basic.phpt2
-rw-r--r--ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt46
-rw-r--r--ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt30
-rw-r--r--ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt14
-rw-r--r--ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt2
-rw-r--r--ext/reflection/tests/ReflectionParameter_001.phpt22
-rw-r--r--ext/reflection/tests/ReflectionParameter_002.phpt12
-rw-r--r--ext/reflection/tests/ReflectionParameter_003.phpt46
-rw-r--r--ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt34
-rw-r--r--ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt28
-rw-r--r--ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt13
-rw-r--r--ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt22
-rw-r--r--ext/reflection/tests/ReflectionParameter_export_basic.phpt8
-rw-r--r--ext/reflection/tests/ReflectionParameter_export_error2.phpt34
-rw-r--r--ext/reflection/tests/ReflectionParameter_export_error3.phpt23
-rw-r--r--ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt7
-rw-r--r--ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt6
-rw-r--r--ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt20
-rw-r--r--ext/reflection/tests/ReflectionParameter_isDefault.phpt2
-rw-r--r--ext/reflection/tests/ReflectionParameter_toString_basic.phpt6
-rw-r--r--ext/reflection/tests/ReflectionProperty_basic1.phpt60
-rw-r--r--ext/reflection/tests/ReflectionProperty_constructor_error.phpt15
-rw-r--r--ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt38
-rw-r--r--ext/reflection/tests/ReflectionProperty_error.phpt51
-rw-r--r--ext/reflection/tests/ReflectionProperty_export_basic.phpt14
-rw-r--r--ext/reflection/tests/ReflectionProperty_export_error.phpt64
-rw-r--r--ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt6
-rw-r--r--ext/reflection/tests/ReflectionProperty_getDefaultValue.phpt73
-rw-r--r--ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt16
-rw-r--r--ext/reflection/tests/ReflectionProperty_getValue_error.phpt63
-rw-r--r--ext/reflection/tests/ReflectionProperty_hasDefaultValue.phpt60
-rw-r--r--ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt9
-rw-r--r--ext/reflection/tests/ReflectionProperty_isInitialized.phpt21
-rw-r--r--ext/reflection/tests/ReflectionProperty_setAccessible.phpt14
-rw-r--r--ext/reflection/tests/ReflectionProperty_setValue_error.phpt63
-rw-r--r--ext/reflection/tests/ReflectionProperty_typed_static.phpt2
-rw-r--r--ext/reflection/tests/ReflectionReference_errors.phpt8
-rw-r--r--ext/reflection/tests/ReflectionType_001.phpt46
-rw-r--r--ext/reflection/tests/ReflectionType_002.phpt1
-rw-r--r--ext/reflection/tests/ReflectionZendExtension.phpt6
-rw-r--r--ext/reflection/tests/ReflectionZendExtension_error.phpt4
-rw-r--r--ext/reflection/tests/bug26640.phpt16
-rw-r--r--ext/reflection/tests/bug26695.phpt5
-rw-r--r--ext/reflection/tests/bug29268.phpt15
-rw-r--r--ext/reflection/tests/bug29523.phpt18
-rw-r--r--ext/reflection/tests/bug29828.phpt12
-rw-r--r--ext/reflection/tests/bug30146.phpt2
-rw-r--r--ext/reflection/tests/bug30148.phpt36
-rw-r--r--ext/reflection/tests/bug30209.phpt26
-rw-r--r--ext/reflection/tests/bug30856.phpt2
-rw-r--r--ext/reflection/tests/bug31651.phpt2
-rw-r--r--ext/reflection/tests/bug32981.phpt14
-rw-r--r--ext/reflection/tests/bug33389.phpt1
-rw-r--r--ext/reflection/tests/bug36434.phpt18
-rw-r--r--ext/reflection/tests/bug37816.phpt10
-rw-r--r--ext/reflection/tests/bug37964.phpt18
-rw-r--r--ext/reflection/tests/bug38132.phpt4
-rw-r--r--ext/reflection/tests/bug38217.phpt14
-rw-r--r--ext/reflection/tests/bug38653.phpt6
-rw-r--r--ext/reflection/tests/bug38942.phpt35
-rw-r--r--ext/reflection/tests/bug39001.phpt4
-rw-r--r--ext/reflection/tests/bug39067.phpt10
-rw-r--r--ext/reflection/tests/bug39884.phpt3
-rw-r--r--ext/reflection/tests/bug40431.phpt2
-rw-r--r--ext/reflection/tests/bug40794.phpt2
-rw-r--r--ext/reflection/tests/bug41061.phpt3
-rw-r--r--ext/reflection/tests/bug41884.phpt4
-rw-r--r--ext/reflection/tests/bug42976.phpt10
-rw-r--r--ext/reflection/tests/bug45139.phpt14
-rw-r--r--ext/reflection/tests/bug45571.phpt14
-rw-r--r--ext/reflection/tests/bug45765.phpt20
-rw-r--r--ext/reflection/tests/bug46064.phpt22
-rw-r--r--ext/reflection/tests/bug46064_2.phpt24
-rw-r--r--ext/reflection/tests/bug46205.phpt15
-rw-r--r--ext/reflection/tests/bug47254.phpt9
-rw-r--r--ext/reflection/tests/bug48757.phpt4
-rw-r--r--ext/reflection/tests/bug49074.phpt8
-rw-r--r--ext/reflection/tests/bug49719.phpt24
-rw-r--r--ext/reflection/tests/bug51905.phpt6
-rw-r--r--ext/reflection/tests/bug52854.phpt4
-rw-r--r--ext/reflection/tests/bug53366.phpt2
-rw-r--r--ext/reflection/tests/bug53915.phpt5
-rw-r--r--ext/reflection/tests/bug60367.phpt11
-rw-r--r--ext/reflection/tests/bug61388.phpt1
-rw-r--r--ext/reflection/tests/bug62715.phpt3
-rw-r--r--ext/reflection/tests/bug64239.phpt6
-rw-r--r--ext/reflection/tests/bug64936.phpt6
-rw-r--r--ext/reflection/tests/bug66430.phpt8
-rw-r--r--ext/reflection/tests/bug69180.phpt37
-rw-r--r--ext/reflection/tests/bug69802.phpt4
-rw-r--r--ext/reflection/tests/bug70982.phpt10
-rw-r--r--ext/reflection/tests/bug71767.phpt9
-rw-r--r--ext/reflection/tests/bug72661.phpt3
-rw-r--r--ext/reflection/tests/bug74454.inc2
-rw-r--r--ext/reflection/tests/bug74454.phpt10
-rw-r--r--ext/reflection/tests/bug74673.phpt17
-rw-r--r--ext/reflection/tests/bug74949.phpt4
-rw-r--r--ext/reflection/tests/bug76536.phpt2
-rw-r--r--ext/reflection/tests/bug77325.phpt29
-rw-r--r--ext/reflection/tests/bug77882.phpt2
-rw-r--r--ext/reflection/tests/bug78774.phpt6
-rw-r--r--ext/reflection/tests/bug78895.phpt12
-rw-r--r--ext/reflection/tests/bug80190.phpt67
-rw-r--r--ext/reflection/tests/bug80299.phpt15
-rw-r--r--ext/reflection/tests/bug80370.phpt17
-rw-r--r--ext/reflection/tests/closures_001.phpt10
-rw-r--r--ext/reflection/tests/closures_002.phpt6
-rw-r--r--ext/reflection/tests/closures_003.phpt2
-rw-r--r--ext/reflection/tests/closures_003_v1.phpt2
-rw-r--r--ext/reflection/tests/closures_004.phpt2
-rw-r--r--ext/reflection/tests/constructor_promotion.phpt70
-rw-r--r--ext/reflection/tests/default_value_internal_userland_arginfo.phpt27
-rw-r--r--ext/reflection/tests/default_value_leak.phpt22
-rw-r--r--ext/reflection/tests/included4.inc4
-rw-r--r--ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValueConstantName_Internal.phpt53
-rw-r--r--ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValue_Internal.phpt37
-rw-r--r--ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_isDefaultValueAvailable_Internal.phpt28
-rw-r--r--ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_isDefaultValueConstant_Internal.phpt36
-rw-r--r--ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_toString_Internal.phpt28
-rw-r--r--ext/reflection/tests/internal_parameter_default_value/check_all.phpt33
-rw-r--r--ext/reflection/tests/mixed_type.phpt32
-rw-r--r--ext/reflection/tests/parameters_001.phpt20
-rw-r--r--ext/reflection/tests/parameters_002.phpt165
-rw-r--r--ext/reflection/tests/property_exists.phpt117
-rw-r--r--ext/reflection/tests/request38992.phpt21
-rw-r--r--ext/reflection/tests/static_properties_002.phpt32
-rw-r--r--ext/reflection/tests/static_type.phpt22
-rw-r--r--ext/reflection/tests/traits001.phpt1
-rw-r--r--ext/reflection/tests/traits004.phpt1
-rw-r--r--ext/reflection/tests/union_types.phpt112
279 files changed, 6944 insertions, 5685 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index a358994fd5..64c5355fc8 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -33,6 +31,8 @@
#include "zend.h"
#include "zend_API.h"
+#include "zend_ast.h"
+#include "zend_attributes.h"
#include "zend_exceptions.h"
#include "zend_operators.h"
#include "zend_constants.h"
@@ -43,6 +43,7 @@
#include "zend_extensions.h"
#include "zend_builtin_functions.h"
#include "zend_smart_str.h"
+#include "php_reflection_arginfo.h"
/* Key used to avoid leaking addresses in ReflectionProperty::getId() */
#define REFLECTION_KEY_LEN 16
@@ -76,6 +77,7 @@ PHPAPI zend_class_entry *reflection_generator_ptr;
PHPAPI zend_class_entry *reflection_parameter_ptr;
PHPAPI zend_class_entry *reflection_type_ptr;
PHPAPI zend_class_entry *reflection_named_type_ptr;
+PHPAPI zend_class_entry *reflection_union_type_ptr;
PHPAPI zend_class_entry *reflection_class_ptr;
PHPAPI zend_class_entry *reflection_object_ptr;
PHPAPI zend_class_entry *reflection_method_ptr;
@@ -84,6 +86,7 @@ PHPAPI zend_class_entry *reflection_class_constant_ptr;
PHPAPI zend_class_entry *reflection_extension_ptr;
PHPAPI zend_class_entry *reflection_zend_extension_ptr;
PHPAPI zend_class_entry *reflection_reference_ptr;
+PHPAPI zend_class_entry *reflection_attribute_ptr;
/* Exception throwing macro */
#define _DO_THROW(msg) \
@@ -93,10 +96,10 @@ PHPAPI zend_class_entry *reflection_reference_ptr;
intern = Z_REFLECTION_P(ZEND_THIS); \
if (intern->ptr == NULL) { \
if (EG(exception) && EG(exception)->ce == reflection_exception_ptr) { \
- return; \
+ RETURN_THROWS(); \
} \
zend_throw_error(NULL, "Internal error: Failed to retrieve the reflection object"); \
- return; \
+ RETURN_THROWS(); \
} \
} while (0)
@@ -109,13 +112,14 @@ PHPAPI zend_class_entry *reflection_reference_ptr;
#define REGISTER_REFLECTION_CLASS_CONST_LONG(class_name, const_name, value) \
zend_declare_class_constant_long(reflection_ ## class_name ## _ptr, const_name, sizeof(const_name)-1, (zend_long)value);
+#define REFLECTION_ATTRIBUTE_IS_INSTANCEOF (1 << 1)
+
/* {{{ Object structure */
/* Struct for properties */
typedef struct _property_reference {
- zend_property_info prop;
+ zend_property_info *prop;
zend_string *unmangled_name;
- zend_bool dynamic;
} property_reference;
/* Struct for parameters */
@@ -129,8 +133,19 @@ typedef struct _parameter_reference {
/* Struct for type hints */
typedef struct _type_reference {
zend_type type;
+ /* Whether to use backwards compatible null representation */
+ zend_bool legacy_behavior;
} type_reference;
+/* Struct for attributes */
+typedef struct _attribute_reference {
+ HashTable *attributes;
+ zend_attribute *data;
+ zend_class_entry *scope;
+ zend_string *filename;
+ uint32_t target;
+} attribute_reference;
+
typedef enum {
REF_TYPE_OTHER, /* Must be 0 */
REF_TYPE_FUNCTION,
@@ -138,7 +153,8 @@ typedef enum {
REF_TYPE_PARAMETER,
REF_TYPE_TYPE,
REF_TYPE_PROPERTY,
- REF_TYPE_CLASS_CONSTANT
+ REF_TYPE_CLASS_CONSTANT,
+ REF_TYPE_ATTRIBUTE
} reflection_type_t;
/* Struct for reflection objects */
@@ -160,25 +176,22 @@ static inline reflection_object *reflection_object_from_obj(zend_object *obj) {
static zend_object_handlers reflection_object_handlers;
+static zend_always_inline uint32_t prop_get_flags(property_reference *ref) {
+ return ref->prop ? ref->prop->flags : ZEND_ACC_PUBLIC;
+}
+
static inline zend_bool is_closure_invoke(zend_class_entry *ce, zend_string *lcname) {
return ce == zend_ce_closure
&& zend_string_equals_literal(lcname, ZEND_INVOKE_FUNC_NAME);
}
-static zval *_default_load_name(zval *object) /* {{{ */
-{
- return zend_hash_find_ex_ind(Z_OBJPROP_P(object), ZSTR_KNOWN(ZEND_STR_NAME), 1);
-}
-/* }}} */
-
static void _default_get_name(zval *object, zval *return_value) /* {{{ */
{
- zval *value;
-
- if ((value = _default_load_name(object)) == NULL) {
+ zval *name = reflection_prop_name(object);
+ if (Z_ISUNDEF_P(name)) {
RETURN_FALSE;
}
- ZVAL_COPY(return_value, value);
+ ZVAL_COPY(return_value, name);
}
/* }}} */
@@ -226,7 +239,7 @@ static void reflection_free_objects_storage(zend_object *object) /* {{{ */
case REF_TYPE_TYPE:
{
type_reference *type_ref = intern->ptr;
- if (ZEND_TYPE_IS_NAME(type_ref->type)) {
+ if (ZEND_TYPE_HAS_NAME(type_ref->type)) {
zend_string_release(ZEND_TYPE_NAME(type_ref->type));
}
efree(type_ref);
@@ -238,13 +251,16 @@ static void reflection_free_objects_storage(zend_object *object) /* {{{ */
case REF_TYPE_PROPERTY:
prop_reference = (property_reference*)intern->ptr;
zend_string_release_ex(prop_reference->unmangled_name, 0);
-
- if (ZEND_TYPE_IS_NAME(prop_reference->prop.type)) {
- zend_string_release(ZEND_TYPE_NAME(prop_reference->prop.type));
+ efree(intern->ptr);
+ break;
+ case REF_TYPE_ATTRIBUTE: {
+ attribute_reference *attr_ref = intern->ptr;
+ if (attr_ref->filename) {
+ zend_string_release(attr_ref->filename);
}
-
efree(intern->ptr);
break;
+ }
case REF_TYPE_GENERATOR:
case REF_TYPE_CLASS_CONSTANT:
case REF_TYPE_OTHER:
@@ -257,9 +273,9 @@ static void reflection_free_objects_storage(zend_object *object) /* {{{ */
}
/* }}} */
-static HashTable *reflection_get_gc(zval *obj, zval **gc_data, int *gc_data_count) /* {{{ */
+static HashTable *reflection_get_gc(zend_object *obj, zval **gc_data, int *gc_data_count) /* {{{ */
{
- reflection_object *intern = Z_REFLECTION_P(obj);
+ reflection_object *intern = reflection_object_from_obj(obj);
*gc_data = &intern->obj;
*gc_data_count = 1;
return zend_std_get_properties(obj);
@@ -286,7 +302,7 @@ static zval *reflection_instantiate(zend_class_entry *pce, zval *object) /* {{{
static void _const_string(smart_str *str, char *name, zval *value, char *indent);
static void _function_string(smart_str *str, zend_function *fptr, zend_class_entry *scope, char* indent);
-static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent, zend_bool dynamic);
+static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent);
static void _class_const_string(smart_str *str, char *name, zend_class_constant *c, char* indent);
static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char *indent);
static void _extension_string(smart_str *str, zend_module_entry *module, char *indent);
@@ -402,7 +418,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) {
if ((prop->flags & ZEND_ACC_STATIC) && (!(prop->flags & ZEND_ACC_PRIVATE) || prop->ce == ce)) {
- _property_string(str, prop, NULL, ZSTR_VAL(sub_indent), 0);
+ _property_string(str, prop, NULL, ZSTR_VAL(sub_indent));
}
} ZEND_HASH_FOREACH_END();
}
@@ -415,7 +431,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
zend_function *mptr;
ZEND_HASH_FOREACH_PTR(&ce->function_table, mptr) {
- if (mptr->common.fn_flags & ZEND_ACC_STATIC
+ if ((mptr->common.fn_flags & ZEND_ACC_STATIC)
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
{
count_static_funcs++;
@@ -429,7 +445,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
zend_function *mptr;
ZEND_HASH_FOREACH_PTR(&ce->function_table, mptr) {
- if (mptr->common.fn_flags & ZEND_ACC_STATIC
+ if ((mptr->common.fn_flags & ZEND_ACC_STATIC)
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
{
smart_str_append_printf(str, "\n");
@@ -450,14 +466,14 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) {
if (!(prop->flags & ZEND_ACC_STATIC)
&& (!(prop->flags & ZEND_ACC_PRIVATE) || prop->ce == ce)) {
- _property_string(str, prop, NULL, ZSTR_VAL(sub_indent), 0);
+ _property_string(str, prop, NULL, ZSTR_VAL(sub_indent));
}
} ZEND_HASH_FOREACH_END();
}
smart_str_append_printf(str, "%s }\n", indent);
if (obj && Z_TYPE_P(obj) == IS_OBJECT) {
- HashTable *properties = Z_OBJ_HT_P(obj)->get_properties(obj);
+ HashTable *properties = Z_OBJ_HT_P(obj)->get_properties(Z_OBJ_P(obj));
zend_string *prop_name;
smart_str prop_str = {0};
@@ -467,7 +483,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
if (prop_name && ZSTR_LEN(prop_name) && ZSTR_VAL(prop_name)[0]) { /* skip all private and protected properties */
if (!zend_hash_exists(&ce->properties_info, prop_name)) {
count++;
- _property_string(&prop_str, NULL, ZSTR_VAL(prop_name), ZSTR_VAL(sub_indent), 0);
+ _property_string(&prop_str, NULL, ZSTR_VAL(prop_name), ZSTR_VAL(sub_indent));
}
}
} ZEND_HASH_FOREACH_END();
@@ -524,7 +540,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
/* {{{ _const_string */
static void _const_string(smart_str *str, char *name, zval *value, char *indent)
{
- char *type = zend_zval_type_name(value);
+ const char *type = zend_zval_type_name(value);
if (Z_TYPE_P(value) == IS_ARRAY) {
smart_str_append_printf(str, "%s Constant [ %s %s ] { Array }\n",
@@ -546,7 +562,7 @@ static void _const_string(smart_str *str, char *name, zval *value, char *indent)
static void _class_const_string(smart_str *str, char *name, zend_class_constant *c, char *indent)
{
char *visibility = zend_visibility_string(Z_ACCESS_FLAGS(c->value));
- char *type;
+ const char *type;
if (zval_update_constant_ex(&c->value, c->ce) == FAILURE) {
return;
@@ -569,8 +585,7 @@ static void _class_const_string(smart_str *str, char *name, zend_class_constant
}
/* }}} */
-/* {{{ _get_recv_opcode */
-static zend_op* _get_recv_op(zend_op_array *op_array, uint32_t offset)
+static zend_op *get_recv_op(zend_op_array *op_array, uint32_t offset)
{
zend_op *op = op_array->opcodes;
zend_op *end = op + op_array->last;
@@ -584,9 +599,56 @@ static zend_op* _get_recv_op(zend_op_array *op_array, uint32_t offset)
}
++op;
}
+ ZEND_ASSERT(0 && "Failed to find op");
return NULL;
}
-/* }}} */
+
+static zval *get_default_from_recv(zend_op_array *op_array, uint32_t offset) {
+ zend_op *recv = get_recv_op(op_array, offset);
+ if (!recv || recv->opcode != ZEND_RECV_INIT) {
+ return NULL;
+ }
+
+ return RT_CONSTANT(recv, recv->op2);
+}
+
+static int format_default_value(smart_str *str, zval *value, zend_class_entry *scope) {
+ zval zv;
+ ZVAL_COPY(&zv, value);
+ if (UNEXPECTED(zval_update_constant_ex(&zv, scope) == FAILURE)) {
+ zval_ptr_dtor(&zv);
+ return FAILURE;
+ }
+
+ if (Z_TYPE(zv) == IS_TRUE) {
+ smart_str_appends(str, "true");
+ } else if (Z_TYPE(zv) == IS_FALSE) {
+ smart_str_appends(str, "false");
+ } else if (Z_TYPE(zv) == IS_NULL) {
+ smart_str_appends(str, "NULL");
+ } else if (Z_TYPE(zv) == IS_STRING) {
+ smart_str_appendc(str, '\'');
+ smart_str_appendl(str, Z_STRVAL(zv), MIN(Z_STRLEN(zv), 15));
+ if (Z_STRLEN(zv) > 15) {
+ smart_str_appends(str, "...");
+ }
+ smart_str_appendc(str, '\'');
+ } else if (Z_TYPE(zv) == IS_ARRAY) {
+ smart_str_appends(str, "Array");
+ } else {
+ zend_string *tmp_zv_str;
+ zend_string *zv_str = zval_get_tmp_string(&zv, &tmp_zv_str);
+ smart_str_append(str, zv_str);
+ zend_tmp_string_release(tmp_zv_str);
+ }
+ zval_ptr_dtor(&zv);
+ return SUCCESS;
+}
+
+static inline zend_bool has_internal_arg_info(const zend_function *fptr) {
+ return fptr->type == ZEND_INTERNAL_FUNCTION
+ && !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO);
+}
/* {{{ _parameter_string */
static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_arg_info *arg_info, uint32_t offset, zend_bool required, char* indent)
@@ -597,66 +659,40 @@ static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_
} else {
smart_str_append_printf(str, "<required> ");
}
- if (ZEND_TYPE_IS_CLASS(arg_info->type)) {
- smart_str_append_printf(str, "%s ",
- ZSTR_VAL(ZEND_TYPE_NAME(arg_info->type)));
- if (ZEND_TYPE_ALLOW_NULL(arg_info->type)) {
- smart_str_append_printf(str, "or NULL ");
- }
- } else if (ZEND_TYPE_IS_CODE(arg_info->type)) {
- smart_str_append_printf(str, "%s ", zend_get_type_by_const(ZEND_TYPE_CODE(arg_info->type)));
- if (ZEND_TYPE_ALLOW_NULL(arg_info->type)) {
- smart_str_append_printf(str, "or NULL ");
- }
+ if (ZEND_TYPE_IS_SET(arg_info->type)) {
+ zend_string *type_str = zend_type_to_string(arg_info->type);
+ smart_str_append(str, type_str);
+ smart_str_appendc(str, ' ');
+ zend_string_release(type_str);
}
- if (arg_info->pass_by_reference) {
+ if (ZEND_ARG_SEND_MODE(arg_info)) {
smart_str_appendc(str, '&');
}
- if (arg_info->is_variadic) {
+ if (ZEND_ARG_IS_VARIADIC(arg_info)) {
smart_str_appends(str, "...");
}
- if (arg_info->name) {
- smart_str_append_printf(str, "$%s",
- (fptr->type == ZEND_INTERNAL_FUNCTION &&
- !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ?
- ((zend_internal_arg_info*)arg_info)->name :
- ZSTR_VAL(arg_info->name));
- } else {
- smart_str_append_printf(str, "$param%d", offset);
- }
- if (fptr->type == ZEND_USER_FUNCTION && !required) {
- zend_op *precv = _get_recv_op((zend_op_array*)fptr, offset);
- if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) {
- zval zv;
+ smart_str_append_printf(str, "$%s", has_internal_arg_info(fptr)
+ ? ((zend_internal_arg_info*)arg_info)->name : ZSTR_VAL(arg_info->name));
+ if (!required && !ZEND_ARG_IS_VARIADIC(arg_info)) {
+ if (fptr->type == ZEND_INTERNAL_FUNCTION) {
smart_str_appends(str, " = ");
- ZVAL_COPY(&zv, RT_CONSTANT(precv, precv->op2));
- if (UNEXPECTED(zval_update_constant_ex(&zv, fptr->common.scope) == FAILURE)) {
- zval_ptr_dtor(&zv);
- return;
+ /* TODO: We don't have a way to fetch the default value for an internal function
+ * with userland arg info. */
+ if (has_internal_arg_info(fptr)
+ && ((zend_internal_arg_info*)arg_info)->default_value) {
+ smart_str_appends(str, ((zend_internal_arg_info*)arg_info)->default_value);
+ } else {
+ smart_str_appends(str, "<default>");
}
- if (Z_TYPE(zv) == IS_TRUE) {
- smart_str_appends(str, "true");
- } else if (Z_TYPE(zv) == IS_FALSE) {
- smart_str_appends(str, "false");
- } else if (Z_TYPE(zv) == IS_NULL) {
- smart_str_appends(str, "NULL");
- } else if (Z_TYPE(zv) == IS_STRING) {
- smart_str_appendc(str, '\'');
- smart_str_appendl(str, Z_STRVAL(zv), MIN(Z_STRLEN(zv), 15));
- if (Z_STRLEN(zv) > 15) {
- smart_str_appends(str, "...");
+ } else {
+ zval *default_value = get_default_from_recv((zend_op_array*)fptr, offset);
+ if (default_value) {
+ smart_str_appends(str, " = ");
+ if (format_default_value(str, default_value, fptr->common.scope) == FAILURE) {
+ return;
}
- smart_str_appendc(str, '\'');
- } else if (Z_TYPE(zv) == IS_ARRAY) {
- smart_str_appends(str, "Array");
- } else {
- zend_string *tmp_zv_str;
- zend_string *zv_str = zval_get_tmp_string(&zv, &tmp_zv_str);
- smart_str_append(str, zv_str);
- zend_tmp_string_release(tmp_zv_str);
}
- zval_ptr_dtor(&zv);
}
}
smart_str_appends(str, " ]");
@@ -761,9 +797,6 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent
if (fptr->common.fn_flags & ZEND_ACC_CTOR) {
smart_str_appends(str, ", ctor");
}
- if (fptr->common.fn_flags & ZEND_ACC_DTOR) {
- smart_str_appends(str, ", dtor");
- }
smart_str_appends(str, "> ");
if (fptr->common.fn_flags & ZEND_ACC_ABSTRACT) {
@@ -817,17 +850,10 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent
smart_str_free(&param_indent);
if (fptr->op_array.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
smart_str_append_printf(str, " %s- Return [ ", indent);
- if (ZEND_TYPE_IS_CLASS(fptr->common.arg_info[-1].type)) {
- smart_str_append_printf(str, "%s ",
- ZSTR_VAL(ZEND_TYPE_NAME(fptr->common.arg_info[-1].type)));
- if (ZEND_TYPE_ALLOW_NULL(fptr->common.arg_info[-1].type)) {
- smart_str_appends(str, "or NULL ");
- }
- } else if (ZEND_TYPE_IS_CODE(fptr->common.arg_info[-1].type)) {
- smart_str_append_printf(str, "%s ", zend_get_type_by_const(ZEND_TYPE_CODE(fptr->common.arg_info[-1].type)));
- if (ZEND_TYPE_ALLOW_NULL(fptr->common.arg_info[-1].type)) {
- smart_str_appends(str, "or NULL ");
- }
+ if (ZEND_TYPE_IS_SET(fptr->common.arg_info[-1].type)) {
+ zend_string *type_str = zend_type_to_string(fptr->common.arg_info[-1].type);
+ smart_str_append_printf(str, "%s ", ZSTR_VAL(type_str));
+ zend_string_release(type_str);
}
smart_str_appends(str, "]\n");
}
@@ -835,21 +861,24 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent
}
/* }}} */
+static zval *property_get_default(zend_property_info *prop_info) {
+ zend_class_entry *ce = prop_info->ce;
+ if (prop_info->flags & ZEND_ACC_STATIC) {
+ zval *prop = &ce->default_static_members_table[prop_info->offset];
+ ZVAL_DEINDIRECT(prop);
+ return prop;
+ } else {
+ return &ce->default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)];
+ }
+}
+
/* {{{ _property_string */
-static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent, zend_bool dynamic)
+static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent)
{
smart_str_append_printf(str, "%sProperty [ ", indent);
if (!prop) {
smart_str_append_printf(str, "<dynamic> public $%s", prop_name);
} else {
- if (!(prop->flags & ZEND_ACC_STATIC)) {
- if (dynamic) {
- smart_str_appends(str, "<implicit> ");
- } else {
- smart_str_appends(str, "<default> ");
- }
- }
-
/* These are mutually exclusive */
switch (prop->flags & ZEND_ACC_PPP_MASK) {
case ZEND_ACC_PUBLIC:
@@ -865,11 +894,25 @@ static void _property_string(smart_str *str, zend_property_info *prop, const cha
if (prop->flags & ZEND_ACC_STATIC) {
smart_str_appends(str, "static ");
}
+ if (ZEND_TYPE_IS_SET(prop->type)) {
+ zend_string *type_str = zend_type_to_string(prop->type);
+ smart_str_append(str, type_str);
+ smart_str_appendc(str, ' ');
+ zend_string_release(type_str);
+ }
if (!prop_name) {
const char *class_name;
zend_unmangle_property_name(prop->name, &class_name, &prop_name);
}
smart_str_append_printf(str, "$%s", prop_name);
+
+ zval *default_value = property_get_default(prop);
+ if (!Z_ISUNDEF_P(default_value)) {
+ smart_str_appends(str, " = ");
+ if (format_default_value(str, default_value, prop->ce) == FAILURE) {
+ return;
+ }
+ }
}
smart_str_appends(str, " ]\n");
@@ -1045,6 +1088,120 @@ static void _extension_string(smart_str *str, zend_module_entry *module, char *i
}
/* }}} */
+/* {{{ reflection_attribute_factory */
+static void reflection_attribute_factory(zval *object, HashTable *attributes, zend_attribute *data,
+ zend_class_entry *scope, uint32_t target, zend_string *filename)
+{
+ reflection_object *intern;
+ attribute_reference *reference;
+
+ reflection_instantiate(reflection_attribute_ptr, object);
+ intern = Z_REFLECTION_P(object);
+ reference = (attribute_reference*) emalloc(sizeof(attribute_reference));
+ reference->attributes = attributes;
+ reference->data = data;
+ reference->scope = scope;
+ reference->filename = filename ? zend_string_copy(filename) : NULL;
+ reference->target = target;
+ intern->ptr = reference;
+ intern->ref_type = REF_TYPE_ATTRIBUTE;
+}
+/* }}} */
+
+static int read_attributes(zval *ret, HashTable *attributes, zend_class_entry *scope,
+ uint32_t offset, uint32_t target, zend_string *name, zend_class_entry *base, zend_string *filename) /* {{{ */
+{
+ ZEND_ASSERT(attributes != NULL);
+
+ zend_attribute *attr;
+ zval tmp;
+
+ if (name) {
+ // Name based filtering using lowercased key.
+ zend_string *filter = zend_string_tolower(name);
+
+ ZEND_HASH_FOREACH_PTR(attributes, attr) {
+ if (attr->offset == offset && zend_string_equals(attr->lcname, filter)) {
+ reflection_attribute_factory(&tmp, attributes, attr, scope, target, filename);
+ add_next_index_zval(ret, &tmp);
+ }
+ } ZEND_HASH_FOREACH_END();
+
+ zend_string_release(filter);
+ return SUCCESS;
+ }
+
+ ZEND_HASH_FOREACH_PTR(attributes, attr) {
+ if (attr->offset != offset) {
+ continue;
+ }
+
+ if (base) {
+ // Base type filtering.
+ zend_class_entry *ce = zend_lookup_class_ex(attr->name, attr->lcname, 0);
+
+ if (ce == NULL) {
+ // Bailout on error, otherwise ignore unavailable class.
+ if (EG(exception)) {
+ return FAILURE;
+ }
+
+ continue;
+ }
+
+ if (!instanceof_function(ce, base)) {
+ continue;
+ }
+ }
+
+ reflection_attribute_factory(&tmp, attributes, attr, scope, target, filename);
+ add_next_index_zval(ret, &tmp);
+ } ZEND_HASH_FOREACH_END();
+
+ return SUCCESS;
+}
+/* }}} */
+
+static void reflect_attributes(INTERNAL_FUNCTION_PARAMETERS, HashTable *attributes,
+ uint32_t offset, zend_class_entry *scope, uint32_t target, zend_string *filename) /* {{{ */
+{
+ zend_string *name = NULL;
+ zend_long flags = 0;
+ zend_class_entry *base = NULL;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!l", &name, &flags) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ if (flags & ~REFLECTION_ATTRIBUTE_IS_INSTANCEOF) {
+ zend_argument_value_error(2, "must be a valid attribute filter flag");
+ RETURN_THROWS();
+ }
+
+ if (name && (flags & REFLECTION_ATTRIBUTE_IS_INSTANCEOF)) {
+ if (NULL == (base = zend_lookup_class(name))) {
+ if (!EG(exception)) {
+ zend_throw_error(NULL, "Class \"%s\" not found", ZSTR_VAL(name));
+ }
+
+ RETURN_THROWS();
+ }
+
+ name = NULL;
+ }
+
+ if (!attributes) {
+ RETURN_EMPTY_ARRAY();
+ }
+
+ array_init(return_value);
+
+ if (FAILURE == read_attributes(return_value, attributes, scope, offset, target, name, base, filename)) {
+ RETURN_THROWS();
+ }
+}
+/* }}} */
+
static void _zend_extension_string(smart_str *str, zend_extension *extension, char *indent) /* {{{ */
{
smart_str_append_printf(str, "%sZend Extension [ %s ", indent, extension->name);
@@ -1073,7 +1230,7 @@ static void _function_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask)
zend_function *mptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(mptr);
RETURN_BOOL(mptr->common.fn_flags & mask);
@@ -1137,40 +1294,58 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje
intern->ref_type = REF_TYPE_PARAMETER;
intern->ce = fptr->common.scope;
if (closure_object) {
- Z_ADDREF_P(closure_object);
- ZVAL_OBJ(&intern->obj, Z_OBJ_P(closure_object));
+ ZVAL_OBJ_COPY(&intern->obj, Z_OBJ_P(closure_object));
}
prop_name = reflection_prop_name(object);
- if (arg_info->name) {
- if (fptr->type == ZEND_INTERNAL_FUNCTION &&
- !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) {
- ZVAL_STRING(prop_name, ((zend_internal_arg_info*)arg_info)->name);
- } else {
- ZVAL_STR_COPY(prop_name, arg_info->name);
- }
+ if (has_internal_arg_info(fptr)) {
+ ZVAL_STRING(prop_name, ((zend_internal_arg_info*)arg_info)->name);
} else {
- ZVAL_NULL(prop_name);
+ ZVAL_STR_COPY(prop_name, arg_info->name);
}
}
/* }}} */
+/* For backwards compatibility reasons, we need to return T|null style unions
+ * as a ReflectionNamedType. Here we determine what counts as a union type and
+ * what doesn't. */
+static zend_bool is_union_type(zend_type type) {
+ if (ZEND_TYPE_HAS_LIST(type)) {
+ return 1;
+ }
+ uint32_t type_mask_without_null = ZEND_TYPE_PURE_MASK_WITHOUT_NULL(type);
+ if (ZEND_TYPE_HAS_CLASS(type)) {
+ return type_mask_without_null != 0;
+ }
+ if (type_mask_without_null == MAY_BE_BOOL) {
+ return 0;
+ }
+ /* Check that only one bit is set. */
+ return (type_mask_without_null & (type_mask_without_null - 1)) != 0;
+}
+
/* {{{ reflection_type_factory */
-static void reflection_type_factory(zend_type type, zval *object)
+static void reflection_type_factory(zend_type type, zval *object, zend_bool legacy_behavior)
{
reflection_object *intern;
type_reference *reference;
+ zend_bool is_union = is_union_type(type);
+ zend_bool is_mixed = ZEND_TYPE_PURE_MASK(type) == MAY_BE_ANY;
- reflection_instantiate(reflection_named_type_ptr, object);
+ reflection_instantiate(is_union && !is_mixed ? reflection_union_type_ptr : reflection_named_type_ptr, object);
intern = Z_REFLECTION_P(object);
reference = (type_reference*) emalloc(sizeof(type_reference));
reference->type = type;
+ reference->legacy_behavior = legacy_behavior && !is_union && !is_mixed;
intern->ptr = reference;
intern->ref_type = REF_TYPE_TYPE;
- /* Property types may be resolved during the lifetime of the ReflectionType,
- * so we need to make sure that the strings we reference are not released. */
- if (ZEND_TYPE_IS_NAME(type)) {
+ /* Property types may be resolved during the lifetime of the ReflectionType.
+ * If we reference a string, make sure it doesn't get released. However, only
+ * do this for the top-level type, as resolutions inside type lists will be
+ * fully visible to us (we'd have to do a fully copy of the type if we wanted
+ * to prevent that). */
+ if (ZEND_TYPE_HAS_NAME(type)) {
zend_string_addref(ZEND_TYPE_NAME(type));
}
}
@@ -1186,8 +1361,7 @@ static void reflection_function_factory(zend_function *function, zval *closure_o
intern->ref_type = REF_TYPE_FUNCTION;
intern->ce = NULL;
if (closure_object) {
- Z_ADDREF_P(closure_object);
- ZVAL_OBJ(&intern->obj, Z_OBJ_P(closure_object));
+ ZVAL_OBJ_COPY(&intern->obj, Z_OBJ_P(closure_object));
}
ZVAL_STR_COPY(reflection_prop_name(object), function->common.function_name);
}
@@ -1204,69 +1378,43 @@ static void reflection_method_factory(zend_class_entry *ce, zend_function *metho
intern->ref_type = REF_TYPE_FUNCTION;
intern->ce = ce;
if (closure_object) {
- Z_ADDREF_P(closure_object);
- ZVAL_OBJ(&intern->obj, Z_OBJ_P(closure_object));
+ ZVAL_OBJ_COPY(&intern->obj, Z_OBJ_P(closure_object));
}
- ZVAL_STR_COPY(reflection_prop_name(object),
- (method->common.scope && method->common.scope->trait_aliases)
- ? zend_resolve_method_name(ce, method) : method->common.function_name);
+ ZVAL_STR_COPY(reflection_prop_name(object), method->common.function_name);
ZVAL_STR_COPY(reflection_prop_class(object), method->common.scope->name);
}
/* }}} */
/* {{{ reflection_property_factory */
-static void reflection_property_factory(zend_class_entry *ce, zend_string *name, zend_property_info *prop, zval *object, zend_bool dynamic)
+static void reflection_property_factory(zend_class_entry *ce, zend_string *name, zend_property_info *prop, zval *object)
{
reflection_object *intern;
property_reference *reference;
- if (!(prop->flags & ZEND_ACC_PRIVATE)) {
- /* we have to search the class hierarchy for this (implicit) public or protected property */
- zend_class_entry *tmp_ce = ce, *store_ce = ce;
- zend_property_info *tmp_info = NULL;
-
- while (tmp_ce && (tmp_info = zend_hash_find_ptr(&tmp_ce->properties_info, name)) == NULL) {
- ce = tmp_ce;
- tmp_ce = tmp_ce->parent;
- }
-
- if (tmp_info && (!(tmp_info->flags & ZEND_ACC_PRIVATE) || tmp_info->ce == tmp_ce)) { /* found something and it's not a parent's private */
- prop = tmp_info;
- } else { /* not found, use initial value */
- ce = store_ce;
- }
- }
-
reflection_instantiate(reflection_property_ptr, object);
intern = Z_REFLECTION_P(object);
reference = (property_reference*) emalloc(sizeof(property_reference));
- reference->prop = *prop;
-
- if (ZEND_TYPE_IS_NAME(reference->prop.type)) {
- zend_string_addref(ZEND_TYPE_NAME(reference->prop.type));
- }
-
+ reference->prop = prop;
reference->unmangled_name = zend_string_copy(name);
- reference->dynamic = dynamic;
intern->ptr = reference;
intern->ref_type = REF_TYPE_PROPERTY;
intern->ce = ce;
intern->ignore_visibility = 0;
ZVAL_STR_COPY(reflection_prop_name(object), name);
- ZVAL_STR_COPY(reflection_prop_class(object), prop->ce->name);
+ ZVAL_STR_COPY(reflection_prop_class(object), prop ? prop->ce->name : ce->name);
}
/* }}} */
static void reflection_property_factory_str(zend_class_entry *ce, const char *name_str, size_t name_len, zend_property_info *prop, zval *object)
{
zend_string *name = zend_string_init(name_str, name_len, 0);
- reflection_property_factory(ce, name, prop, object, 0);
+ reflection_property_factory(ce, name, prop, object);
zend_string_release(name);
}
/* {{{ reflection_class_constant_factory */
-static void reflection_class_constant_factory(zend_class_entry *ce, zend_string *name_str, zend_class_constant *constant, zval *object)
+static void reflection_class_constant_factory(zend_string *name_str, zend_class_constant *constant, zval *object)
{
reflection_object *intern;
@@ -1278,182 +1426,44 @@ static void reflection_class_constant_factory(zend_class_entry *ce, zend_string
intern->ignore_visibility = 0;
ZVAL_STR_COPY(reflection_prop_name(object), name_str);
- ZVAL_STR_COPY(reflection_prop_class(object), ce->name);
+ ZVAL_STR_COPY(reflection_prop_class(object), constant->ce->name);
}
/* }}} */
-static void reflection_export_impl(zval *return_value, zval *object, zend_bool return_output) {
- zval fname, retval;
- int result;
-
- /* Invoke the __toString() method */
- ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring") - 1);
- result = call_user_function(NULL, object, &fname, &retval, 0, NULL);
- zval_ptr_dtor_str(&fname);
-
- if (result == FAILURE) {
- _DO_THROW("Invocation of method __toString() failed");
- return;
- }
-
- if (Z_TYPE(retval) == IS_UNDEF) {
- php_error_docref(NULL, E_WARNING, "%s::__toString() did not return anything", ZSTR_VAL(Z_OBJCE_P(object)->name));
- RETURN_FALSE;
- }
-
- if (return_output) {
- ZVAL_COPY_VALUE(return_value, &retval);
- } else {
- /* No need for _r variant, return of __toString should always be a string */
- zend_print_zval(&retval, 0);
- zend_printf("\n");
- zval_ptr_dtor(&retval);
- }
-}
-
-/* {{{ _reflection_export */
-static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *ce_ptr, int ctor_argc)
-{
- zval reflector;
- zval *argument_ptr, *argument2_ptr;
- zval retval, params[2];
- int result;
- int return_output = 0;
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
-
- if (ctor_argc == 1) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &argument_ptr, &return_output) == FAILURE) {
- return;
+static int get_parameter_default(zval *result, parameter_reference *param) {
+ if (param->fptr->type == ZEND_INTERNAL_FUNCTION) {
+ if (param->fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO) {
+ /* We don't have a way to determine the default value for this case right now. */
+ return FAILURE;
}
- ZVAL_COPY_VALUE(&params[0], argument_ptr);
- ZVAL_NULL(&params[1]);
+ return zend_get_default_from_internal_arg_info(
+ result, (zend_internal_arg_info *) param->arg_info);
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz|b", &argument_ptr, &argument2_ptr, &return_output) == FAILURE) {
- return;
+ zval *default_value = get_default_from_recv((zend_op_array *) param->fptr, param->offset);
+ if (!default_value) {
+ return FAILURE;
}
- ZVAL_COPY_VALUE(&params[0], argument_ptr);
- ZVAL_COPY_VALUE(&params[1], argument2_ptr);
- }
- /* Create object */
- if (object_init_ex(&reflector, ce_ptr) == FAILURE) {
- _DO_THROW("Could not create reflector");
- return;
- }
-
- /* Call __construct() */
-
- fci.size = sizeof(fci);
- ZVAL_UNDEF(&fci.function_name);
- fci.object = Z_OBJ(reflector);
- fci.retval = &retval;
- fci.param_count = ctor_argc;
- fci.params = params;
- fci.no_separation = 1;
-
- fcc.function_handler = ce_ptr->constructor;
- fcc.called_scope = Z_OBJCE(reflector);
- fcc.object = Z_OBJ(reflector);
-
- result = zend_call_function(&fci, &fcc);
-
- zval_ptr_dtor(&retval);
-
- if (EG(exception)) {
- zval_ptr_dtor(&reflector);
- return;
- }
- if (result == FAILURE) {
- zval_ptr_dtor(&reflector);
- _DO_THROW("Could not create reflector");
- return;
+ ZVAL_COPY(result, default_value);
+ return SUCCESS;
}
-
- reflection_export_impl(return_value, &reflector, return_output);
-
- /* Destruct reflector which is no longer needed */
- zval_ptr_dtor(&reflector);
-}
-/* }}} */
-
-/* {{{ _reflection_param_get_default_param */
-static parameter_reference *_reflection_param_get_default_param(INTERNAL_FUNCTION_PARAMETERS)
-{
- reflection_object *intern;
- parameter_reference *param;
-
- intern = Z_REFLECTION_P(ZEND_THIS);
- if (intern->ptr == NULL) {
- if (EG(exception) && EG(exception)->ce == reflection_exception_ptr) {
- return NULL;
- }
- zend_throw_error(NULL, "Internal error: Failed to retrieve the reflection object");
- return NULL;
- }
-
- param = intern->ptr;
- if (param->fptr->type != ZEND_USER_FUNCTION) {
- zend_throw_exception_ex(reflection_exception_ptr, 0, "Cannot determine default value for internal functions");
- return NULL;
- }
-
- return param;
}
-/* }}} */
-
-/* {{{ _reflection_param_get_default_precv */
-static zend_op *_reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAMETERS, parameter_reference *param)
-{
- zend_op *precv;
-
- if (param == NULL) {
- return NULL;
- }
-
- precv = _get_recv_op((zend_op_array*)param->fptr, param->offset);
- if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) {
- zend_throw_exception_ex(reflection_exception_ptr, 0, "Internal error: Failed to retrieve the default value");
- return NULL;
- }
-
- return precv;
-}
-/* }}} */
/* {{{ Preventing __clone from being called */
-ZEND_METHOD(reflection, __clone)
+ZEND_METHOD(ReflectionClass, __clone)
{
/* Should never be executable */
_DO_THROW("Cannot clone object using __clone()");
}
/* }}} */
-/* {{{ proto public static mixed Reflection::export(Reflector r [, bool return])
- Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
-ZEND_METHOD(reflection, export)
-{
- zval *object;
- zend_bool return_output = 0;
-
- ZEND_PARSE_PARAMETERS_START(1, 2)
- Z_PARAM_OBJECT_OF_CLASS(object, reflector_ptr)
- Z_PARAM_OPTIONAL
- Z_PARAM_BOOL(return_output)
- ZEND_PARSE_PARAMETERS_END();
-
- reflection_export_impl(return_value, object, return_output);
-}
-/* }}} */
-
-/* {{{ proto public static array Reflection::getModifierNames(int modifiers)
- Returns an array of modifier names */
-ZEND_METHOD(reflection, getModifierNames)
+/* {{{ Returns an array of modifier names */
+ZEND_METHOD(Reflection, getModifierNames)
{
zend_long modifiers;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &modifiers) == FAILURE) {
- return;
+ RETURN_THROWS();
}
array_init(return_value);
@@ -1484,20 +1494,11 @@ ZEND_METHOD(reflection, getModifierNames)
}
/* }}} */
-/* {{{ proto public static mixed ReflectionFunction::export(string name [, bool return])
- Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
-ZEND_METHOD(reflection_function, export)
-{
- _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_function_ptr, 1);
-}
-/* }}} */
-
-/* {{{ proto public void ReflectionFunction::__construct(string name)
- Constructor. Throws an Exception in case the given function does not exist */
-ZEND_METHOD(reflection_function, __construct)
+/* {{{ Constructor. Throws an Exception in case the given function does not exist */
+ZEND_METHOD(ReflectionFunction, __construct)
{
zval *object;
- zval *closure = NULL;
+ zend_object *closure_obj = NULL;
reflection_object *intern;
zend_function *fptr;
zend_string *fname, *lcname;
@@ -1505,18 +1506,16 @@ ZEND_METHOD(reflection_function, __construct)
object = ZEND_THIS;
intern = Z_REFLECTION_P(object);
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "O", &closure, zend_ce_closure) == SUCCESS) {
- fptr = (zend_function*)zend_get_closure_method_def(closure);
- Z_ADDREF_P(closure);
- } else {
- ALLOCA_FLAG(use_heap)
-
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "S", &fname) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJ_OF_CLASS_OR_STR(closure_obj, zend_ce_closure, fname)
+ ZEND_PARSE_PARAMETERS_END();
+ if (closure_obj) {
+ fptr = (zend_function*)zend_get_closure_method_def(closure_obj);
+ } else {
if (UNEXPECTED(ZSTR_VAL(fname)[0] == '\\')) {
/* Ignore leading "\" */
+ ALLOCA_FLAG(use_heap)
ZSTR_ALLOCA_ALLOC(lcname, ZSTR_LEN(fname) - 1, use_heap);
zend_str_tolower_copy(ZSTR_VAL(lcname), ZSTR_VAL(fname) + 1, ZSTR_LEN(fname) - 1);
fptr = zend_fetch_function(lcname);
@@ -1530,7 +1529,7 @@ ZEND_METHOD(reflection_function, __construct)
if (fptr == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Function %s() does not exist", ZSTR_VAL(fname));
- return;
+ RETURN_THROWS();
}
}
@@ -1542,8 +1541,8 @@ ZEND_METHOD(reflection_function, __construct)
ZVAL_STR_COPY(reflection_prop_name(object), fptr->common.function_name);
intern->ptr = fptr;
intern->ref_type = REF_TYPE_FUNCTION;
- if (closure) {
- ZVAL_OBJ(&intern->obj, Z_OBJ_P(closure));
+ if (closure_obj) {
+ ZVAL_OBJ_COPY(&intern->obj, closure_obj);
} else {
ZVAL_UNDEF(&intern->obj);
}
@@ -1551,16 +1550,15 @@ ZEND_METHOD(reflection_function, __construct)
}
/* }}} */
-/* {{{ proto public string ReflectionFunction::__toString()
- Returns a string representation */
-ZEND_METHOD(reflection_function, __toString)
+/* {{{ Returns a string representation */
+ZEND_METHOD(ReflectionFunction, __toString)
{
reflection_object *intern;
zend_function *fptr;
smart_str str = {0};
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(fptr);
_function_string(&str, fptr, intern->ce, "");
@@ -1568,66 +1566,66 @@ ZEND_METHOD(reflection_function, __toString)
}
/* }}} */
-/* {{{ proto public string ReflectionFunction::getName()
- Returns this function's name */
-ZEND_METHOD(reflection_function, getName)
+/* {{{ Returns this function's name */
+ZEND_METHOD(ReflectionFunctionAbstract, getName)
{
+ reflection_object *intern;
+ zend_function *fptr;
+
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
- _default_get_name(ZEND_THIS, return_value);
+
+ GET_REFLECTION_OBJECT_PTR(fptr);
+ RETURN_STR_COPY(fptr->common.function_name);
}
/* }}} */
-/* {{{ proto public bool ReflectionFunction::isClosure()
- Returns whether this is a closure */
-ZEND_METHOD(reflection_function, isClosure)
+/* {{{ Returns whether this is a closure */
+ZEND_METHOD(ReflectionFunctionAbstract, isClosure)
{
reflection_object *intern;
zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(fptr);
RETURN_BOOL(fptr->common.fn_flags & ZEND_ACC_CLOSURE);
}
/* }}} */
-/* {{{ proto public bool ReflectionFunction::getClosureThis()
- Returns this pointer bound to closure */
-ZEND_METHOD(reflection_function, getClosureThis)
+/* {{{ Returns this pointer bound to closure */
+ZEND_METHOD(ReflectionFunctionAbstract, getClosureThis)
{
reflection_object *intern;
zval* closure_this;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT();
if (!Z_ISUNDEF(intern->obj)) {
closure_this = zend_get_closure_this_ptr(&intern->obj);
if (!Z_ISUNDEF_P(closure_this)) {
- Z_ADDREF_P(closure_this);
- ZVAL_OBJ(return_value, Z_OBJ_P(closure_this));
+ RETURN_OBJ_COPY(Z_OBJ_P(closure_this));
}
}
}
/* }}} */
-/* {{{ proto public ReflectionClass ReflectionFunction::getClosureScopeClass()
- Returns the scope associated to the closure */
-ZEND_METHOD(reflection_function, getClosureScopeClass)
+/* {{{ Returns the scope associated to the closure */
+ZEND_METHOD(ReflectionFunctionAbstract, getClosureScopeClass)
{
reflection_object *intern;
const zend_function *closure_func;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT();
if (!Z_ISUNDEF(intern->obj)) {
- closure_func = zend_get_closure_method_def(&intern->obj);
+ closure_func = zend_get_closure_method_def(Z_OBJ(intern->obj));
if (closure_func && closure_func->common.scope) {
zend_reflection_class_factory(closure_func->common.scope, return_value);
}
@@ -1635,79 +1633,74 @@ ZEND_METHOD(reflection_function, getClosureScopeClass)
}
/* }}} */
-/* {{{ proto public mixed ReflectionFunction::getClosure()
- Returns a dynamically created closure for the function */
-ZEND_METHOD(reflection_function, getClosure)
+/* {{{ Returns a dynamically created closure for the function */
+ZEND_METHOD(ReflectionFunction, getClosure)
{
reflection_object *intern;
zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(fptr);
if (!Z_ISUNDEF(intern->obj)) {
/* Closures are immutable objects */
- Z_ADDREF(intern->obj);
- ZVAL_OBJ(return_value, Z_OBJ(intern->obj));
+ RETURN_OBJ_COPY(Z_OBJ(intern->obj));
} else {
zend_create_fake_closure(return_value, fptr, NULL, NULL, NULL);
}
}
/* }}} */
-/* {{{ proto public bool ReflectionFunction::isInternal()
- Returns whether this is an internal function */
-ZEND_METHOD(reflection_function, isInternal)
+/* {{{ Returns whether this is an internal function */
+ZEND_METHOD(ReflectionFunctionAbstract, isInternal)
{
reflection_object *intern;
zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(fptr);
RETURN_BOOL(fptr->type == ZEND_INTERNAL_FUNCTION);
}
/* }}} */
-/* {{{ proto public bool ReflectionFunction::isUserDefined()
- Returns whether this is a user-defined function */
-ZEND_METHOD(reflection_function, isUserDefined)
+/* {{{ Returns whether this is a user-defined function */
+ZEND_METHOD(ReflectionFunctionAbstract, isUserDefined)
{
reflection_object *intern;
zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(fptr);
RETURN_BOOL(fptr->type == ZEND_USER_FUNCTION);
}
/* }}} */
-/* {{{ proto public bool ReflectionFunction::isDisabled()
- Returns whether this function has been disabled or not */
-ZEND_METHOD(reflection_function, isDisabled)
+/* {{{ Returns whether this function has been disabled or not */
+ZEND_METHOD(ReflectionFunction, isDisabled)
{
- reflection_object *intern;
- zend_function *fptr;
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
- GET_REFLECTION_OBJECT_PTR(fptr);
- RETURN_BOOL(fptr->type == ZEND_INTERNAL_FUNCTION && fptr->internal_function.handler == zif_display_disabled_function);
+ /* A disabled function cannot be queried using Reflection. */
+ RETURN_FALSE;
}
/* }}} */
-/* {{{ proto public string ReflectionFunction::getFileName()
- Returns the filename of the file this function was declared in */
-ZEND_METHOD(reflection_function, getFileName)
+/* {{{ Returns the filename of the file this function was declared in */
+ZEND_METHOD(ReflectionFunctionAbstract, getFileName)
{
reflection_object *intern;
zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(fptr);
if (fptr->type == ZEND_USER_FUNCTION) {
@@ -1717,15 +1710,14 @@ ZEND_METHOD(reflection_function, getFileName)
}
/* }}} */
-/* {{{ proto public int ReflectionFunction::getStartLine()
- Returns the line this function's declaration starts at */
-ZEND_METHOD(reflection_function, getStartLine)
+/* {{{ Returns the line this function's declaration starts at */
+ZEND_METHOD(ReflectionFunctionAbstract, getStartLine)
{
reflection_object *intern;
zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(fptr);
if (fptr->type == ZEND_USER_FUNCTION) {
@@ -1735,15 +1727,14 @@ ZEND_METHOD(reflection_function, getStartLine)
}
/* }}} */
-/* {{{ proto public int ReflectionFunction::getEndLine()
- Returns the line this function's declaration ends at */
-ZEND_METHOD(reflection_function, getEndLine)
+/* {{{ Returns the line this function's declaration ends at */
+ZEND_METHOD(ReflectionFunctionAbstract, getEndLine)
{
reflection_object *intern;
zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(fptr);
if (fptr->type == ZEND_USER_FUNCTION) {
@@ -1753,15 +1744,14 @@ ZEND_METHOD(reflection_function, getEndLine)
}
/* }}} */
-/* {{{ proto public string ReflectionFunction::getDocComment()
- Returns the doc comment for this function */
-ZEND_METHOD(reflection_function, getDocComment)
+/* {{{ Returns the doc comment for this function */
+ZEND_METHOD(ReflectionFunctionAbstract, getDocComment)
{
reflection_object *intern;
zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(fptr);
if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) {
@@ -1771,16 +1761,36 @@ ZEND_METHOD(reflection_function, getDocComment)
}
/* }}} */
-/* {{{ proto public array ReflectionFunction::getStaticVariables()
- Returns an associative array containing this function's static variables and their values */
-ZEND_METHOD(reflection_function, getStaticVariables)
+/* {{{ Returns the attributes of this function */
+ZEND_METHOD(ReflectionFunctionAbstract, getAttributes)
+{
+ reflection_object *intern;
+ zend_function *fptr;
+ uint32_t target;
+
+ GET_REFLECTION_OBJECT_PTR(fptr);
+
+ if (fptr->common.scope) {
+ target = ZEND_ATTRIBUTE_TARGET_METHOD;
+ } else {
+ target = ZEND_ATTRIBUTE_TARGET_FUNCTION;
+ }
+
+ reflect_attributes(INTERNAL_FUNCTION_PARAM_PASSTHRU,
+ fptr->common.attributes, 0, fptr->common.scope, target,
+ fptr->type == ZEND_USER_FUNCTION ? fptr->op_array.filename : NULL);
+}
+/* }}} */
+
+/* {{{ Returns an associative array containing this function's static variables and their values */
+ZEND_METHOD(ReflectionFunctionAbstract, getStaticVariables)
{
reflection_object *intern;
zend_function *fptr;
zval *val;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(fptr);
@@ -1797,7 +1807,7 @@ ZEND_METHOD(reflection_function, getStaticVariables)
}
ZEND_HASH_FOREACH_VAL(ht, val) {
if (UNEXPECTED(zval_update_constant_ex(val, fptr->common.scope) != SUCCESS)) {
- return;
+ RETURN_THROWS();
}
} ZEND_HASH_FOREACH_END();
zend_hash_copy(Z_ARRVAL_P(return_value), ht, zval_add_ref);
@@ -1807,23 +1817,23 @@ ZEND_METHOD(reflection_function, getStaticVariables)
}
/* }}} */
-/* {{{ proto public mixed ReflectionFunction::invoke([mixed* args])
- Invokes the function */
-ZEND_METHOD(reflection_function, invoke)
+/* {{{ Invokes the function */
+ZEND_METHOD(ReflectionFunction, invoke)
{
zval retval;
- zval *params = NULL;
- int result, num_args = 0;
+ zval *params;
+ int result, num_args;
+ HashTable *named_params;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
reflection_object *intern;
zend_function *fptr;
- GET_REFLECTION_OBJECT_PTR(fptr);
+ ZEND_PARSE_PARAMETERS_START(0, -1)
+ Z_PARAM_VARIADIC_WITH_NAMED(params, num_args, named_params)
+ ZEND_PARSE_PARAMETERS_END();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "*", &params, &num_args) == FAILURE) {
- return;
- }
+ GET_REFLECTION_OBJECT_PTR(fptr);
fci.size = sizeof(fci);
ZVAL_UNDEF(&fci.function_name);
@@ -1831,7 +1841,7 @@ ZEND_METHOD(reflection_function, invoke)
fci.retval = &retval;
fci.param_count = num_args;
fci.params = params;
- fci.no_separation = 1;
+ fci.named_params = named_params;
fcc.function_handler = fptr;
fcc.called_scope = NULL;
@@ -1839,7 +1849,7 @@ ZEND_METHOD(reflection_function, invoke)
if (!Z_ISUNDEF(intern->obj)) {
Z_OBJ_HT(intern->obj)->get_closure(
- &intern->obj, &fcc.called_scope, &fcc.function_handler, &fcc.object);
+ Z_OBJ(intern->obj), &fcc.called_scope, &fcc.function_handler, &fcc.object, 0);
}
result = zend_call_function(&fci, &fcc);
@@ -1847,7 +1857,7 @@ ZEND_METHOD(reflection_function, invoke)
if (result == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Invocation of function %s() failed", ZSTR_VAL(fptr->common.function_name));
- return;
+ RETURN_THROWS();
}
if (Z_TYPE(retval) != IS_UNDEF) {
@@ -1859,42 +1869,30 @@ ZEND_METHOD(reflection_function, invoke)
}
/* }}} */
-/* {{{ proto public mixed ReflectionFunction::invokeArgs(array args)
- Invokes the function and pass its arguments as array. */
-ZEND_METHOD(reflection_function, invokeArgs)
+/* {{{ Invokes the function and pass its arguments as array. */
+ZEND_METHOD(ReflectionFunction, invokeArgs)
{
zval retval;
- zval *params, *val;
int result;
- int i, argc;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
reflection_object *intern;
zend_function *fptr;
- zval *param_array;
+ HashTable *params;
GET_REFLECTION_OBJECT_PTR(fptr);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &param_array) == FAILURE) {
- return;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "h", &params) == FAILURE) {
+ RETURN_THROWS();
}
- argc = zend_hash_num_elements(Z_ARRVAL_P(param_array));
-
- params = safe_emalloc(sizeof(zval), argc, 0);
- argc = 0;
- ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(param_array), val) {
- ZVAL_COPY(&params[argc], val);
- argc++;
- } ZEND_HASH_FOREACH_END();
-
fci.size = sizeof(fci);
ZVAL_UNDEF(&fci.function_name);
fci.object = NULL;
fci.retval = &retval;
- fci.param_count = argc;
- fci.params = params;
- fci.no_separation = 1;
+ fci.param_count = 0;
+ fci.params = NULL;
+ fci.named_params = params;
fcc.function_handler = fptr;
fcc.called_scope = NULL;
@@ -1902,20 +1900,15 @@ ZEND_METHOD(reflection_function, invokeArgs)
if (!Z_ISUNDEF(intern->obj)) {
Z_OBJ_HT(intern->obj)->get_closure(
- &intern->obj, &fcc.called_scope, &fcc.function_handler, &fcc.object);
+ Z_OBJ(intern->obj), &fcc.called_scope, &fcc.function_handler, &fcc.object, 0);
}
result = zend_call_function(&fci, &fcc);
- for (i = 0; i < argc; i++) {
- zval_ptr_dtor(&params[i]);
- }
- efree(params);
-
if (result == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Invocation of function %s() failed", ZSTR_VAL(fptr->common.function_name));
- return;
+ RETURN_THROWS();
}
if (Z_TYPE(retval) != IS_UNDEF) {
@@ -1927,22 +1920,24 @@ ZEND_METHOD(reflection_function, invokeArgs)
}
/* }}} */
-/* {{{ proto public bool ReflectionFunction::returnsReference()
- Gets whether this function returns a reference */
-ZEND_METHOD(reflection_function, returnsReference)
+/* {{{ Gets whether this function returns a reference */
+ZEND_METHOD(ReflectionFunctionAbstract, returnsReference)
{
reflection_object *intern;
zend_function *fptr;
GET_REFLECTION_OBJECT_PTR(fptr);
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
RETURN_BOOL((fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0);
}
/* }}} */
-/* {{{ proto public bool ReflectionFunction::getNumberOfParameters()
- Gets the number of parameters */
-ZEND_METHOD(reflection_function, getNumberOfParameters)
+/* {{{ Gets the number of parameters */
+ZEND_METHOD(ReflectionFunctionAbstract, getNumberOfParameters)
{
reflection_object *intern;
zend_function *fptr;
@@ -1950,6 +1945,10 @@ ZEND_METHOD(reflection_function, getNumberOfParameters)
GET_REFLECTION_OBJECT_PTR(fptr);
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
num_args = fptr->common.num_args;
if (fptr->common.fn_flags & ZEND_ACC_VARIADIC) {
num_args++;
@@ -1959,22 +1958,24 @@ ZEND_METHOD(reflection_function, getNumberOfParameters)
}
/* }}} */
-/* {{{ proto public bool ReflectionFunction::getNumberOfRequiredParameters()
- Gets the number of required parameters */
-ZEND_METHOD(reflection_function, getNumberOfRequiredParameters)
+/* {{{ Gets the number of required parameters */
+ZEND_METHOD(ReflectionFunctionAbstract, getNumberOfRequiredParameters)
{
reflection_object *intern;
zend_function *fptr;
GET_REFLECTION_OBJECT_PTR(fptr);
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
RETURN_LONG(fptr->common.required_num_args);
}
/* }}} */
-/* {{{ proto public ReflectionParameter[] ReflectionFunction::getParameters()
- Returns an array of parameter objects for this function */
-ZEND_METHOD(reflection_function, getParameters)
+/* {{{ Returns an array of parameter objects for this function */
+ZEND_METHOD(ReflectionFunctionAbstract, getParameters)
{
reflection_object *intern;
zend_function *fptr;
@@ -1983,6 +1984,10 @@ ZEND_METHOD(reflection_function, getParameters)
GET_REFLECTION_OBJECT_PTR(fptr);
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
arg_info= fptr->common.arg_info;
num_args = fptr->common.num_args;
if (fptr->common.fn_flags & ZEND_ACC_VARIADIC) {
@@ -2012,9 +2017,8 @@ ZEND_METHOD(reflection_function, getParameters)
}
/* }}} */
-/* {{{ proto public ReflectionExtension|NULL ReflectionFunction::getExtension()
- Returns NULL or the extension the function belongs to */
-ZEND_METHOD(reflection_function, getExtension)
+/* {{{ Returns NULL or the extension the function belongs to */
+ZEND_METHOD(ReflectionFunctionAbstract, getExtension)
{
reflection_object *intern;
zend_function *fptr;
@@ -2022,6 +2026,10 @@ ZEND_METHOD(reflection_function, getExtension)
GET_REFLECTION_OBJECT_PTR(fptr);
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
if (fptr->type != ZEND_INTERNAL_FUNCTION) {
RETURN_NULL();
}
@@ -2035,9 +2043,8 @@ ZEND_METHOD(reflection_function, getExtension)
}
/* }}} */
-/* {{{ proto public string|false ReflectionFunction::getExtensionName()
- Returns false or the name of the extension the function belongs to */
-ZEND_METHOD(reflection_function, getExtensionName)
+/* {{{ Returns false or the name of the extension the function belongs to */
+ZEND_METHOD(ReflectionFunctionAbstract, getExtensionName)
{
reflection_object *intern;
zend_function *fptr;
@@ -2045,6 +2052,10 @@ ZEND_METHOD(reflection_function, getExtensionName)
GET_REFLECTION_OBJECT_PTR(fptr);
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
if (fptr->type != ZEND_INTERNAL_FUNCTION) {
RETURN_FALSE;
}
@@ -2058,8 +2069,8 @@ ZEND_METHOD(reflection_function, getExtensionName)
}
/* }}} */
-/* {{{ proto public void ReflectionGenerator::__construct(object Generator) */
-ZEND_METHOD(reflection_generator, __construct)
+/* {{{ */
+ZEND_METHOD(ReflectionGenerator, __construct)
{
zval *generator, *object;
reflection_object *intern;
@@ -2068,14 +2079,14 @@ ZEND_METHOD(reflection_generator, __construct)
object = ZEND_THIS;
intern = Z_REFLECTION_P(object);
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "O", &generator, zend_ce_generator) == FAILURE) {
- return;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &generator, zend_ce_generator) == FAILURE) {
+ RETURN_THROWS();
}
ex = ((zend_generator *) Z_OBJ_P(generator))->execute_data;
if (!ex) {
_DO_THROW("Cannot create ReflectionGenerator based on a terminated Generator");
- return;
+ RETURN_THROWS();
}
if (intern->ce) {
@@ -2083,8 +2094,7 @@ ZEND_METHOD(reflection_generator, __construct)
}
intern->ref_type = REF_TYPE_GENERATOR;
- Z_ADDREF_P(generator);
- ZVAL_OBJ(&intern->obj, Z_OBJ_P(generator));
+ ZVAL_OBJ_COPY(&intern->obj, Z_OBJ_P(generator));
intern->ce = zend_ce_generator;
}
/* }}} */
@@ -2092,11 +2102,11 @@ ZEND_METHOD(reflection_generator, __construct)
#define REFLECTION_CHECK_VALID_GENERATOR(ex) \
if (!ex) { \
_DO_THROW("Cannot fetch information from a terminated Generator"); \
- return; \
+ RETURN_THROWS(); \
}
-/* {{{ proto public array ReflectionGenerator::getTrace($options = DEBUG_BACKTRACE_PROVIDE_OBJECT) */
-ZEND_METHOD(reflection_generator, getTrace)
+/* {{{ */
+ZEND_METHOD(ReflectionGenerator, getTrace)
{
zend_long options = DEBUG_BACKTRACE_PROVIDE_OBJECT;
zend_generator *generator = (zend_generator *) Z_OBJ(Z_REFLECTION_P(ZEND_THIS)->obj);
@@ -2106,7 +2116,7 @@ ZEND_METHOD(reflection_generator, getTrace)
zend_execute_data *root_prev = NULL, *cur_prev;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &options) == FAILURE) {
- return;
+ RETURN_THROWS();
}
REFLECTION_CHECK_VALID_GENERATOR(ex)
@@ -2131,14 +2141,14 @@ ZEND_METHOD(reflection_generator, getTrace)
}
/* }}} */
-/* {{{ proto public int ReflectionGenerator::getExecutingLine() */
-ZEND_METHOD(reflection_generator, getExecutingLine)
+/* {{{ */
+ZEND_METHOD(ReflectionGenerator, getExecutingLine)
{
zend_generator *generator = (zend_generator *) Z_OBJ(Z_REFLECTION_P(ZEND_THIS)->obj);
zend_execute_data *ex = generator->execute_data;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
REFLECTION_CHECK_VALID_GENERATOR(ex)
@@ -2147,14 +2157,14 @@ ZEND_METHOD(reflection_generator, getExecutingLine)
}
/* }}} */
-/* {{{ proto public string ReflectionGenerator::getExecutingFile() */
-ZEND_METHOD(reflection_generator, getExecutingFile)
+/* {{{ */
+ZEND_METHOD(ReflectionGenerator, getExecutingFile)
{
zend_generator *generator = (zend_generator *) Z_OBJ(Z_REFLECTION_P(ZEND_THIS)->obj);
zend_execute_data *ex = generator->execute_data;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
REFLECTION_CHECK_VALID_GENERATOR(ex)
@@ -2163,14 +2173,14 @@ ZEND_METHOD(reflection_generator, getExecutingFile)
}
/* }}} */
-/* {{{ proto public ReflectionFunctionAbstract ReflectionGenerator::getFunction() */
-ZEND_METHOD(reflection_generator, getFunction)
+/* {{{ */
+ZEND_METHOD(ReflectionGenerator, getFunction)
{
zend_generator *generator = (zend_generator *) Z_OBJ(Z_REFLECTION_P(ZEND_THIS)->obj);
zend_execute_data *ex = generator->execute_data;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
REFLECTION_CHECK_VALID_GENERATOR(ex)
@@ -2187,74 +2197,64 @@ ZEND_METHOD(reflection_generator, getFunction)
}
/* }}} */
-/* {{{ proto public object ReflectionGenerator::getThis() */
-ZEND_METHOD(reflection_generator, getThis)
+/* {{{ */
+ZEND_METHOD(ReflectionGenerator, getThis)
{
zend_generator *generator = (zend_generator *) Z_OBJ(Z_REFLECTION_P(ZEND_THIS)->obj);
zend_execute_data *ex = generator->execute_data;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
REFLECTION_CHECK_VALID_GENERATOR(ex)
if (Z_TYPE(ex->This) == IS_OBJECT) {
- Z_ADDREF(ex->This);
- ZVAL_OBJ(return_value, Z_OBJ(ex->This));
+ RETURN_OBJ_COPY(Z_OBJ(ex->This));
} else {
- ZVAL_NULL(return_value);
+ RETURN_NULL();
}
}
/* }}} */
-/* {{{ proto public Generator ReflectionGenerator::getExecutingGenerator() */
-ZEND_METHOD(reflection_generator, getExecutingGenerator)
+/* {{{ */
+ZEND_METHOD(ReflectionGenerator, getExecutingGenerator)
{
zend_generator *generator = (zend_generator *) Z_OBJ(Z_REFLECTION_P(ZEND_THIS)->obj);
zend_execute_data *ex = generator->execute_data;
zend_generator *current;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
REFLECTION_CHECK_VALID_GENERATOR(ex)
current = zend_generator_get_current(generator);
- GC_ADDREF(&current->std);
-
- ZVAL_OBJ(return_value, (zend_object *) current);
-}
-/* }}} */
-
-/* {{{ proto public static mixed ReflectionParameter::export(mixed function, mixed parameter [, bool return]) throws ReflectionException
- Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
-ZEND_METHOD(reflection_parameter, export)
-{
- _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_parameter_ptr, 2);
+ RETURN_OBJ_COPY(&current->std);
}
/* }}} */
-/* {{{ proto public void ReflectionParameter::__construct(mixed function, mixed parameter)
- Constructor. Throws an Exception in case the given method does not exist */
-ZEND_METHOD(reflection_parameter, __construct)
+/* {{{ Constructor. Throws an Exception in case the given method does not exist */
+ZEND_METHOD(ReflectionParameter, __construct)
{
parameter_reference *ref;
- zval *reference, *parameter;
+ zval *reference;
+ zend_string *arg_name = NULL;
+ zend_long position;
zval *object;
zval *prop_name;
reflection_object *intern;
zend_function *fptr;
struct _zend_arg_info *arg_info;
- int position;
uint32_t num_args;
zend_class_entry *ce = NULL;
zend_bool is_closure = 0;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "zz", &reference, &parameter) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_ZVAL(reference)
+ Z_PARAM_STR_OR_LONG(arg_name, position)
+ ZEND_PARSE_PARAMETERS_END();
object = ZEND_THIS;
intern = Z_REFLECTION_P(object);
@@ -2269,7 +2269,7 @@ ZEND_METHOD(reflection_parameter, __construct)
if (!fptr) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Function %s() does not exist", Z_STRVAL_P(reference));
- return;
+ RETURN_THROWS();
}
ce = fptr->common.scope;
}
@@ -2284,7 +2284,7 @@ ZEND_METHOD(reflection_parameter, __construct)
|| ((method = zend_hash_index_find(Z_ARRVAL_P(reference), 1)) == NULL))
{
_DO_THROW("Expected array($object, $method) or array($classname, $method)");
- return;
+ RETURN_THROWS();
}
if (Z_TYPE_P(classref) == IS_OBJECT) {
@@ -2296,9 +2296,9 @@ ZEND_METHOD(reflection_parameter, __construct)
}
if ((ce = zend_lookup_class(name)) == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Class %s does not exist", ZSTR_VAL(name));
+ "Class \"%s\" does not exist", ZSTR_VAL(name));
zend_string_release(name);
- return;
+ RETURN_THROWS();
}
zend_string_release(name);
}
@@ -2319,7 +2319,7 @@ ZEND_METHOD(reflection_parameter, __construct)
"Method %s::%s() does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(name));
zend_string_release(name);
zend_string_release(lcname);
- return;
+ RETURN_THROWS();
}
zend_string_release(name);
zend_string_release(lcname);
@@ -2330,20 +2330,20 @@ ZEND_METHOD(reflection_parameter, __construct)
ce = Z_OBJCE_P(reference);
if (instanceof_function(ce, zend_ce_closure)) {
- fptr = (zend_function *)zend_get_closure_method_def(reference);
+ fptr = (zend_function *)zend_get_closure_method_def(Z_OBJ_P(reference));
Z_ADDREF_P(reference);
is_closure = 1;
} else if ((fptr = zend_hash_find_ptr(&ce->function_table, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE))) == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Method %s::%s() does not exist", ZSTR_VAL(ce->name), ZEND_INVOKE_FUNC_NAME);
- return;
+ RETURN_THROWS();
}
}
break;
default:
- _DO_THROW("The parameter class is expected to be either a string, an array(class, method) or a callable object");
- return;
+ zend_argument_error(reflection_exception_ptr, 1, "must be a string, an array(class, method), or a callable object, %s given", zend_zval_type_name(reference));
+ RETURN_THROWS();
}
/* Now, search for the parameter */
@@ -2352,35 +2352,23 @@ ZEND_METHOD(reflection_parameter, __construct)
if (fptr->common.fn_flags & ZEND_ACC_VARIADIC) {
num_args++;
}
- if (Z_TYPE_P(parameter) == IS_LONG) {
- position= (int)Z_LVAL_P(parameter);
- if (position < 0 || (uint32_t)position >= num_args) {
- _DO_THROW("The parameter specified by its offset could not be found");
- goto failure;
- }
- } else {
+ if (arg_name != NULL) {
uint32_t i;
-
position = -1;
- if (!try_convert_to_string(parameter)) {
- goto failure;
- }
- if (fptr->type == ZEND_INTERNAL_FUNCTION &&
- !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) {
+ if (has_internal_arg_info(fptr)) {
for (i = 0; i < num_args; i++) {
if (arg_info[i].name) {
- if (strcmp(((zend_internal_arg_info*)arg_info)[i].name, Z_STRVAL_P(parameter)) == 0) {
+ if (strcmp(((zend_internal_arg_info*)arg_info)[i].name, ZSTR_VAL(arg_name)) == 0) {
position = i;
break;
}
-
}
}
} else {
for (i = 0; i < num_args; i++) {
if (arg_info[i].name) {
- if (strcmp(ZSTR_VAL(arg_info[i].name), Z_STRVAL_P(parameter)) == 0) {
+ if (zend_string_equals(arg_name, arg_info[i].name)) {
position = i;
break;
}
@@ -2391,6 +2379,15 @@ ZEND_METHOD(reflection_parameter, __construct)
_DO_THROW("The parameter specified by its name could not be found");
goto failure;
}
+ } else {
+ if (position < 0) {
+ zend_argument_value_error(2, "must be greater than or equal to 0");
+ goto failure;
+ }
+ if (position >= num_args) {
+ _DO_THROW("The parameter specified by its offset could not be found");
+ goto failure;
+ }
}
ref = (parameter_reference*) emalloc(sizeof(parameter_reference));
@@ -2407,41 +2404,34 @@ ZEND_METHOD(reflection_parameter, __construct)
}
prop_name = reflection_prop_name(object);
- if (arg_info[position].name) {
- if (fptr->type == ZEND_INTERNAL_FUNCTION &&
- !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) {
- ZVAL_STRING(prop_name, ((zend_internal_arg_info*)arg_info)[position].name);
- } else {
- ZVAL_STR_COPY(prop_name, arg_info[position].name);
- }
+ if (has_internal_arg_info(fptr)) {
+ ZVAL_STRING(prop_name, ((zend_internal_arg_info*)arg_info)[position].name);
} else {
- ZVAL_NULL(prop_name);
+ ZVAL_STR_COPY(prop_name, arg_info[position].name);
}
return;
failure:
if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
- if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
- zend_string_release_ex(fptr->common.function_name, 0);
- }
+ zend_string_release_ex(fptr->common.function_name, 0);
zend_free_trampoline(fptr);
}
if (is_closure) {
zval_ptr_dtor(reference);
}
+ RETURN_THROWS();
}
/* }}} */
-/* {{{ proto public string ReflectionParameter::__toString()
- Returns a string representation */
-ZEND_METHOD(reflection_parameter, __toString)
+/* {{{ Returns a string representation */
+ZEND_METHOD(ReflectionParameter, __toString)
{
reflection_object *intern;
parameter_reference *param;
smart_str str = {0};
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
_parameter_string(&str, param->fptr, param->arg_info, param->offset, param->required, "");
@@ -2450,26 +2440,33 @@ ZEND_METHOD(reflection_parameter, __toString)
/* }}} */
-/* {{{ proto public string ReflectionParameter::getName()
- Returns this parameters's name */
-ZEND_METHOD(reflection_parameter, getName)
+/* {{{ Returns this parameters's name */
+ZEND_METHOD(ReflectionParameter, getName)
{
+ reflection_object *intern;
+ parameter_reference *param;
+
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
+ }
+
+ GET_REFLECTION_OBJECT_PTR(param);
+ if (has_internal_arg_info(param->fptr)) {
+ RETURN_STRING(((zend_internal_arg_info *) param->arg_info)->name);
+ } else {
+ RETURN_STR_COPY(param->arg_info->name);
}
- _default_get_name(ZEND_THIS, return_value);
}
/* }}} */
-/* {{{ proto public ReflectionFunction ReflectionParameter::getDeclaringFunction()
- Returns the ReflectionFunction for the function of this parameter */
-ZEND_METHOD(reflection_parameter, getDeclaringFunction)
+/* {{{ Returns the ReflectionFunction for the function of this parameter */
+ZEND_METHOD(ReflectionParameter, getDeclaringFunction)
{
reflection_object *intern;
parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
@@ -2481,15 +2478,14 @@ ZEND_METHOD(reflection_parameter, getDeclaringFunction)
}
/* }}} */
-/* {{{ proto public ReflectionClass|NULL ReflectionParameter::getDeclaringClass()
- Returns in which class this parameter is defined (not the type of the parameter) */
-ZEND_METHOD(reflection_parameter, getDeclaringClass)
+/* {{{ Returns in which class this parameter is defined (not the type of the parameter) */
+ZEND_METHOD(ReflectionParameter, getDeclaringClass)
{
reflection_object *intern;
parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
@@ -2499,20 +2495,20 @@ ZEND_METHOD(reflection_parameter, getDeclaringClass)
}
/* }}} */
-/* {{{ proto public ReflectionClass|NULL ReflectionParameter::getClass()
- Returns this parameters's class hint or NULL if there is none */
-ZEND_METHOD(reflection_parameter, getClass)
+/* {{{ Returns this parameters's class hint or NULL if there is none */
+ZEND_METHOD(ReflectionParameter, getClass)
{
reflection_object *intern;
parameter_reference *param;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
- if (ZEND_TYPE_IS_CLASS(param->arg_info->type)) {
+ // TODO: This is going to return null for union types, which is rather odd.
+ if (ZEND_TYPE_HAS_NAME(param->arg_info->type)) {
/* Class name is stored as a string, we might also get "self" or "parent"
* - For "self", simply use the function scope. If scope is NULL then
* the function is global and thus self does not make any sense
@@ -2532,28 +2528,28 @@ ZEND_METHOD(reflection_parameter, getClass)
ce = param->fptr->common.scope;
if (!ce) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Parameter uses 'self' as type hint but function is not a class member!");
- return;
+ "Parameter uses \"self\" as type but function is not a class member");
+ RETURN_THROWS();
}
} else if (0 == zend_binary_strcasecmp(ZSTR_VAL(class_name), ZSTR_LEN(class_name), "parent", sizeof("parent")- 1)) {
ce = param->fptr->common.scope;
if (!ce) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Parameter uses 'parent' as type hint but function is not a class member!");
- return;
+ "Parameter uses \"parent\" as type but function is not a class member");
+ RETURN_THROWS();
}
if (!ce->parent) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Parameter uses 'parent' as type hint although class does not have a parent!");
- return;
+ "Parameter uses \"parent\" as type although class does not have a parent");
+ RETURN_THROWS();
}
ce = ce->parent;
} else {
ce = zend_lookup_class(class_name);
if (!ce) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Class %s does not exist", ZSTR_VAL(class_name));
- return;
+ "Class \"%s\" does not exist", ZSTR_VAL(class_name));
+ RETURN_THROWS();
}
}
zend_reflection_class_factory(ce, return_value);
@@ -2561,15 +2557,14 @@ ZEND_METHOD(reflection_parameter, getClass)
}
/* }}} */
-/* {{{ proto public bool ReflectionParameter::hasType()
- Returns whether parameter has a type */
-ZEND_METHOD(reflection_parameter, hasType)
+/* {{{ Returns whether parameter has a type */
+ZEND_METHOD(ReflectionParameter, hasType)
{
reflection_object *intern;
parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
@@ -2577,115 +2572,129 @@ ZEND_METHOD(reflection_parameter, hasType)
}
/* }}} */
-/* {{{ proto public ReflectionType ReflectionParameter::getType()
- Returns the type associated with the parameter */
-ZEND_METHOD(reflection_parameter, getType)
+/* {{{ Returns the type associated with the parameter */
+ZEND_METHOD(ReflectionParameter, getType)
{
reflection_object *intern;
parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
if (!ZEND_TYPE_IS_SET(param->arg_info->type)) {
RETURN_NULL();
}
- reflection_type_factory(param->arg_info->type, return_value);
+ reflection_type_factory(param->arg_info->type, return_value, 1);
}
/* }}} */
-/* {{{ proto public bool ReflectionParameter::isArray()
- Returns whether parameter MUST be an array */
-ZEND_METHOD(reflection_parameter, isArray)
+/* {{{ Returns whether parameter MUST be an array */
+ZEND_METHOD(ReflectionParameter, isArray)
{
reflection_object *intern;
parameter_reference *param;
+ uint32_t type_mask;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
- RETVAL_BOOL(ZEND_TYPE_CODE(param->arg_info->type) == IS_ARRAY);
+ type_mask = ZEND_TYPE_PURE_MASK_WITHOUT_NULL(param->arg_info->type);
+ RETVAL_BOOL(type_mask == MAY_BE_ARRAY);
}
/* }}} */
-/* {{{ proto public bool ReflectionParameter::isCallable()
- Returns whether parameter MUST be callable */
-ZEND_METHOD(reflection_parameter, isCallable)
+/* {{{ Returns whether parameter MUST be callable */
+ZEND_METHOD(ReflectionParameter, isCallable)
{
reflection_object *intern;
parameter_reference *param;
+ uint32_t type_mask;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
- RETVAL_BOOL(ZEND_TYPE_CODE(param->arg_info->type) == IS_CALLABLE);
+ type_mask = ZEND_TYPE_PURE_MASK_WITHOUT_NULL(param->arg_info->type);
+ RETVAL_BOOL(type_mask == MAY_BE_CALLABLE);
}
/* }}} */
-/* {{{ proto public bool ReflectionParameter::allowsNull()
- Returns whether NULL is allowed as this parameters's value */
-ZEND_METHOD(reflection_parameter, allowsNull)
+/* {{{ Returns whether NULL is allowed as this parameters's value */
+ZEND_METHOD(ReflectionParameter, allowsNull)
{
reflection_object *intern;
parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
- RETVAL_BOOL(ZEND_TYPE_ALLOW_NULL(param->arg_info->type));
+ RETVAL_BOOL(!ZEND_TYPE_IS_SET(param->arg_info->type)
+ || ZEND_TYPE_ALLOW_NULL(param->arg_info->type));
}
/* }}} */
-/* {{{ proto public bool ReflectionParameter::isPassedByReference()
- Returns whether this parameters is passed to by reference */
-ZEND_METHOD(reflection_parameter, isPassedByReference)
+/* {{{ Returns whether this parameters is passed to by reference */
+ZEND_METHOD(ReflectionParameter, isPassedByReference)
{
reflection_object *intern;
parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
- RETVAL_BOOL(param->arg_info->pass_by_reference);
+ RETVAL_BOOL(ZEND_ARG_SEND_MODE(param->arg_info));
}
/* }}} */
-/* {{{ proto public bool ReflectionParameter::canBePassedByValue()
- Returns whether this parameter can be passed by value */
-ZEND_METHOD(reflection_parameter, canBePassedByValue)
+/* {{{ Returns whether this parameter can be passed by value */
+ZEND_METHOD(ReflectionParameter, canBePassedByValue)
{
reflection_object *intern;
parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
/* true if it's ZEND_SEND_BY_VAL or ZEND_SEND_PREFER_REF */
- RETVAL_BOOL(param->arg_info->pass_by_reference != ZEND_SEND_BY_REF);
+ RETVAL_BOOL(ZEND_ARG_SEND_MODE(param->arg_info) != ZEND_SEND_BY_REF);
}
/* }}} */
-/* {{{ proto public bool ReflectionParameter::getPosition()
- Returns whether this parameter is an optional parameter */
-ZEND_METHOD(reflection_parameter, getPosition)
+/* {{{ Get parameter attributes. */
+ZEND_METHOD(ReflectionParameter, getAttributes)
+{
+ reflection_object *intern;
+ parameter_reference *param;
+
+ GET_REFLECTION_OBJECT_PTR(param);
+
+ HashTable *attributes = param->fptr->common.attributes;
+ zend_class_entry *scope = param->fptr->common.scope;
+
+ reflect_attributes(INTERNAL_FUNCTION_PARAM_PASSTHRU,
+ attributes, param->offset + 1, scope, ZEND_ATTRIBUTE_TARGET_PARAMETER,
+ param->fptr->type == ZEND_USER_FUNCTION ? param->fptr->op_array.filename : NULL);
+}
+
+/* {{{ Returns whether this parameter is an optional parameter */
+ZEND_METHOD(ReflectionParameter, getPosition)
{
reflection_object *intern;
parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
@@ -2693,15 +2702,14 @@ ZEND_METHOD(reflection_parameter, getPosition)
}
/* }}} */
-/* {{{ proto public bool ReflectionParameter::isOptional()
- Returns whether this parameter is an optional parameter */
-ZEND_METHOD(reflection_parameter, isOptional)
+/* {{{ Returns whether this parameter is an optional parameter */
+ZEND_METHOD(ReflectionParameter, isOptional)
{
reflection_object *intern;
parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
@@ -2709,302 +2717,371 @@ ZEND_METHOD(reflection_parameter, isOptional)
}
/* }}} */
-/* {{{ proto public bool ReflectionParameter::isDefaultValueAvailable()
- Returns whether the default value of this parameter is available */
-ZEND_METHOD(reflection_parameter, isDefaultValueAvailable)
+/* {{{ Returns whether the default value of this parameter is available */
+ZEND_METHOD(ReflectionParameter, isDefaultValueAvailable)
{
reflection_object *intern;
parameter_reference *param;
- zend_op *precv;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
- GET_REFLECTION_OBJECT_PTR(param);
- if (param->fptr->type != ZEND_USER_FUNCTION)
- {
- RETURN_FALSE;
- }
+ GET_REFLECTION_OBJECT_PTR(param);
- precv = _get_recv_op((zend_op_array*)param->fptr, param->offset);
- if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) {
- RETURN_FALSE;
+ if (param->fptr->type == ZEND_INTERNAL_FUNCTION) {
+ RETURN_BOOL(!(param->fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)
+ && ((zend_internal_arg_info*) (param->arg_info))->default_value);
+ } else {
+ zval *default_value = get_default_from_recv((zend_op_array *)param->fptr, param->offset);
+ RETURN_BOOL(default_value != NULL);
}
- RETURN_TRUE;
}
/* }}} */
-/* {{{ proto public bool ReflectionParameter::getDefaultValue()
- Returns the default value of this parameter or throws an exception */
-ZEND_METHOD(reflection_parameter, getDefaultValue)
+/* {{{ Returns the default value of this parameter or throws an exception */
+ZEND_METHOD(ReflectionParameter, getDefaultValue)
{
+ reflection_object *intern;
parameter_reference *param;
- zend_op *precv;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
- param = _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- if (!param) {
- return;
- }
+ GET_REFLECTION_OBJECT_PTR(param);
- precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param);
- if (!precv) {
- return;
+ if (get_parameter_default(return_value, param) == FAILURE) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0,
+ "Internal error: Failed to retrieve the default value");
+ RETURN_THROWS();
}
- ZVAL_COPY(return_value, RT_CONSTANT(precv, precv->op2));
if (Z_TYPE_P(return_value) == IS_CONSTANT_AST) {
zval_update_constant_ex(return_value, param->fptr->common.scope);
}
}
/* }}} */
-/* {{{ proto public bool ReflectionParameter::isDefaultValueConstant()
- Returns whether the default value of this parameter is constant */
-ZEND_METHOD(reflection_parameter, isDefaultValueConstant)
+/* {{{ Returns whether the default value of this parameter is constant */
+ZEND_METHOD(ReflectionParameter, isDefaultValueConstant)
{
- zend_op *precv;
+ reflection_object *intern;
parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
- param = _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- if (!param) {
- RETURN_FALSE;
- }
+ GET_REFLECTION_OBJECT_PTR(param);
- precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param);
- if (precv && Z_TYPE_P(RT_CONSTANT(precv, precv->op2)) == IS_CONSTANT_AST) {
- zend_ast *ast = Z_ASTVAL_P(RT_CONSTANT(precv, precv->op2));
+ zval default_value;
+ if (get_parameter_default(&default_value, param) == FAILURE) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0,
+ "Internal error: Failed to retrieve the default value");
+ RETURN_THROWS();
+ }
- if (ast->kind == ZEND_AST_CONSTANT
- || ast->kind == ZEND_AST_CONSTANT_CLASS) {
- RETURN_TRUE;
- }
+ if (Z_TYPE(default_value) == IS_CONSTANT_AST) {
+ zend_ast *ast = Z_ASTVAL(default_value);
+ RETVAL_BOOL(ast->kind == ZEND_AST_CONSTANT || ast->kind == ZEND_AST_CONSTANT_CLASS);
+ } else {
+ RETVAL_FALSE;
}
- RETURN_FALSE;
+ zval_ptr_dtor_nogc(&default_value);
}
/* }}} */
-/* {{{ proto public mixed ReflectionParameter::getDefaultValueConstantName()
- Returns the default value's constant name if default value is constant or null */
-ZEND_METHOD(reflection_parameter, getDefaultValueConstantName)
+/* {{{ Returns the default value's constant name if default value is constant or null */
+ZEND_METHOD(ReflectionParameter, getDefaultValueConstantName)
{
- zend_op *precv;
+ reflection_object *intern;
parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
- param = _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- if (!param) {
- return;
+ GET_REFLECTION_OBJECT_PTR(param);
+
+ zval default_value;
+ if (get_parameter_default(&default_value, param) == FAILURE) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0,
+ "Internal error: Failed to retrieve the default value");
+ RETURN_THROWS();
}
- precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param);
- if (precv && Z_TYPE_P(RT_CONSTANT(precv, precv->op2)) == IS_CONSTANT_AST) {
- zend_ast *ast = Z_ASTVAL_P(RT_CONSTANT(precv, precv->op2));
+ if (Z_TYPE(default_value) != IS_CONSTANT_AST) {
+ zval_ptr_dtor_nogc(&default_value);
+ RETURN_NULL();
+ }
- if (ast->kind == ZEND_AST_CONSTANT) {
- RETURN_STR_COPY(zend_ast_get_constant_name(ast));
- } else if (ast->kind == ZEND_AST_CONSTANT_CLASS) {
- RETURN_STRINGL("__CLASS__", sizeof("__CLASS__")-1);
- }
+ zend_ast *ast = Z_ASTVAL(default_value);
+ if (ast->kind == ZEND_AST_CONSTANT) {
+ RETVAL_STR_COPY(zend_ast_get_constant_name(ast));
+ } else if (ast->kind == ZEND_AST_CONSTANT_CLASS) {
+ RETVAL_STRINGL("__CLASS__", sizeof("__CLASS__")-1);
+ } else {
+ RETVAL_NULL();
}
+ zval_ptr_dtor_nogc(&default_value);
}
-/* }}} */
-/* {{{ proto public bool ReflectionParameter::isVariadic()
- Returns whether this parameter is a variadic parameter */
-ZEND_METHOD(reflection_parameter, isVariadic)
+/* {{{ Returns whether this parameter is a variadic parameter */
+ZEND_METHOD(ReflectionParameter, isVariadic)
{
reflection_object *intern;
parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
- RETVAL_BOOL(param->arg_info->is_variadic);
+ RETVAL_BOOL(ZEND_ARG_IS_VARIADIC(param->arg_info));
}
/* }}} */
-/* {{{ proto public bool ReflectionType::allowsNull()
- Returns whether parameter MAY be null */
-ZEND_METHOD(reflection_type, allowsNull)
+/* {{{ Returns this constructor parameter has been promoted to a property */
+ZEND_METHOD(ReflectionParameter, isPromoted)
{
reflection_object *intern;
- type_reference *param;
+ parameter_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
- RETVAL_BOOL(ZEND_TYPE_ALLOW_NULL(param->type));
+ RETVAL_BOOL(ZEND_ARG_IS_PROMOTED(param->arg_info));
}
/* }}} */
-/* {{{ proto public bool ReflectionType::isBuiltin()
- Returns whether parameter is a builtin type */
-ZEND_METHOD(reflection_type, isBuiltin)
+/* {{{ Returns whether parameter MAY be null */
+ZEND_METHOD(ReflectionType, allowsNull)
{
reflection_object *intern;
type_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
- RETVAL_BOOL(ZEND_TYPE_IS_CODE(param->type));
+ RETVAL_BOOL(ZEND_TYPE_ALLOW_NULL(param->type));
}
/* }}} */
-/* {{{ reflection_type_name */
-static zend_string *reflection_type_name(type_reference *param) {
- if (ZEND_TYPE_IS_NAME(param->type)) {
- return zend_string_copy(ZEND_TYPE_NAME(param->type));
- } else if (ZEND_TYPE_IS_CE(param->type)) {
- return zend_string_copy(ZEND_TYPE_CE(param->type)->name);
- } else {
- char *name = zend_get_type_by_const(ZEND_TYPE_CODE(param->type));
- return zend_string_init(name, strlen(name), 0);
+static zend_string *zend_type_to_string_without_null(zend_type type) {
+ ZEND_TYPE_FULL_MASK(type) &= ~MAY_BE_NULL;
+ return zend_type_to_string(type);
+}
+
+/* {{{ Return the text of the type hint */
+ZEND_METHOD(ReflectionType, __toString)
+{
+ reflection_object *intern;
+ type_reference *param;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
}
+ GET_REFLECTION_OBJECT_PTR(param);
+
+ RETURN_STR(zend_type_to_string(param->type));
}
/* }}} */
-/* {{{ proto public string ReflectionType::__toString()
- Return the text of the type hint */
-ZEND_METHOD(reflection_type, __toString)
+/* {{{ Return the name of the type */
+ZEND_METHOD(ReflectionNamedType, getName)
{
reflection_object *intern;
type_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
- RETURN_STR(reflection_type_name(param));
+ if (param->legacy_behavior) {
+ RETURN_STR(zend_type_to_string_without_null(param->type));
+ }
+ RETURN_STR(zend_type_to_string(param->type));
}
/* }}} */
-/* {{{ proto public string ReflectionNamedType::getName()
- Return the text of the type hint */
-ZEND_METHOD(reflection_named_type, getName)
+/* {{{ Returns whether type is a builtin type */
+ZEND_METHOD(ReflectionNamedType, isBuiltin)
{
reflection_object *intern;
type_reference *param;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(param);
- RETURN_STR(reflection_type_name(param));
+ /* Treat "static" as a class type for the purposes of reflection. */
+ RETVAL_BOOL(ZEND_TYPE_IS_ONLY_MASK(param->type)
+ && !(ZEND_TYPE_FULL_MASK(param->type) & MAY_BE_STATIC));
}
/* }}} */
-/* {{{ proto public static mixed ReflectionMethod::export(mixed class, string name [, bool return]) throws ReflectionException
- Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
-ZEND_METHOD(reflection_method, export)
+static void append_type(zval *return_value, zend_type type) {
+ zval reflection_type;
+ reflection_type_factory(type, &reflection_type, 0);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &reflection_type);
+}
+
+static void append_type_mask(zval *return_value, uint32_t type_mask) {
+ append_type(return_value, (zend_type) ZEND_TYPE_INIT_MASK(type_mask));
+}
+
+/* {{{ Returns the types that are part of this union type */
+ZEND_METHOD(ReflectionUnionType, getTypes)
{
- _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_method_ptr, 2);
+ reflection_object *intern;
+ type_reference *param;
+ uint32_t type_mask;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+ GET_REFLECTION_OBJECT_PTR(param);
+
+ array_init(return_value);
+ if (ZEND_TYPE_HAS_LIST(param->type)) {
+ zend_type *list_type;
+ ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(param->type), list_type) {
+ append_type(return_value, *list_type);
+ } ZEND_TYPE_LIST_FOREACH_END();
+ } else if (ZEND_TYPE_HAS_NAME(param->type)) {
+ append_type(return_value,
+ (zend_type) ZEND_TYPE_INIT_CLASS(ZEND_TYPE_NAME(param->type), 0, 0));
+ } else if (ZEND_TYPE_HAS_CE(param->type)) {
+ append_type(return_value,
+ (zend_type) ZEND_TYPE_INIT_CE(ZEND_TYPE_CE(param->type), 0, 0));
+ }
+
+ type_mask = ZEND_TYPE_PURE_MASK(param->type);
+ ZEND_ASSERT(!(type_mask & MAY_BE_VOID));
+ if (type_mask & MAY_BE_STATIC) {
+ append_type_mask(return_value, MAY_BE_STATIC);
+ }
+ if (type_mask & MAY_BE_CALLABLE) {
+ append_type_mask(return_value, MAY_BE_CALLABLE);
+ }
+ if (type_mask & MAY_BE_ITERABLE) {
+ append_type_mask(return_value, MAY_BE_ITERABLE);
+ }
+ if (type_mask & MAY_BE_OBJECT) {
+ append_type_mask(return_value, MAY_BE_OBJECT);
+ }
+ if (type_mask & MAY_BE_ARRAY) {
+ append_type_mask(return_value, MAY_BE_ARRAY);
+ }
+ if (type_mask & MAY_BE_STRING) {
+ append_type_mask(return_value, MAY_BE_STRING);
+ }
+ if (type_mask & MAY_BE_LONG) {
+ append_type_mask(return_value, MAY_BE_LONG);
+ }
+ if (type_mask & MAY_BE_DOUBLE) {
+ append_type_mask(return_value, MAY_BE_DOUBLE);
+ }
+ if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL) {
+ append_type_mask(return_value, MAY_BE_BOOL);
+ } else if (type_mask & MAY_BE_FALSE) {
+ append_type_mask(return_value, MAY_BE_FALSE);
+ }
+ if (type_mask & MAY_BE_NULL) {
+ append_type_mask(return_value, MAY_BE_NULL);
+ }
}
/* }}} */
-/* {{{ proto public void ReflectionMethod::__construct(mixed class_or_method [, string name])
- Constructor. Throws an Exception in case the given method does not exist */
-ZEND_METHOD(reflection_method, __construct)
+/* {{{ Constructor. Throws an Exception in case the given method does not exist */
+ZEND_METHOD(ReflectionMethod, __construct)
{
- zval *classname;
- zval *object, *orig_obj;
- reflection_object *intern;
+ zend_object *arg1_obj;
+ zend_string *arg1_str;
+ zend_string *arg2_str = NULL;
+
+ zend_object *orig_obj = NULL;
+ zend_class_entry *ce = NULL;
+ zend_string *class_name = NULL;
+ char *method_name;
+ size_t method_name_len;
char *lcname;
- zend_class_entry *ce;
+
+ zval *object;
+ reflection_object *intern;
zend_function *mptr;
- char *name_str, *tmp;
- size_t name_len, tmp_len;
- zval ztmp;
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "zs", &classname, &name_str, &name_len) == FAILURE) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_OBJ_OR_STR(arg1_obj, arg1_str)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STR_OR_NULL(arg2_str)
+ ZEND_PARSE_PARAMETERS_END();
- if ((tmp = strstr(name_str, "::")) == NULL) {
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Invalid method name %s", name_str);
- return;
+ if (arg1_obj) {
+ if (!arg2_str) {
+ zend_argument_value_error(2, "cannot be null when argument #1 ($objectOrMethod) is an object");
+ RETURN_THROWS();
}
- classname = &ztmp;
- tmp_len = tmp - name_str;
- ZVAL_STRINGL(classname, name_str, tmp_len);
- name_len = name_len - (tmp_len + 2);
- name_str = tmp + 2;
- orig_obj = NULL;
- } else if (Z_TYPE_P(classname) == IS_OBJECT) {
- orig_obj = classname;
- } else {
- orig_obj = NULL;
- }
- object = ZEND_THIS;
- intern = Z_REFLECTION_P(object);
+ orig_obj = arg1_obj;
+ ce = arg1_obj->ce;
+ method_name = ZSTR_VAL(arg2_str);
+ method_name_len = ZSTR_LEN(arg2_str);
+ } else if (arg2_str) {
+ class_name = zend_string_copy(arg1_str);
+ method_name = ZSTR_VAL(arg2_str);
+ method_name_len = ZSTR_LEN(arg2_str);
+ } else {
+ char *tmp;
+ size_t tmp_len;
+ char *name = ZSTR_VAL(arg1_str);
- /* Find the class entry */
- switch (Z_TYPE_P(classname)) {
- case IS_STRING:
- if ((ce = zend_lookup_class(Z_STR_P(classname))) == NULL) {
- if (!EG(exception)) {
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Class %s does not exist", Z_STRVAL_P(classname));
- }
- if (classname == &ztmp) {
- zval_ptr_dtor_str(&ztmp);
- }
- return;
- }
- break;
+ if ((tmp = strstr(name, "::")) == NULL) {
+ zend_argument_error(reflection_exception_ptr, 1, "must be a valid method name");
+ RETURN_THROWS();
+ }
+ tmp_len = tmp - name;
- case IS_OBJECT:
- ce = Z_OBJCE_P(classname);
- break;
+ class_name = zend_string_init(name, tmp_len, 0);
+ method_name = tmp + 2;
+ method_name_len = ZSTR_LEN(arg1_str) - tmp_len - 2;
+ }
- default:
- if (classname == &ztmp) {
- zval_ptr_dtor_str(&ztmp);
+ if (class_name) {
+ if ((ce = zend_lookup_class(class_name)) == NULL) {
+ if (!EG(exception)) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0, "Class \"%s\" does not exist", ZSTR_VAL(class_name));
}
- _DO_THROW("The parameter class is expected to be either a string or an object");
- return;
- }
+ zend_string_release(class_name);
+ RETURN_THROWS();
+ }
- if (classname == &ztmp) {
- zval_ptr_dtor_str(&ztmp);
+ zend_string_release(class_name);
}
- lcname = zend_str_tolower_dup(name_str, name_len);
+ object = ZEND_THIS;
+ intern = Z_REFLECTION_P(object);
+
+ lcname = zend_str_tolower_dup(method_name, method_name_len);
- if (ce == zend_ce_closure && orig_obj && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
+ if (ce == zend_ce_closure && orig_obj && (method_name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
&& memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
- && (mptr = zend_get_closure_invoke_method(Z_OBJ_P(orig_obj))) != NULL)
+ && (mptr = zend_get_closure_invoke_method(orig_obj)) != NULL)
{
/* do nothing, mptr already set */
- } else if ((mptr = zend_hash_str_find_ptr(&ce->function_table, lcname, name_len)) == NULL) {
+ } else if ((mptr = zend_hash_str_find_ptr(&ce->function_table, lcname, method_name_len)) == NULL) {
efree(lcname);
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Method %s::%s() does not exist", ZSTR_VAL(ce->name), name_str);
- return;
+ "Method %s::%s() does not exist", ZSTR_VAL(ce->name), method_name);
+ RETURN_THROWS();
}
efree(lcname);
@@ -3016,16 +3093,15 @@ ZEND_METHOD(reflection_method, __construct)
}
/* }}} */
-/* {{{ proto public string ReflectionMethod::__toString()
- Returns a string representation */
-ZEND_METHOD(reflection_method, __toString)
+/* {{{ Returns a string representation */
+ZEND_METHOD(ReflectionMethod, __toString)
{
reflection_object *intern;
zend_function *mptr;
smart_str str = {0};
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(mptr);
_function_string(&str, mptr, intern->ce, "");
@@ -3033,34 +3109,37 @@ ZEND_METHOD(reflection_method, __toString)
}
/* }}} */
-/* {{{ proto public mixed ReflectionMethod::getClosure([mixed object])
- Invokes the function */
-ZEND_METHOD(reflection_method, getClosure)
+/* {{{ Invokes the function */
+ZEND_METHOD(ReflectionMethod, getClosure)
{
reflection_object *intern;
- zval *obj;
+ zval *obj = NULL;
zend_function *mptr;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|o!", &obj) == FAILURE) {
+ RETURN_THROWS();
+ }
+
GET_REFLECTION_OBJECT_PTR(mptr);
if (mptr->common.fn_flags & ZEND_ACC_STATIC) {
zend_create_fake_closure(return_value, mptr, mptr->common.scope, mptr->common.scope, NULL);
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &obj) == FAILURE) {
- return;
+ if (!obj) {
+ zend_argument_value_error(1, "cannot be null for non-static methods");
+ RETURN_THROWS();
}
if (!instanceof_function(Z_OBJCE_P(obj), mptr->common.scope)) {
_DO_THROW("Given object is not an instance of the class this method was declared in");
- return;
+ RETURN_THROWS();
}
/* This is an original closure object and __invoke is to be called. */
if (Z_OBJCE_P(obj) == zend_ce_closure &&
(mptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE))
{
- Z_ADDREF_P(obj);
- ZVAL_OBJ(return_value, Z_OBJ_P(obj));
+ RETURN_OBJ_COPY(Z_OBJ_P(obj));
} else {
zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_OBJCE_P(obj), obj);
}
@@ -3072,14 +3151,14 @@ ZEND_METHOD(reflection_method, getClosure)
static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
{
zval retval;
- zval *params = NULL, *val, *object;
+ zval *params = NULL, *object;
+ HashTable *named_params = NULL;
reflection_object *intern;
zend_function *mptr;
- int i, argc = 0, result;
+ int argc = 0, result;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
zend_class_entry *obj_ce;
- zval *param_array;
GET_REFLECTION_OBJECT_PTR(mptr);
@@ -3087,7 +3166,7 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Trying to invoke abstract method %s::%s()",
ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name));
- return;
+ RETURN_THROWS();
}
if (!(mptr->common.fn_flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
@@ -3096,26 +3175,18 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private",
ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name),
ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name));
- return;
+ RETURN_THROWS();
}
if (variadic) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "o!*", &object, &params, &argc) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, -1)
+ Z_PARAM_OBJECT_OR_NULL(object)
+ Z_PARAM_VARIADIC_WITH_NAMED(params, argc, named_params)
+ ZEND_PARSE_PARAMETERS_END();
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "o!a", &object, &param_array) == FAILURE) {
- return;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "o!h", &object, &named_params) == FAILURE) {
+ RETURN_THROWS();
}
-
- argc = zend_hash_num_elements(Z_ARRVAL_P(param_array));
-
- params = safe_emalloc(sizeof(zval), argc, 0);
- argc = 0;
- ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(param_array), val) {
- ZVAL_COPY(&params[argc], val);
- argc++;
- } ZEND_HASH_FOREACH_END();
}
/* In case this is a static method, we shouldn't pass an object_ptr
@@ -3132,7 +3203,7 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Trying to invoke non static method %s::%s() without an object",
ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name));
- return;
+ RETURN_THROWS();
}
obj_ce = Z_OBJCE_P(object);
@@ -3142,7 +3213,7 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
efree(params);
}
_DO_THROW("Given object is not an instance of the class this method was declared in");
- return;
+ RETURN_THROWS();
}
}
@@ -3152,7 +3223,7 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
fci.retval = &retval;
fci.param_count = argc;
fci.params = params;
- fci.no_separation = 1;
+ fci.named_params = named_params;
fcc.function_handler = mptr;
fcc.called_scope = intern->ce;
@@ -3167,17 +3238,10 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
result = zend_call_function(&fci, &fcc);
- if (!variadic) {
- for (i = 0; i < argc; i++) {
- zval_ptr_dtor(&params[i]);
- }
- efree(params);
- }
-
if (result == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Invocation of method %s::%s() failed", ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name));
- return;
+ RETURN_THROWS();
}
if (Z_TYPE(retval) != IS_UNDEF) {
@@ -3189,172 +3253,151 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
}
/* }}} */
-/* {{{ proto public mixed ReflectionMethod::invoke(mixed object, mixed* args)
- Invokes the method. */
-ZEND_METHOD(reflection_method, invoke)
+/* {{{ Invokes the method. */
+ZEND_METHOD(ReflectionMethod, invoke)
{
reflection_method_invoke(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
/* }}} */
-/* {{{ proto public mixed ReflectionMethod::invokeArgs(mixed object, array args)
- Invokes the function and pass its arguments as array. */
-ZEND_METHOD(reflection_method, invokeArgs)
+/* {{{ Invokes the function and pass its arguments as array. */
+ZEND_METHOD(ReflectionMethod, invokeArgs)
{
reflection_method_invoke(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
-/* {{{ proto public bool ReflectionMethod::isFinal()
- Returns whether this method is final */
-ZEND_METHOD(reflection_method, isFinal)
+/* {{{ Returns whether this method is final */
+ZEND_METHOD(ReflectionMethod, isFinal)
{
_function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_FINAL);
}
/* }}} */
-/* {{{ proto public bool ReflectionMethod::isAbstract()
- Returns whether this method is abstract */
-ZEND_METHOD(reflection_method, isAbstract)
+/* {{{ Returns whether this method is abstract */
+ZEND_METHOD(ReflectionMethod, isAbstract)
{
_function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_ABSTRACT);
}
/* }}} */
-/* {{{ proto public bool ReflectionMethod::isPublic()
- Returns whether this method is public */
-ZEND_METHOD(reflection_method, isPublic)
+/* {{{ Returns whether this method is public */
+ZEND_METHOD(ReflectionMethod, isPublic)
{
_function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC);
}
/* }}} */
-/* {{{ proto public bool ReflectionMethod::isPrivate()
- Returns whether this method is private */
-ZEND_METHOD(reflection_method, isPrivate)
+/* {{{ Returns whether this method is private */
+ZEND_METHOD(ReflectionMethod, isPrivate)
{
_function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PRIVATE);
}
/* }}} */
-/* {{{ proto public bool ReflectionMethod::isProtected()
- Returns whether this method is protected */
-ZEND_METHOD(reflection_method, isProtected)
+/* {{{ Returns whether this method is protected */
+ZEND_METHOD(ReflectionMethod, isProtected)
{
_function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PROTECTED);
}
/* }}} */
-/* {{{ proto public bool ReflectionMethod::isStatic()
- Returns whether this method is static */
-ZEND_METHOD(reflection_method, isStatic)
+/* {{{ Returns whether this method is static */
+ZEND_METHOD(ReflectionMethod, isStatic)
{
_function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_STATIC);
}
/* }}} */
-/* {{{ proto public bool ReflectionFunction::isDeprecated()
- Returns whether this function is deprecated */
-ZEND_METHOD(reflection_function, isDeprecated)
+/* {{{ Returns whether this function is deprecated */
+ZEND_METHOD(ReflectionFunctionAbstract, isDeprecated)
{
_function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_DEPRECATED);
}
/* }}} */
-/* {{{ proto public bool ReflectionFunction::isGenerator()
- Returns whether this function is a generator */
-ZEND_METHOD(reflection_function, isGenerator)
+/* {{{ Returns whether this function is a generator */
+ZEND_METHOD(ReflectionFunctionAbstract, isGenerator)
{
_function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_GENERATOR);
}
/* }}} */
-/* {{{ proto public bool ReflectionFunction::isVariadic()
- Returns whether this function is variadic */
-ZEND_METHOD(reflection_function, isVariadic)
+/* {{{ Returns whether this function is variadic */
+ZEND_METHOD(ReflectionFunctionAbstract, isVariadic)
{
_function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_VARIADIC);
}
/* }}} */
-/* {{{ proto public bool ReflectionFunction::inNamespace()
- Returns whether this function is defined in namespace */
-ZEND_METHOD(reflection_function, inNamespace)
+/* {{{ Returns whether this function is defined in namespace */
+ZEND_METHOD(ReflectionFunctionAbstract, inNamespace)
{
- zval *name;
- const char *backslash;
+ reflection_object *intern;
+ zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
- if ((name = _default_load_name(ZEND_THIS)) == NULL) {
- RETURN_FALSE;
+ RETURN_THROWS();
}
- if (Z_TYPE_P(name) == IS_STRING
- && (backslash = zend_memrchr(Z_STRVAL_P(name), '\\', Z_STRLEN_P(name)))
- && backslash > Z_STRVAL_P(name))
- {
- RETURN_TRUE;
- }
- RETURN_FALSE;
+
+ GET_REFLECTION_OBJECT_PTR(fptr);
+
+ zend_string *name = fptr->common.function_name;
+ const char *backslash = zend_memrchr(ZSTR_VAL(name), '\\', ZSTR_LEN(name));
+ RETURN_BOOL(backslash && backslash > ZSTR_VAL(name));
}
/* }}} */
-/* {{{ proto public string ReflectionFunction::getNamespaceName()
- Returns the name of namespace where this function is defined */
-ZEND_METHOD(reflection_function, getNamespaceName)
+/* {{{ Returns the name of namespace where this function is defined */
+ZEND_METHOD(ReflectionFunctionAbstract, getNamespaceName)
{
- zval *name;
- const char *backslash;
+ reflection_object *intern;
+ zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
- if ((name = _default_load_name(ZEND_THIS)) == NULL) {
- RETURN_FALSE;
+ RETURN_THROWS();
}
- if (Z_TYPE_P(name) == IS_STRING
- && (backslash = zend_memrchr(Z_STRVAL_P(name), '\\', Z_STRLEN_P(name)))
- && backslash > Z_STRVAL_P(name))
- {
- RETURN_STRINGL(Z_STRVAL_P(name), backslash - Z_STRVAL_P(name));
+
+ GET_REFLECTION_OBJECT_PTR(fptr);
+
+ zend_string *name = fptr->common.function_name;
+ const char *backslash = zend_memrchr(ZSTR_VAL(name), '\\', ZSTR_LEN(name));
+ if (backslash && backslash > ZSTR_VAL(name)) {
+ RETURN_STRINGL(ZSTR_VAL(name), backslash - ZSTR_VAL(name));
}
RETURN_EMPTY_STRING();
}
/* }}} */
-/* {{{ proto public string ReflectionFunction::getShortName()
- Returns the short name of the function (without namespace part) */
-ZEND_METHOD(reflection_function, getShortName)
+/* {{{ Returns the short name of the function (without namespace part) */
+ZEND_METHOD(ReflectionFunctionAbstract, getShortName)
{
- zval *name;
- const char *backslash;
+ reflection_object *intern;
+ zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
- if ((name = _default_load_name(ZEND_THIS)) == NULL) {
- RETURN_FALSE;
- }
- if (Z_TYPE_P(name) == IS_STRING
- && (backslash = zend_memrchr(Z_STRVAL_P(name), '\\', Z_STRLEN_P(name)))
- && backslash > Z_STRVAL_P(name))
- {
- RETURN_STRINGL(backslash + 1, Z_STRLEN_P(name) - (backslash - Z_STRVAL_P(name) + 1));
+
+ GET_REFLECTION_OBJECT_PTR(fptr);
+
+ zend_string *name = fptr->common.function_name;
+ const char *backslash = zend_memrchr(ZSTR_VAL(name), '\\', ZSTR_LEN(name));
+ if (backslash && backslash > ZSTR_VAL(name)) {
+ RETURN_STRINGL(backslash + 1, ZSTR_LEN(name) - (backslash - ZSTR_VAL(name) + 1));
}
- ZVAL_COPY_DEREF(return_value, name);
+ RETURN_STR_COPY(name);
}
/* }}} */
-/* {{{ proto public bool ReflectionFunctionAbstract:hasReturnType()
- Return whether the function has a return type */
-ZEND_METHOD(reflection_function, hasReturnType)
+/* {{{ Return whether the function has a return type */
+ZEND_METHOD(ReflectionFunctionAbstract, hasReturnType)
{
reflection_object *intern;
zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(fptr);
@@ -3363,15 +3406,14 @@ ZEND_METHOD(reflection_function, hasReturnType)
}
/* }}} */
-/* {{{ proto public string ReflectionFunctionAbstract::getReturnType()
- Returns the return type associated with the function */
-ZEND_METHOD(reflection_function, getReturnType)
+/* {{{ Returns the return type associated with the function */
+ZEND_METHOD(ReflectionFunctionAbstract, getReturnType)
{
reflection_object *intern;
zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(fptr);
@@ -3380,46 +3422,44 @@ ZEND_METHOD(reflection_function, getReturnType)
RETURN_NULL();
}
- reflection_type_factory(fptr->common.arg_info[-1].type, return_value);
+ reflection_type_factory(fptr->common.arg_info[-1].type, return_value, 1);
}
/* }}} */
-/* {{{ proto public bool ReflectionMethod::isConstructor()
- Returns whether this method is the constructor */
-ZEND_METHOD(reflection_method, isConstructor)
+/* {{{ Returns whether this method is the constructor */
+ZEND_METHOD(ReflectionMethod, isConstructor)
{
reflection_object *intern;
zend_function *mptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(mptr);
/* we need to check if the ctor is the ctor of the class level we we
* looking at since we might be looking at an inherited old style ctor
* defined in base class. */
- RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_CTOR && intern->ce->constructor && intern->ce->constructor->common.scope == mptr->common.scope);
+ RETURN_BOOL((mptr->common.fn_flags & ZEND_ACC_CTOR) && intern->ce->constructor && intern->ce->constructor->common.scope == mptr->common.scope);
}
/* }}} */
-/* {{{ proto public bool ReflectionMethod::isDestructor()
- Returns whether this method is static */
-ZEND_METHOD(reflection_method, isDestructor)
+/* {{{ Returns whether this method is a destructor */
+ZEND_METHOD(ReflectionMethod, isDestructor)
{
reflection_object *intern;
zend_function *mptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(mptr);
- RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_DTOR);
+ RETURN_BOOL(zend_string_equals_literal_ci(
+ mptr->common.function_name, ZEND_DESTRUCTOR_FUNC_NAME));
}
/* }}} */
-/* {{{ proto public int ReflectionMethod::getModifiers()
- Returns a bitfield of the access modifiers for this method */
-ZEND_METHOD(reflection_method, getModifiers)
+/* {{{ Returns a bitfield of the access modifiers for this method */
+ZEND_METHOD(ReflectionMethod, getModifiers)
{
reflection_object *intern;
zend_function *mptr;
@@ -3427,7 +3467,7 @@ ZEND_METHOD(reflection_method, getModifiers)
| ZEND_ACC_STATIC | ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(mptr);
@@ -3435,9 +3475,8 @@ ZEND_METHOD(reflection_method, getModifiers)
}
/* }}} */
-/* {{{ proto public ReflectionClass ReflectionMethod::getDeclaringClass()
- Get the declaring class */
-ZEND_METHOD(reflection_method, getDeclaringClass)
+/* {{{ Get the declaring class */
+ZEND_METHOD(ReflectionMethod, getDeclaringClass)
{
reflection_object *intern;
zend_function *mptr;
@@ -3445,16 +3484,15 @@ ZEND_METHOD(reflection_method, getDeclaringClass)
GET_REFLECTION_OBJECT_PTR(mptr);
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
zend_reflection_class_factory(mptr->common.scope, return_value);
}
/* }}} */
-/* {{{ proto public ReflectionClass ReflectionMethod::getPrototype()
- Get the prototype */
-ZEND_METHOD(reflection_method, getPrototype)
+/* {{{ Get the prototype */
+ZEND_METHOD(ReflectionMethod, getPrototype)
{
reflection_object *intern;
zend_function *mptr;
@@ -3462,28 +3500,27 @@ ZEND_METHOD(reflection_method, getPrototype)
GET_REFLECTION_OBJECT_PTR(mptr);
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!mptr->common.prototype) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Method %s::%s does not have a prototype", ZSTR_VAL(intern->ce->name), ZSTR_VAL(mptr->common.function_name));
- return;
+ RETURN_THROWS();
}
reflection_method_factory(mptr->common.prototype->common.scope, mptr->common.prototype, NULL, return_value);
}
/* }}} */
-/* {{{ proto public void ReflectionMethod::setAccessible(bool visible)
- Sets whether non-public methods can be invoked */
-ZEND_METHOD(reflection_method, setAccessible)
+/* {{{ Sets whether non-public methods can be invoked */
+ZEND_METHOD(ReflectionMethod, setAccessible)
{
reflection_object *intern;
zend_bool visible;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &visible) == FAILURE) {
- return;
+ RETURN_THROWS();
}
intern = Z_REFLECTION_P(ZEND_THIS);
@@ -3492,45 +3529,37 @@ ZEND_METHOD(reflection_method, setAccessible)
}
/* }}} */
-/* {{{ proto public void ReflectionClassConstant::__construct(mixed class, string name)
- Constructor. Throws an Exception in case the given class constant does not exist */
-ZEND_METHOD(reflection_class_constant, __construct)
+/* {{{ Constructor. Throws an Exception in case the given class constant does not exist */
+ZEND_METHOD(ReflectionClassConstant, __construct)
{
- zval *classname, *object;
+ zval *object;
+ zend_string *classname_str;
+ zend_object *classname_obj;
zend_string *constname;
reflection_object *intern;
zend_class_entry *ce;
zend_class_constant *constant = NULL;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "zS", &classname, &constname) == FAILURE) {
- return;
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJ_OR_STR(classname_obj, classname_str)
+ Z_PARAM_STR(constname)
+ ZEND_PARSE_PARAMETERS_END();
+
+ if (classname_obj) {
+ ce = classname_obj->ce;
+ } else {
+ if ((ce = zend_lookup_class(classname_str)) == NULL) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0, "Class \"%s\" does not exist", ZSTR_VAL(classname_str));
+ RETURN_THROWS();
+ }
}
object = ZEND_THIS;
intern = Z_REFLECTION_P(object);
- /* Find the class entry */
- switch (Z_TYPE_P(classname)) {
- case IS_STRING:
- if ((ce = zend_lookup_class(Z_STR_P(classname))) == NULL) {
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Class %s does not exist", Z_STRVAL_P(classname));
- return;
- }
- break;
-
- case IS_OBJECT:
- ce = Z_OBJCE_P(classname);
- break;
-
- default:
- _DO_THROW("The parameter class is expected to be either a string or an object");
- return;
- }
-
if ((constant = zend_hash_find_ptr(&ce->constants_table, constname)) == NULL) {
- zend_throw_exception_ex(reflection_exception_ptr, 0, "Class Constant %s::%s does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(constname));
- return;
+ zend_throw_exception_ex(reflection_exception_ptr, 0, "Constant %s::%s does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(constname));
+ RETURN_THROWS();
}
intern->ptr = constant;
@@ -3538,13 +3567,12 @@ ZEND_METHOD(reflection_class_constant, __construct)
intern->ce = constant->ce;
intern->ignore_visibility = 0;
ZVAL_STR_COPY(reflection_prop_name(object), constname);
- ZVAL_STR_COPY(reflection_prop_class(object), ce->name);
+ ZVAL_STR_COPY(reflection_prop_class(object), constant->ce->name);
}
/* }}} */
-/* {{{ proto public string ReflectionClassConstant::__toString()
- Returns a string representation */
-ZEND_METHOD(reflection_class_constant, __toString)
+/* {{{ Returns a string representation */
+ZEND_METHOD(ReflectionClassConstant, __toString)
{
reflection_object *intern;
zend_class_constant *ref;
@@ -3552,7 +3580,7 @@ ZEND_METHOD(reflection_class_constant, __toString)
zval name;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
_default_get_name(ZEND_THIS, &name);
@@ -3562,12 +3590,11 @@ ZEND_METHOD(reflection_class_constant, __toString)
}
/* }}} */
-/* {{{ proto public string ReflectionClassConstant::getName()
- Returns the constant' name */
-ZEND_METHOD(reflection_class_constant, getName)
+/* {{{ Returns the constant' name */
+ZEND_METHOD(ReflectionClassConstant, getName)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
_default_get_name(ZEND_THIS, return_value);
}
@@ -3579,46 +3606,42 @@ static void _class_constant_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) /
zend_class_constant *ref;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
RETURN_BOOL(Z_ACCESS_FLAGS(ref->value) & mask);
}
/* }}} */
-/* {{{ proto public bool ReflectionClassConstant::isPublic()
- Returns whether this constant is public */
-ZEND_METHOD(reflection_class_constant, isPublic)
+/* {{{ Returns whether this constant is public */
+ZEND_METHOD(ReflectionClassConstant, isPublic)
{
_class_constant_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC);
}
/* }}} */
-/* {{{ proto public bool ReflectionClassConstant::isPrivate()
- Returns whether this constant is private */
-ZEND_METHOD(reflection_class_constant, isPrivate)
+/* {{{ Returns whether this constant is private */
+ZEND_METHOD(ReflectionClassConstant, isPrivate)
{
_class_constant_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PRIVATE);
}
/* }}} */
-/* {{{ proto public bool ReflectionClassConstant::isProtected()
- Returns whether this constant is protected */
-ZEND_METHOD(reflection_class_constant, isProtected)
+/* {{{ Returns whether this constant is protected */
+ZEND_METHOD(ReflectionClassConstant, isProtected)
{
_class_constant_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PROTECTED);
}
/* }}} */
-/* {{{ proto public int ReflectionClassConstant::getModifiers()
- Returns a bitfield of the access modifiers for this constant */
-ZEND_METHOD(reflection_class_constant, getModifiers)
+/* {{{ Returns a bitfield of the access modifiers for this constant */
+ZEND_METHOD(ReflectionClassConstant, getModifiers)
{
reflection_object *intern;
zend_class_constant *ref;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
@@ -3626,15 +3649,14 @@ ZEND_METHOD(reflection_class_constant, getModifiers)
}
/* }}} */
-/* {{{ proto public mixed ReflectionClassConstant::getValue()
- Returns this constant's value */
-ZEND_METHOD(reflection_class_constant, getValue)
+/* {{{ Returns this constant's value */
+ZEND_METHOD(ReflectionClassConstant, getValue)
{
reflection_object *intern;
zend_class_constant *ref;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
@@ -3645,15 +3667,14 @@ ZEND_METHOD(reflection_class_constant, getValue)
}
/* }}} */
-/* {{{ proto public ReflectionClass ReflectionClassConstant::getDeclaringClass()
- Get the declaring class */
-ZEND_METHOD(reflection_class_constant, getDeclaringClass)
+/* {{{ Get the declaring class */
+ZEND_METHOD(ReflectionClassConstant, getDeclaringClass)
{
reflection_object *intern;
zend_class_constant *ref;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
@@ -3661,15 +3682,14 @@ ZEND_METHOD(reflection_class_constant, getDeclaringClass)
}
/* }}} */
-/* {{{ proto public string ReflectionClassConstant::getDocComment()
- Returns the doc comment for this constant */
-ZEND_METHOD(reflection_class_constant, getDocComment)
+/* {{{ Returns the doc comment for this constant */
+ZEND_METHOD(ReflectionClassConstant, getDocComment)
{
reflection_object *intern;
zend_class_constant *ref;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
if (ref->doc_comment) {
@@ -3679,51 +3699,54 @@ ZEND_METHOD(reflection_class_constant, getDocComment)
}
/* }}} */
-/* {{{ proto public static mixed ReflectionClass::export(mixed argument [, bool return]) throws ReflectionException
- Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
-ZEND_METHOD(reflection_class, export)
+/* {{{ Returns the attributes of this constant */
+ZEND_METHOD(ReflectionClassConstant, getAttributes)
{
- _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_class_ptr, 1);
+ reflection_object *intern;
+ zend_class_constant *ref;
+
+ GET_REFLECTION_OBJECT_PTR(ref);
+
+ reflect_attributes(INTERNAL_FUNCTION_PARAM_PASSTHRU,
+ ref->attributes, 0, ref->ce, ZEND_ATTRIBUTE_TARGET_CLASS_CONST,
+ ref->ce->type == ZEND_USER_CLASS ? ref->ce->info.user.filename : NULL);
}
/* }}} */
/* {{{ reflection_class_object_ctor */
static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_object)
{
- zval *argument;
zval *object;
+ zend_string *arg_class = NULL;
+ zend_object *arg_obj;
reflection_object *intern;
zend_class_entry *ce;
if (is_object) {
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_OBJECT(argument)
+ Z_PARAM_OBJ(arg_obj)
ZEND_PARSE_PARAMETERS_END();
} else {
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_ZVAL(argument)
+ Z_PARAM_OBJ_OR_STR(arg_obj, arg_class)
ZEND_PARSE_PARAMETERS_END();
}
object = ZEND_THIS;
intern = Z_REFLECTION_P(object);
- if (Z_TYPE_P(argument) == IS_OBJECT) {
- ZVAL_STR_COPY(reflection_prop_name(object), Z_OBJCE_P(argument)->name);
- intern->ptr = Z_OBJCE_P(argument);
+ if (arg_obj) {
+ ZVAL_STR_COPY(reflection_prop_name(object), arg_obj->ce->name);
+ intern->ptr = arg_obj->ce;
if (is_object) {
- ZVAL_COPY(&intern->obj, argument);
+ ZVAL_OBJ_COPY(&intern->obj, arg_obj);
}
} else {
- if (!try_convert_to_string(argument)) {
- return;
- }
-
- if ((ce = zend_lookup_class(Z_STR_P(argument))) == NULL) {
+ if ((ce = zend_lookup_class(arg_class)) == NULL) {
if (!EG(exception)) {
- zend_throw_exception_ex(reflection_exception_ptr, -1, "Class %s does not exist", Z_STRVAL_P(argument));
+ zend_throw_exception_ex(reflection_exception_ptr, -1, "Class \"%s\" does not exist", ZSTR_VAL(arg_class));
}
- return;
+ RETURN_THROWS();
}
ZVAL_STR_COPY(reflection_prop_name(object), ce->name);
@@ -3733,16 +3756,15 @@ static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_ob
}
/* }}} */
-/* {{{ proto public void ReflectionClass::__construct(mixed argument) throws ReflectionException
- Constructor. Takes a string or an instance as an argument */
-ZEND_METHOD(reflection_class, __construct)
+/* {{{ Constructor. Takes a string or an instance as an argument */
+ZEND_METHOD(ReflectionClass, __construct)
{
reflection_class_object_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
/* {{{ add_class_vars */
-static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value)
+static void add_class_vars(zend_class_entry *ce, zend_bool statics, zval *return_value)
{
zend_property_info *prop_info;
zval *prop, prop_copy;
@@ -3753,14 +3775,14 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value
prop_info->ce != ce)) {
continue;
}
- prop = NULL;
- if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) {
- prop = &ce->default_static_members_table[prop_info->offset];
- ZVAL_DEINDIRECT(prop);
- } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) {
- prop = &ce->default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)];
+
+ zend_bool is_static = (prop_info->flags & ZEND_ACC_STATIC) != 0;
+ if (statics != is_static) {
+ continue;
}
- if (!prop || (prop_info->type && Z_ISUNDEF_P(prop))) {
+
+ prop = property_get_default(prop_info);
+ if (Z_ISUNDEF_P(prop)) {
continue;
}
@@ -3781,9 +3803,8 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value
}
/* }}} */
-/* {{{ proto public array ReflectionClass::getStaticProperties()
- Returns an associative array containing all static property values of the class */
-ZEND_METHOD(reflection_class, getStaticProperties)
+/* {{{ Returns an associative array containing all static property values of the class */
+ZEND_METHOD(ReflectionClass, getStaticProperties)
{
reflection_object *intern;
zend_class_entry *ce;
@@ -3792,13 +3813,13 @@ ZEND_METHOD(reflection_class, getStaticProperties)
zend_string *key;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
if (UNEXPECTED(zend_update_class_constants(ce) != SUCCESS)) {
- return;
+ RETURN_THROWS();
}
if (ce->default_static_members_count && !CE_STATIC_MEMBERS(ce)) {
@@ -3819,7 +3840,7 @@ ZEND_METHOD(reflection_class, getStaticProperties)
prop = &CE_STATIC_MEMBERS(ce)[prop_info->offset];
ZVAL_DEINDIRECT(prop);
- if (prop_info->type && Z_ISUNDEF_P(prop)) {
+ if (ZEND_TYPE_IS_SET(prop_info->type) && Z_ISUNDEF_P(prop)) {
continue;
}
@@ -3832,9 +3853,8 @@ ZEND_METHOD(reflection_class, getStaticProperties)
}
/* }}} */
-/* {{{ proto public mixed ReflectionClass::getStaticPropertyValue(string name [, mixed default])
- Returns the value of a static property */
-ZEND_METHOD(reflection_class, getStaticPropertyValue)
+/* {{{ Returns the value of a static property */
+ZEND_METHOD(ReflectionClass, getStaticPropertyValue)
{
reflection_object *intern;
zend_class_entry *ce, *old_scope;
@@ -3842,13 +3862,13 @@ ZEND_METHOD(reflection_class, getStaticPropertyValue)
zval *prop, *def_value = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|z", &name, &def_value) == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
if (UNEXPECTED(zend_update_class_constants(ce) != SUCCESS)) {
- return;
+ RETURN_THROWS();
}
old_scope = EG(fake_scope);
@@ -3861,7 +3881,7 @@ ZEND_METHOD(reflection_class, getStaticPropertyValue)
ZVAL_COPY(return_value, def_value);
} else {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Class %s does not have a property named %s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
+ "Property %s::$%s does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(name));
}
return;
} else {
@@ -3870,9 +3890,8 @@ ZEND_METHOD(reflection_class, getStaticPropertyValue)
}
/* }}} */
-/* {{{ proto public void ReflectionClass::setStaticPropertyValue(string $name, mixed $value)
- Sets the value of a static property */
-ZEND_METHOD(reflection_class, setStaticPropertyValue)
+/* {{{ Sets the value of a static property */
+ZEND_METHOD(ReflectionClass, setStaticPropertyValue)
{
reflection_object *intern;
zend_class_entry *ce, *old_scope;
@@ -3881,13 +3900,13 @@ ZEND_METHOD(reflection_class, setStaticPropertyValue)
zval *variable_ptr, *value;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sz", &name, &value) == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
if (UNEXPECTED(zend_update_class_constants(ce) != SUCCESS)) {
- return;
+ RETURN_THROWS();
}
old_scope = EG(fake_scope);
EG(fake_scope) = ce;
@@ -3897,7 +3916,7 @@ ZEND_METHOD(reflection_class, setStaticPropertyValue)
zend_clear_exception();
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Class %s does not have a property named %s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
- return;
+ RETURN_THROWS();
}
if (Z_ISREF_P(variable_ptr)) {
@@ -3909,7 +3928,7 @@ ZEND_METHOD(reflection_class, setStaticPropertyValue)
}
}
- if (prop_info->type && !zend_verify_property_type(prop_info, value, 0)) {
+ if (ZEND_TYPE_IS_SET(prop_info->type) && !zend_verify_property_type(prop_info, value, 0)) {
return;
}
@@ -3919,36 +3938,34 @@ ZEND_METHOD(reflection_class, setStaticPropertyValue)
}
/* }}} */
-/* {{{ proto public array ReflectionClass::getDefaultProperties()
- Returns an associative array containing copies of all default property values of the class */
-ZEND_METHOD(reflection_class, getDefaultProperties)
+/* {{{ Returns an associative array containing copies of all default property values of the class */
+ZEND_METHOD(ReflectionClass, getDefaultProperties)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
array_init(return_value);
if (UNEXPECTED(zend_update_class_constants(ce) != SUCCESS)) {
- return;
+ RETURN_THROWS();
}
add_class_vars(ce, 1, return_value);
add_class_vars(ce, 0, return_value);
}
/* }}} */
-/* {{{ proto public string ReflectionClass::__toString()
- Returns a string representation */
-ZEND_METHOD(reflection_class, __toString)
+/* {{{ Returns a string representation */
+ZEND_METHOD(ReflectionClass, __toString)
{
reflection_object *intern;
zend_class_entry *ce;
smart_str str = {0};
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
_class_string(&str, ce, &intern->obj, "");
@@ -3956,71 +3973,71 @@ ZEND_METHOD(reflection_class, __toString)
}
/* }}} */
-/* {{{ proto public string ReflectionClass::getName()
- Returns the class' name */
-ZEND_METHOD(reflection_class, getName)
+/* {{{ Returns the class' name */
+ZEND_METHOD(ReflectionClass, getName)
{
+ reflection_object *intern;
+ zend_class_entry *ce;
+
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
- _default_get_name(ZEND_THIS, return_value);
+
+ GET_REFLECTION_OBJECT_PTR(ce);
+ RETURN_STR_COPY(ce->name);
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::isInternal()
- Returns whether this class is an internal class */
-ZEND_METHOD(reflection_class, isInternal)
+/* {{{ Returns whether this class is an internal class */
+ZEND_METHOD(ReflectionClass, isInternal)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
RETURN_BOOL(ce->type == ZEND_INTERNAL_CLASS);
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::isUserDefined()
- Returns whether this class is user-defined */
-ZEND_METHOD(reflection_class, isUserDefined)
+/* {{{ Returns whether this class is user-defined */
+ZEND_METHOD(ReflectionClass, isUserDefined)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
RETURN_BOOL(ce->type == ZEND_USER_CLASS);
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::isAnonymous()
- Returns whether this class is anonymous */
-ZEND_METHOD(reflection_class, isAnonymous)
+/* {{{ Returns whether this class is anonymous */
+ZEND_METHOD(ReflectionClass, isAnonymous)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
RETURN_BOOL(ce->ce_flags & ZEND_ACC_ANON_CLASS);
}
/* }}} */
-/* {{{ proto public string ReflectionClass::getFileName()
- Returns the filename of the file this class was declared in */
-ZEND_METHOD(reflection_class, getFileName)
+/* {{{ Returns the filename of the file this class was declared in */
+ZEND_METHOD(ReflectionClass, getFileName)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->type == ZEND_USER_CLASS) {
@@ -4030,15 +4047,14 @@ ZEND_METHOD(reflection_class, getFileName)
}
/* }}} */
-/* {{{ proto public int ReflectionClass::getStartLine()
- Returns the line this class' declaration starts at */
-ZEND_METHOD(reflection_class, getStartLine)
+/* {{{ Returns the line this class' declaration starts at */
+ZEND_METHOD(ReflectionClass, getStartLine)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->type == ZEND_USER_CLASS) {
@@ -4048,15 +4064,14 @@ ZEND_METHOD(reflection_class, getStartLine)
}
/* }}} */
-/* {{{ proto public int ReflectionClass::getEndLine()
- Returns the line this class' declaration ends at */
-ZEND_METHOD(reflection_class, getEndLine)
+/* {{{ Returns the line this class' declaration ends at */
+ZEND_METHOD(ReflectionClass, getEndLine)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->type == ZEND_USER_CLASS) {
@@ -4066,15 +4081,14 @@ ZEND_METHOD(reflection_class, getEndLine)
}
/* }}} */
-/* {{{ proto public string ReflectionClass::getDocComment()
- Returns the doc comment for this class */
-ZEND_METHOD(reflection_class, getDocComment)
+/* {{{ Returns the doc comment for this class */
+ZEND_METHOD(ReflectionClass, getDocComment)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->type == ZEND_USER_CLASS && ce->info.user.doc_comment) {
@@ -4084,15 +4098,28 @@ ZEND_METHOD(reflection_class, getDocComment)
}
/* }}} */
-/* {{{ proto public ReflectionMethod ReflectionClass::getConstructor()
- Returns the class' constructor if there is one, NULL otherwise */
-ZEND_METHOD(reflection_class, getConstructor)
+/* {{{ Returns the attributes for this class */
+ZEND_METHOD(ReflectionClass, getAttributes)
+{
+ reflection_object *intern;
+ zend_class_entry *ce;
+
+ GET_REFLECTION_OBJECT_PTR(ce);
+
+ reflect_attributes(INTERNAL_FUNCTION_PARAM_PASSTHRU,
+ ce->attributes, 0, ce, ZEND_ATTRIBUTE_TARGET_CLASS,
+ ce->type == ZEND_USER_CLASS ? ce->info.user.filename : NULL);
+}
+/* }}} */
+
+/* {{{ Returns the class' constructor if there is one, NULL otherwise */
+ZEND_METHOD(ReflectionClass, getConstructor)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -4104,16 +4131,15 @@ ZEND_METHOD(reflection_class, getConstructor)
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::hasMethod(string name)
- Returns whether a method exists or not */
-ZEND_METHOD(reflection_class, hasMethod)
+/* {{{ Returns whether a method exists or not */
+ZEND_METHOD(ReflectionClass, hasMethod)
{
reflection_object *intern;
zend_class_entry *ce;
zend_string *name, *lc_name;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -4123,9 +4149,8 @@ ZEND_METHOD(reflection_class, hasMethod)
}
/* }}} */
-/* {{{ proto public ReflectionMethod ReflectionClass::getMethod(string name) throws ReflectionException
- Returns the class' method specified by its name */
-ZEND_METHOD(reflection_class, getMethod)
+/* {{{ Returns the class' method specified by its name */
+ZEND_METHOD(ReflectionClass, getMethod)
{
reflection_object *intern;
zend_class_entry *ce;
@@ -4134,7 +4159,7 @@ ZEND_METHOD(reflection_class, getMethod)
zend_string *name, *lc_name;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -4155,7 +4180,7 @@ ZEND_METHOD(reflection_class, getMethod)
reflection_method_factory(ce, mptr, NULL, return_value);
} else {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Method %s does not exist", ZSTR_VAL(name));
+ "Method %s::%s() does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(name));
}
zend_string_release(lc_name);
}
@@ -4164,6 +4189,10 @@ ZEND_METHOD(reflection_class, getMethod)
/* {{{ _addmethod */
static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval, zend_long filter)
{
+ if ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) && mptr->common.scope != ce) {
+ return;
+ }
+
if (mptr->common.fn_flags & filter) {
zval method;
reflection_method_factory(ce, mptr, NULL, &method);
@@ -4172,18 +4201,17 @@ static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval,
}
/* }}} */
-/* {{{ proto public ReflectionMethod[] ReflectionClass::getMethods([long $filter])
- Returns an array of this class' methods */
-ZEND_METHOD(reflection_class, getMethods)
+/* {{{ Returns an array of this class' methods */
+ZEND_METHOD(ReflectionClass, getMethods)
{
reflection_object *intern;
zend_class_entry *ce;
zend_function *mptr;
- zend_long filter = 0;
+ zend_long filter;
zend_bool filter_is_null = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (filter_is_null) {
@@ -4218,18 +4246,16 @@ ZEND_METHOD(reflection_class, getMethods)
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::hasProperty(string name)
- Returns whether a property exists or not */
-ZEND_METHOD(reflection_class, hasProperty)
+/* {{{ Returns whether a property exists or not */
+ZEND_METHOD(ReflectionClass, hasProperty)
{
reflection_object *intern;
zend_property_info *property_info;
zend_class_entry *ce;
zend_string *name;
- zval property;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -4240,21 +4266,17 @@ ZEND_METHOD(reflection_class, hasProperty)
RETURN_TRUE;
} else {
if (Z_TYPE(intern->obj) != IS_UNDEF) {
- ZVAL_STR_COPY(&property, name);
- if (Z_OBJ_HANDLER(intern->obj, has_property)(&intern->obj, &property, 2, NULL)) {
- zval_ptr_dtor(&property);
+ if (Z_OBJ_HANDLER(intern->obj, has_property)(Z_OBJ(intern->obj), name, 2, NULL)) {
RETURN_TRUE;
}
- zval_ptr_dtor(&property);
}
RETURN_FALSE;
}
}
/* }}} */
-/* {{{ proto public ReflectionProperty ReflectionClass::getProperty(string name) throws ReflectionException
- Returns the class' property specified by its name */
-ZEND_METHOD(reflection_class, getProperty)
+/* {{{ Returns the class' property specified by its name */
+ZEND_METHOD(ReflectionClass, getProperty)
{
reflection_object *intern;
zend_class_entry *ce, *ce2;
@@ -4264,26 +4286,19 @@ ZEND_METHOD(reflection_class, getProperty)
size_t classname_len, str_name_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
if ((property_info = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) {
if (!(property_info->flags & ZEND_ACC_PRIVATE) || property_info->ce == ce) {
- reflection_property_factory(ce, name, property_info, return_value, 0);
+ reflection_property_factory(ce, name, property_info, return_value);
return;
}
} else if (Z_TYPE(intern->obj) != IS_UNDEF) {
/* Check for dynamic properties */
- if (zend_hash_exists(Z_OBJ_HT(intern->obj)->get_properties(&intern->obj), name)) {
- zend_property_info property_info_tmp;
- property_info_tmp.flags = ZEND_ACC_PUBLIC;
- property_info_tmp.name = name;
- property_info_tmp.doc_comment = NULL;
- property_info_tmp.ce = ce;
- property_info_tmp.type = 0;
-
- reflection_property_factory(ce, name, &property_info_tmp, return_value, 1);
+ if (zend_hash_exists(Z_OBJ_HT(intern->obj)->get_properties(Z_OBJ(intern->obj)), name)) {
+ reflection_property_factory(ce, name, NULL, return_value);
return;
}
}
@@ -4299,16 +4314,16 @@ ZEND_METHOD(reflection_class, getProperty)
ce2 = zend_lookup_class(classname);
if (!ce2) {
if (!EG(exception)) {
- zend_throw_exception_ex(reflection_exception_ptr, -1, "Class %s does not exist", ZSTR_VAL(classname));
+ zend_throw_exception_ex(reflection_exception_ptr, -1, "Class \"%s\" does not exist", ZSTR_VAL(classname));
}
zend_string_release_ex(classname, 0);
- return;
+ RETURN_THROWS();
}
zend_string_release_ex(classname, 0);
if (!instanceof_function(ce, ce2)) {
- zend_throw_exception_ex(reflection_exception_ptr, -1, "Fully qualified property name %s::%s does not specify a base class of %s", ZSTR_VAL(ce2->name), str_name, ZSTR_VAL(ce->name));
- return;
+ zend_throw_exception_ex(reflection_exception_ptr, -1, "Fully qualified property name %s::$%s does not specify a base class of %s", ZSTR_VAL(ce2->name), str_name, ZSTR_VAL(ce->name));
+ RETURN_THROWS();
}
ce = ce2;
@@ -4320,8 +4335,7 @@ ZEND_METHOD(reflection_class, getProperty)
return;
}
}
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Property %s does not exist", str_name);
+ zend_throw_exception_ex(reflection_exception_ptr, 0, "Property %s::$%s does not exist", ZSTR_VAL(ce->name), str_name);
}
/* }}} */
@@ -4334,7 +4348,7 @@ static void _addproperty(zend_property_info *pptr, zend_string *key, zend_class_
if (pptr->flags & filter) {
zval property;
- reflection_property_factory(ce, key, pptr, &property, 0);
+ reflection_property_factory(ce, key, pptr, &property);
add_next_index_zval(retval, &property);
}
}
@@ -4343,7 +4357,6 @@ static void _addproperty(zend_property_info *pptr, zend_string *key, zend_class_
/* {{{ _adddynproperty */
static void _adddynproperty(zval *ptr, zend_string *key, zend_class_entry *ce, zval *retval)
{
- zend_property_info property_info;
zval property;
/* under some circumstances, the properties hash table may contain numeric
@@ -4358,30 +4371,23 @@ static void _adddynproperty(zval *ptr, zend_string *key, zend_class_entry *ce, z
return;
}
- property_info.doc_comment = NULL;
- property_info.flags = ZEND_ACC_PUBLIC;
- property_info.name = key;
- property_info.ce = ce;
- property_info.offset = -1;
- property_info.type = 0;
- reflection_property_factory(ce, key, &property_info, &property, 1);
+ reflection_property_factory(ce, key, NULL, &property);
add_next_index_zval(retval, &property);
}
/* }}} */
-/* {{{ proto public ReflectionProperty[] ReflectionClass::getProperties([long $filter])
- Returns an array of this class' properties */
-ZEND_METHOD(reflection_class, getProperties)
+/* {{{ Returns an array of this class' properties */
+ZEND_METHOD(ReflectionClass, getProperties)
{
reflection_object *intern;
zend_class_entry *ce;
zend_string *key;
zend_property_info *prop_info;
- zend_long filter = 0;
+ zend_long filter;
zend_bool filter_is_null = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (filter_is_null) {
@@ -4396,7 +4402,7 @@ ZEND_METHOD(reflection_class, getProperties)
} ZEND_HASH_FOREACH_END();
if (Z_TYPE(intern->obj) != IS_UNDEF && (filter & ZEND_ACC_PUBLIC) != 0) {
- HashTable *properties = Z_OBJ_HT(intern->obj)->get_properties(&intern->obj);
+ HashTable *properties = Z_OBJ_HT(intern->obj)->get_properties(Z_OBJ(intern->obj));
zval *prop;
ZEND_HASH_FOREACH_STR_KEY_VAL(properties, key, prop) {
_adddynproperty(prop, key, ce, return_value);
@@ -4405,16 +4411,15 @@ ZEND_METHOD(reflection_class, getProperties)
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::hasConstant(string name)
- Returns whether a constant exists or not */
-ZEND_METHOD(reflection_class, hasConstant)
+/* {{{ Returns whether a constant exists or not */
+ZEND_METHOD(ReflectionClass, hasConstant)
{
reflection_object *intern;
zend_class_entry *ce;
zend_string *name;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -4426,57 +4431,74 @@ ZEND_METHOD(reflection_class, hasConstant)
}
/* }}} */
-/* {{{ proto public array ReflectionClass::getConstants()
- Returns an associative array containing this class' constants and their values */
-ZEND_METHOD(reflection_class, getConstants)
+/* {{{ Returns an associative array containing this class' constants and their values */
+ZEND_METHOD(ReflectionClass, getConstants)
{
reflection_object *intern;
zend_class_entry *ce;
zend_string *key;
- zend_class_constant *c;
+ zend_class_constant *constant;
zval val;
+ zend_long filter;
+ zend_bool filter_is_null = 1;
- if (zend_parse_parameters_none() == FAILURE) {
- return;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) {
+ RETURN_THROWS();
}
+
+ if (filter_is_null) {
+ filter = ZEND_ACC_PPP_MASK;
+ }
+
GET_REFLECTION_OBJECT_PTR(ce);
+
array_init(return_value);
- ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->constants_table, key, c) {
- if (UNEXPECTED(zval_update_constant_ex(&c->value, ce) != SUCCESS)) {
- zend_array_destroy(Z_ARRVAL_P(return_value));
- RETURN_NULL();
+ ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->constants_table, key, constant) {
+ if (UNEXPECTED(zval_update_constant_ex(&constant->value, ce) != SUCCESS)) {
+ RETURN_THROWS();
+ }
+
+ if (Z_ACCESS_FLAGS(constant->value) & filter) {
+ ZVAL_COPY_OR_DUP(&val, &constant->value);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), key, &val);
}
- ZVAL_COPY_OR_DUP(&val, &c->value);
- zend_hash_add_new(Z_ARRVAL_P(return_value), key, &val);
} ZEND_HASH_FOREACH_END();
}
/* }}} */
-/* {{{ proto public array ReflectionClass::getReflectionConstants()
- Returns an associative array containing this class' constants as ReflectionClassConstant objects */
-ZEND_METHOD(reflection_class, getReflectionConstants)
+/* {{{ Returns an associative array containing this class' constants as ReflectionClassConstant objects */
+ZEND_METHOD(ReflectionClass, getReflectionConstants)
{
reflection_object *intern;
zend_class_entry *ce;
zend_string *name;
zend_class_constant *constant;
+ zend_long filter;
+ zend_bool filter_is_null = 1;
- if (zend_parse_parameters_none() == FAILURE) {
- return;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) {
+ RETURN_THROWS();
}
+
+ if (filter_is_null) {
+ filter = ZEND_ACC_PPP_MASK;
+ }
+
GET_REFLECTION_OBJECT_PTR(ce);
+
array_init(return_value);
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->constants_table, name, constant) {
- zval class_const;
- reflection_class_constant_factory(ce, name, constant, &class_const);
- zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &class_const);
+ if (Z_ACCESS_FLAGS(constant->value) & filter) {
+ zval class_const;
+ reflection_class_constant_factory(name, constant, &class_const);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &class_const);
+ }
} ZEND_HASH_FOREACH_END();
}
/* }}} */
-/* {{{ proto public mixed ReflectionClass::getConstant(string name)
- Returns the class' constant specified by its name */
-ZEND_METHOD(reflection_class, getConstant)
+/* {{{ Returns the class' constant specified by its name */
+ZEND_METHOD(ReflectionClass, getConstant)
{
reflection_object *intern;
zend_class_entry *ce;
@@ -4484,13 +4506,13 @@ ZEND_METHOD(reflection_class, getConstant)
zend_string *name;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
ZEND_HASH_FOREACH_PTR(&ce->constants_table, c) {
if (UNEXPECTED(zval_update_constant_ex(&c->value, ce) != SUCCESS)) {
- return;
+ RETURN_THROWS();
}
} ZEND_HASH_FOREACH_END();
if ((c = zend_hash_find_ptr(&ce->constants_table, name)) == NULL) {
@@ -4500,9 +4522,8 @@ ZEND_METHOD(reflection_class, getConstant)
}
/* }}} */
-/* {{{ proto public mixed ReflectionClass::getReflectionConstant(string name)
- Returns the class' constant as ReflectionClassConstant objects */
-ZEND_METHOD(reflection_class, getReflectionConstant)
+/* {{{ Returns the class' constant as ReflectionClassConstant objects */
+ZEND_METHOD(ReflectionClass, getReflectionConstant)
{
reflection_object *intern;
zend_class_entry *ce;
@@ -4511,13 +4532,13 @@ ZEND_METHOD(reflection_class, getReflectionConstant)
GET_REFLECTION_OBJECT_PTR(ce);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if ((constant = zend_hash_find_ptr(&ce->constants_table, name)) == NULL) {
RETURN_FALSE;
}
- reflection_class_constant_factory(ce, name, constant, return_value);
+ reflection_class_constant_factory(name, constant, return_value);
}
/* }}} */
@@ -4528,22 +4549,21 @@ static void _class_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask)
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
RETVAL_BOOL(ce->ce_flags & mask);
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::isInstantiable()
- Returns whether this class is instantiable */
-ZEND_METHOD(reflection_class, isInstantiable)
+/* {{{ Returns whether this class is instantiable */
+ZEND_METHOD(ReflectionClass, isInstantiable)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS)) {
@@ -4560,16 +4580,15 @@ ZEND_METHOD(reflection_class, isInstantiable)
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::isCloneable()
- Returns whether this class is cloneable */
-ZEND_METHOD(reflection_class, isCloneable)
+/* {{{ Returns whether this class is cloneable */
+ZEND_METHOD(ReflectionClass, isCloneable)
{
reflection_object *intern;
zend_class_entry *ce;
zval obj;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS)) {
@@ -4597,41 +4616,36 @@ ZEND_METHOD(reflection_class, isCloneable)
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::isInterface()
- Returns whether this is an interface or a class */
-ZEND_METHOD(reflection_class, isInterface)
+/* {{{ Returns whether this is an interface or a class */
+ZEND_METHOD(ReflectionClass, isInterface)
{
_class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_INTERFACE);
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::isTrait()
- Returns whether this is a trait */
-ZEND_METHOD(reflection_class, isTrait)
+/* {{{ Returns whether this is a trait */
+ZEND_METHOD(ReflectionClass, isTrait)
{
_class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_TRAIT);
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::isFinal()
- Returns whether this class is final */
-ZEND_METHOD(reflection_class, isFinal)
+/* {{{ Returns whether this class is final */
+ZEND_METHOD(ReflectionClass, isFinal)
{
_class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_FINAL);
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::isAbstract()
- Returns whether this class is abstract */
-ZEND_METHOD(reflection_class, isAbstract)
+/* {{{ Returns whether this class is abstract */
+ZEND_METHOD(ReflectionClass, isAbstract)
{
_class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
}
/* }}} */
-/* {{{ proto public int ReflectionClass::getModifiers()
- Returns a bitfield of the access modifiers for this class */
-ZEND_METHOD(reflection_class, getModifiers)
+/* {{{ Returns a bitfield of the access modifiers for this class */
+ZEND_METHOD(ReflectionClass, getModifiers)
{
reflection_object *intern;
zend_class_entry *ce;
@@ -4639,7 +4653,7 @@ ZEND_METHOD(reflection_class, getModifiers)
| ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -4647,27 +4661,24 @@ ZEND_METHOD(reflection_class, getModifiers)
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::isInstance(stdclass object)
- Returns whether the given object is an instance of this class */
-ZEND_METHOD(reflection_class, isInstance)
+/* {{{ Returns whether the given object is an instance of this class */
+ZEND_METHOD(ReflectionClass, isInstance)
{
reflection_object *intern;
zend_class_entry *ce;
zval *object;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &object) == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
RETURN_BOOL(instanceof_function(Z_OBJCE_P(object), ce));
}
/* }}} */
-/* {{{ proto public object ReflectionClass::newInstance(mixed* args, ...)
- Returns an instance of this class */
-ZEND_METHOD(reflection_class, newInstance)
+/* {{{ Returns an instance of this class */
+ZEND_METHOD(ReflectionClass, newInstance)
{
- zval retval;
reflection_object *intern;
zend_class_entry *ce, *old_scope;
zend_function *constructor;
@@ -4685,10 +4696,9 @@ ZEND_METHOD(reflection_class, newInstance)
/* Run the constructor if there is one */
if (constructor) {
- zval *params = NULL;
- int ret, i, num_args = 0;
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
+ zval *params;
+ int num_args;
+ HashTable *named_params;
if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) {
zend_throw_exception_ex(reflection_exception_ptr, 0, "Access to non-public constructor of class %s", ZSTR_VAL(ce->name));
@@ -4696,85 +4706,62 @@ ZEND_METHOD(reflection_class, newInstance)
RETURN_NULL();
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "*", &params, &num_args) == FAILURE) {
- zval_ptr_dtor(return_value);
- RETURN_FALSE;
- }
-
- for (i = 0; i < num_args; i++) {
- Z_TRY_ADDREF(params[i]);
- }
+ ZEND_PARSE_PARAMETERS_START(0, -1)
+ Z_PARAM_VARIADIC_WITH_NAMED(params, num_args, named_params)
+ ZEND_PARSE_PARAMETERS_END();
- fci.size = sizeof(fci);
- ZVAL_UNDEF(&fci.function_name);
- fci.object = Z_OBJ_P(return_value);
- fci.retval = &retval;
- fci.param_count = num_args;
- fci.params = params;
- fci.no_separation = 1;
-
- fcc.function_handler = constructor;
- fcc.called_scope = Z_OBJCE_P(return_value);
- fcc.object = Z_OBJ_P(return_value);
-
- ret = zend_call_function(&fci, &fcc);
- zval_ptr_dtor(&retval);
- for (i = 0; i < num_args; i++) {
- zval_ptr_dtor(&params[i]);
- }
+ zend_call_known_function(
+ constructor, Z_OBJ_P(return_value), Z_OBJCE_P(return_value), NULL,
+ num_args, params, named_params);
if (EG(exception)) {
zend_object_store_ctor_failed(Z_OBJ_P(return_value));
}
- if (ret == FAILURE) {
- php_error_docref(NULL, E_WARNING, "Invocation of %s's constructor failed", ZSTR_VAL(ce->name));
- zval_ptr_dtor(return_value);
- RETURN_NULL();
- }
} else if (ZEND_NUM_ARGS()) {
zend_throw_exception_ex(reflection_exception_ptr, 0, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ZSTR_VAL(ce->name));
}
}
/* }}} */
-/* {{{ proto public object ReflectionClass::newInstanceWithoutConstructor()
- Returns an instance of this class without invoking its constructor */
-ZEND_METHOD(reflection_class, newInstanceWithoutConstructor)
+/* {{{ Returns an instance of this class without invoking its constructor */
+ZEND_METHOD(ReflectionClass, newInstanceWithoutConstructor)
{
reflection_object *intern;
zend_class_entry *ce;
GET_REFLECTION_OBJECT_PTR(ce);
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
if (ce->type == ZEND_INTERNAL_CLASS
&& ce->create_object != NULL && (ce->ce_flags & ZEND_ACC_FINAL)) {
zend_throw_exception_ex(reflection_exception_ptr, 0, "Class %s is an internal class marked as final that cannot be instantiated without invoking its constructor", ZSTR_VAL(ce->name));
- return;
+ RETURN_THROWS();
}
object_init_ex(return_value, ce);
}
/* }}} */
-/* {{{ proto public object ReflectionClass::newInstanceArgs([array args])
- Returns an instance of this class */
-ZEND_METHOD(reflection_class, newInstanceArgs)
+/* {{{ Returns an instance of this class */
+ZEND_METHOD(ReflectionClass, newInstanceArgs)
{
- zval retval, *val;
reflection_object *intern;
zend_class_entry *ce, *old_scope;
- int ret, i, argc = 0;
- HashTable *args;
+ int argc = 0;
+ HashTable *args = NULL;
zend_function *constructor;
GET_REFLECTION_OBJECT_PTR(ce);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|h", &args) == FAILURE) {
- return;
+ RETURN_THROWS();
}
- if (ZEND_NUM_ARGS() > 0) {
- argc = args->nNumOfElements;
+ if (args) {
+ argc = zend_hash_num_elements(args);
}
if (UNEXPECTED(object_init_ex(return_value, ce) != SUCCESS)) {
@@ -4788,70 +4775,32 @@ ZEND_METHOD(reflection_class, newInstanceArgs)
/* Run the constructor if there is one */
if (constructor) {
- zval *params = NULL;
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
-
if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) {
zend_throw_exception_ex(reflection_exception_ptr, 0, "Access to non-public constructor of class %s", ZSTR_VAL(ce->name));
zval_ptr_dtor(return_value);
RETURN_NULL();
}
- if (argc) {
- params = safe_emalloc(sizeof(zval), argc, 0);
- argc = 0;
- ZEND_HASH_FOREACH_VAL(args, val) {
- ZVAL_COPY(&params[argc], val);
- argc++;
- } ZEND_HASH_FOREACH_END();
- }
-
- fci.size = sizeof(fci);
- ZVAL_UNDEF(&fci.function_name);
- fci.object = Z_OBJ_P(return_value);
- fci.retval = &retval;
- fci.param_count = argc;
- fci.params = params;
- fci.no_separation = 1;
-
- fcc.function_handler = constructor;
- fcc.called_scope = Z_OBJCE_P(return_value);
- fcc.object = Z_OBJ_P(return_value);
-
- ret = zend_call_function(&fci, &fcc);
- zval_ptr_dtor(&retval);
- if (params) {
- for (i = 0; i < argc; i++) {
- zval_ptr_dtor(&params[i]);
- }
- efree(params);
- }
+ zend_call_known_function(
+ constructor, Z_OBJ_P(return_value), Z_OBJCE_P(return_value), NULL, 0, NULL, args);
if (EG(exception)) {
zend_object_store_ctor_failed(Z_OBJ_P(return_value));
}
- if (ret == FAILURE) {
- zval_ptr_dtor(&retval);
- php_error_docref(NULL, E_WARNING, "Invocation of %s's constructor failed", ZSTR_VAL(ce->name));
- zval_ptr_dtor(return_value);
- RETURN_NULL();
- }
} else if (argc) {
zend_throw_exception_ex(reflection_exception_ptr, 0, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ZSTR_VAL(ce->name));
}
}
/* }}} */
-/* {{{ proto public ReflectionClass[] ReflectionClass::getInterfaces()
- Returns an array of interfaces this class implements */
-ZEND_METHOD(reflection_class, getInterfaces)
+/* {{{ Returns an array of interfaces this class implements */
+ZEND_METHOD(ReflectionClass, getInterfaces)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -4871,16 +4820,15 @@ ZEND_METHOD(reflection_class, getInterfaces)
}
/* }}} */
-/* {{{ proto public String[] ReflectionClass::getInterfaceNames()
- Returns an array of names of interfaces this class implements */
-ZEND_METHOD(reflection_class, getInterfaceNames)
+/* {{{ Returns an array of names of interfaces this class implements */
+ZEND_METHOD(ReflectionClass, getInterfaceNames)
{
reflection_object *intern;
zend_class_entry *ce;
uint32_t i;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -4898,16 +4846,15 @@ ZEND_METHOD(reflection_class, getInterfaceNames)
}
/* }}} */
-/* {{{ proto public ReflectionClass[] ReflectionClass::getTraits()
- Returns an array of traits used by this class */
-ZEND_METHOD(reflection_class, getTraits)
+/* {{{ Returns an array of traits used by this class */
+ZEND_METHOD(ReflectionClass, getTraits)
{
reflection_object *intern;
zend_class_entry *ce;
uint32_t i;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -4930,16 +4877,15 @@ ZEND_METHOD(reflection_class, getTraits)
}
/* }}} */
-/* {{{ proto public String[] ReflectionClass::getTraitNames()
- Returns an array of names of traits used by this class */
-ZEND_METHOD(reflection_class, getTraitNames)
+/* {{{ Returns an array of names of traits used by this class */
+ZEND_METHOD(ReflectionClass, getTraitNames)
{
reflection_object *intern;
zend_class_entry *ce;
uint32_t i;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -4955,15 +4901,14 @@ ZEND_METHOD(reflection_class, getTraitNames)
}
/* }}} */
-/* {{{ proto public array ReflectionClass::getTraitAliases()
- Returns an array of trait aliases */
-ZEND_METHOD(reflection_class, getTraitAliases)
+/* {{{ Returns an array of trait aliases */
+ZEND_METHOD(ReflectionClass, getTraitAliases)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -4990,15 +4935,14 @@ ZEND_METHOD(reflection_class, getTraitAliases)
}
/* }}} */
-/* {{{ proto public ReflectionClass ReflectionClass::getParentClass()
- Returns the class' parent class, or, if none exists, FALSE */
-ZEND_METHOD(reflection_class, getParentClass)
+/* {{{ Returns the class' parent class, or, if none exists, FALSE */
+ZEND_METHOD(ReflectionClass, getParentClass)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -5010,106 +4954,85 @@ ZEND_METHOD(reflection_class, getParentClass)
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::isSubclassOf(string|ReflectionClass class)
- Returns whether this class is a subclass of another class */
-ZEND_METHOD(reflection_class, isSubclassOf)
+/* {{{ Returns whether this class is a subclass of another class */
+ZEND_METHOD(ReflectionClass, isSubclassOf)
{
reflection_object *intern, *argument;
zend_class_entry *ce, *class_ce;
- zval *class_name;
+ zend_string *class_str;
+ zend_object *class_obj;
- GET_REFLECTION_OBJECT_PTR(ce);
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJ_OF_CLASS_OR_STR(class_obj, reflection_class_ptr, class_str)
+ ZEND_PARSE_PARAMETERS_END();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &class_name) == FAILURE) {
- return;
- }
+ if (class_obj) {
+ argument = reflection_object_from_obj(class_obj);
+ if (argument->ptr == NULL) {
+ zend_throw_error(NULL, "Internal error: Failed to retrieve the argument's reflection object");
+ RETURN_THROWS();
+ }
- switch (Z_TYPE_P(class_name)) {
- case IS_STRING:
- if ((class_ce = zend_lookup_class(Z_STR_P(class_name))) == NULL) {
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Class %s does not exist", Z_STRVAL_P(class_name));
- return;
- }
- break;
- case IS_OBJECT:
- if (instanceof_function(Z_OBJCE_P(class_name), reflection_class_ptr)) {
- argument = Z_REFLECTION_P(class_name);
- if (argument->ptr == NULL) {
- zend_throw_error(NULL, "Internal error: Failed to retrieve the argument's reflection object");
- return;
- }
- class_ce = argument->ptr;
- break;
- }
- /* no break */
- default:
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Parameter one must either be a string or a ReflectionClass object");
- return;
+ class_ce = argument->ptr;
+ } else {
+ if ((class_ce = zend_lookup_class(class_str)) == NULL) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0, "Class \"%s\" does not exist", ZSTR_VAL(class_str));
+ RETURN_THROWS();
+ }
}
+ GET_REFLECTION_OBJECT_PTR(ce);
+
RETURN_BOOL((ce != class_ce && instanceof_function(ce, class_ce)));
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::implementsInterface(string|ReflectionClass interface_name)
- Returns whether this class is a subclass of another class */
-ZEND_METHOD(reflection_class, implementsInterface)
+/* {{{ Returns whether this class is a subclass of another class */
+ZEND_METHOD(ReflectionClass, implementsInterface)
{
reflection_object *intern, *argument;
+ zend_string *interface_str;
zend_class_entry *ce, *interface_ce;
- zval *interface;
+ zend_object *interface_obj;
- GET_REFLECTION_OBJECT_PTR(ce);
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJ_OF_CLASS_OR_STR(interface_obj, reflection_class_ptr, interface_str)
+ ZEND_PARSE_PARAMETERS_END();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &interface) == FAILURE) {
- return;
- }
+ if (interface_obj) {
+ argument = reflection_object_from_obj(interface_obj);
+ if (argument->ptr == NULL) {
+ zend_throw_error(NULL, "Internal error: Failed to retrieve the argument's reflection object");
+ RETURN_THROWS();
+ }
- switch (Z_TYPE_P(interface)) {
- case IS_STRING:
- if ((interface_ce = zend_lookup_class(Z_STR_P(interface))) == NULL) {
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Interface %s does not exist", Z_STRVAL_P(interface));
- return;
- }
- break;
- case IS_OBJECT:
- if (instanceof_function(Z_OBJCE_P(interface), reflection_class_ptr)) {
- argument = Z_REFLECTION_P(interface);
- if (argument->ptr == NULL) {
- zend_throw_error(NULL, "Internal error: Failed to retrieve the argument's reflection object");
- return;
- }
- interface_ce = argument->ptr;
- break;
- }
- /* no break */
- default:
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Parameter one must either be a string or a ReflectionClass object");
- return;
+ interface_ce = argument->ptr;
+ } else {
+ if ((interface_ce = zend_lookup_class(interface_str)) == NULL) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0, "Interface \"%s\" does not exist", ZSTR_VAL(interface_str));
+ RETURN_THROWS();
+ }
}
if (!(interface_ce->ce_flags & ZEND_ACC_INTERFACE)) {
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "%s is not an interface", ZSTR_VAL(interface_ce->name));
- return;
+ zend_throw_exception_ex(reflection_exception_ptr, 0, "%s is not an interface", ZSTR_VAL(interface_ce->name));
+ RETURN_THROWS();
}
+
+ GET_REFLECTION_OBJECT_PTR(ce);
+
RETURN_BOOL(instanceof_function(ce, interface_ce));
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::isIterable()
- Returns whether this class is iterable (can be used inside foreach) */
-ZEND_METHOD(reflection_class, isIterable)
+/* {{{ Returns whether this class is iterable (can be used inside foreach) */
+ZEND_METHOD(ReflectionClass, isIterable)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -5123,15 +5046,14 @@ ZEND_METHOD(reflection_class, isIterable)
}
/* }}} */
-/* {{{ proto public ReflectionExtension|NULL ReflectionClass::getExtension()
- Returns NULL or the extension the class belongs to */
-ZEND_METHOD(reflection_class, getExtension)
+/* {{{ Returns NULL or the extension the class belongs to */
+ZEND_METHOD(ReflectionClass, getExtension)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -5142,15 +5064,14 @@ ZEND_METHOD(reflection_class, getExtension)
}
/* }}} */
-/* {{{ proto public string|false ReflectionClass::getExtensionName()
- Returns false or the name of the extension the class belongs to */
-ZEND_METHOD(reflection_class, getExtensionName)
+/* {{{ Returns false or the name of the extension the class belongs to */
+ZEND_METHOD(ReflectionClass, getExtensionName)
{
reflection_object *intern;
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ce);
@@ -5163,112 +5084,78 @@ ZEND_METHOD(reflection_class, getExtensionName)
}
/* }}} */
-/* {{{ proto public bool ReflectionClass::inNamespace()
- Returns whether this class is defined in namespace */
-ZEND_METHOD(reflection_class, inNamespace)
+/* {{{ Returns whether this class is defined in namespace */
+ZEND_METHOD(ReflectionClass, inNamespace)
{
- zval *name;
- const char *backslash;
+ reflection_object *intern;
+ zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
- if ((name = _default_load_name(ZEND_THIS)) == NULL) {
- RETURN_FALSE;
- }
- if (Z_TYPE_P(name) == IS_STRING
- && (backslash = zend_memrchr(Z_STRVAL_P(name), '\\', Z_STRLEN_P(name)))
- && backslash > Z_STRVAL_P(name))
- {
- RETURN_TRUE;
+ RETURN_THROWS();
}
- RETURN_FALSE;
+
+ GET_REFLECTION_OBJECT_PTR(ce);
+
+ zend_string *name = ce->name;
+ const char *backslash = zend_memrchr(ZSTR_VAL(name), '\\', ZSTR_LEN(name));
+ RETURN_BOOL(backslash && backslash > ZSTR_VAL(name));
}
/* }}} */
-/* {{{ proto public string ReflectionClass::getNamespaceName()
- Returns the name of namespace where this class is defined */
-ZEND_METHOD(reflection_class, getNamespaceName)
+/* {{{ Returns the name of namespace where this class is defined */
+ZEND_METHOD(ReflectionClass, getNamespaceName)
{
- zval *name;
- const char *backslash;
+ reflection_object *intern;
+ zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
- if ((name = _default_load_name(ZEND_THIS)) == NULL) {
- RETURN_FALSE;
+ RETURN_THROWS();
}
- if (Z_TYPE_P(name) == IS_STRING
- && (backslash = zend_memrchr(Z_STRVAL_P(name), '\\', Z_STRLEN_P(name)))
- && backslash > Z_STRVAL_P(name))
- {
- RETURN_STRINGL(Z_STRVAL_P(name), backslash - Z_STRVAL_P(name));
+
+ GET_REFLECTION_OBJECT_PTR(ce);
+
+ zend_string *name = ce->name;
+ const char *backslash = zend_memrchr(ZSTR_VAL(name), '\\', ZSTR_LEN(name));
+ if (backslash && backslash > ZSTR_VAL(name)) {
+ RETURN_STRINGL(ZSTR_VAL(name), backslash - ZSTR_VAL(name));
}
RETURN_EMPTY_STRING();
}
/* }}} */
-/* {{{ proto public string ReflectionClass::getShortName()
- Returns the short name of the class (without namespace part) */
-ZEND_METHOD(reflection_class, getShortName)
+/* {{{ Returns the short name of the class (without namespace part) */
+ZEND_METHOD(ReflectionClass, getShortName)
{
- zval *name;
- const char *backslash;
+ reflection_object *intern;
+ zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
- if ((name = _default_load_name(ZEND_THIS)) == NULL) {
- RETURN_FALSE;
- }
- if (Z_TYPE_P(name) == IS_STRING
- && (backslash = zend_memrchr(Z_STRVAL_P(name), '\\', Z_STRLEN_P(name)))
- && backslash > Z_STRVAL_P(name))
- {
- RETURN_STRINGL(backslash + 1, Z_STRLEN_P(name) - (backslash - Z_STRVAL_P(name) + 1));
+ RETURN_THROWS();
}
- ZVAL_COPY_DEREF(return_value, name);
-}
-/* }}} */
-
-/* {{{ proto public static mixed ReflectionObject::export(mixed argument [, bool return]) throws ReflectionException
- Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
-ZEND_METHOD(reflection_object, export)
-{
- _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_object_ptr, 1);
-}
-/* }}} */
-/* {{{ proto public void ReflectionObject::__construct(mixed argument) throws ReflectionException
- Constructor. Takes an instance as an argument */
-ZEND_METHOD(reflection_object, __construct)
-{
- reflection_class_object_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
+ GET_REFLECTION_OBJECT_PTR(ce);
-/* {{{ proto public static mixed ReflectionProperty::export(mixed class, string name [, bool return]) throws ReflectionException
- Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
-ZEND_METHOD(reflection_property, export)
-{
- _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_property_ptr, 2);
+ zend_string *name = ce->name;
+ const char *backslash = zend_memrchr(ZSTR_VAL(name), '\\', ZSTR_LEN(name));
+ if (backslash && backslash > ZSTR_VAL(name)) {
+ RETURN_STRINGL(backslash + 1, ZSTR_LEN(name) - (backslash - ZSTR_VAL(name) + 1));
+ }
+ RETURN_STR_COPY(name);
}
/* }}} */
-/* {{{ proto public static mixed ReflectionClassConstant::export(mixed class, string name [, bool return]) throws ReflectionException
- Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
-ZEND_METHOD(reflection_class_constant, export)
+/* {{{ Constructor. Takes an instance as an argument */
+ZEND_METHOD(ReflectionObject, __construct)
{
- _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_class_constant_ptr, 2);
+ reflection_class_object_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
/* }}} */
-/* {{{ proto public void ReflectionProperty::__construct(mixed class, string name)
- Constructor. Throws an Exception in case the given property does not exist */
-ZEND_METHOD(reflection_property, __construct)
+/* {{{ Constructor. Throws an Exception in case the given property does not exist */
+ZEND_METHOD(ReflectionProperty, __construct)
{
- zval *classname;
+ zend_string *classname_str;
+ zend_object *classname_obj;
zend_string *name;
int dynam_prop = 0;
zval *object;
@@ -5277,30 +5164,21 @@ ZEND_METHOD(reflection_property, __construct)
zend_property_info *property_info = NULL;
property_reference *reference;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "zS", &classname, &name) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJ_OR_STR(classname_obj, classname_str)
+ Z_PARAM_STR(name)
+ ZEND_PARSE_PARAMETERS_END();
object = ZEND_THIS;
intern = Z_REFLECTION_P(object);
- /* Find the class entry */
- switch (Z_TYPE_P(classname)) {
- case IS_STRING:
- if ((ce = zend_lookup_class(Z_STR_P(classname))) == NULL) {
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Class %s does not exist", Z_STRVAL_P(classname));
- return;
- }
- break;
-
- case IS_OBJECT:
- ce = Z_OBJCE_P(classname);
- break;
-
- default:
- _DO_THROW("The parameter class is expected to be either a string or an object");
- return;
+ if (classname_obj) {
+ ce = classname_obj->ce;
+ } else {
+ if ((ce = zend_lookup_class(classname_str)) == NULL) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0, "Class \"%s\" does not exist", ZSTR_VAL(classname_str));
+ RETURN_THROWS();
+ }
}
property_info = zend_hash_find_ptr(&ce->properties_info, name);
@@ -5308,26 +5186,14 @@ ZEND_METHOD(reflection_property, __construct)
|| ((property_info->flags & ZEND_ACC_PRIVATE)
&& property_info->ce != ce)) {
/* Check for dynamic properties */
- if (property_info == NULL && Z_TYPE_P(classname) == IS_OBJECT) {
- if (zend_hash_exists(Z_OBJ_HT_P(classname)->get_properties(classname), name)) {
+ if (property_info == NULL && classname_obj) {
+ if (zend_hash_exists(classname_obj->handlers->get_properties(classname_obj), name)) {
dynam_prop = 1;
}
}
if (dynam_prop == 0) {
zend_throw_exception_ex(reflection_exception_ptr, 0, "Property %s::$%s does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(name));
- return;
- }
- }
-
- if (dynam_prop == 0 && (property_info->flags & ZEND_ACC_PRIVATE) == 0) {
- /* we have to search the class hierarchy for this (implicit) public or protected property */
- zend_class_entry *tmp_ce = ce;
- zend_property_info *tmp_info;
-
- while (tmp_ce && (tmp_info = zend_hash_find_ptr(&tmp_ce->properties_info, name)) == NULL) {
- ce = tmp_ce;
- property_info = tmp_info;
- tmp_ce = tmp_ce->parent;
+ RETURN_THROWS();
}
}
@@ -5339,21 +5205,7 @@ ZEND_METHOD(reflection_property, __construct)
}
reference = (property_reference*) emalloc(sizeof(property_reference));
- if (dynam_prop) {
- reference->prop.flags = ZEND_ACC_PUBLIC;
- reference->prop.name = name;
- reference->prop.doc_comment = NULL;
- reference->prop.ce = ce;
- reference->prop.type = 0;
- reference->dynamic = 1;
- } else {
- reference->prop = *property_info;
- reference->dynamic = 0;
-
- if (ZEND_TYPE_IS_NAME(reference->prop.type)) {
- zend_string_addref(ZEND_TYPE_NAME(reference->prop.type));
- }
- }
+ reference->prop = dynam_prop ? NULL : property_info;
reference->unmangled_name = zend_string_copy(name);
intern->ptr = reference;
intern->ref_type = REF_TYPE_PROPERTY;
@@ -5362,31 +5214,34 @@ ZEND_METHOD(reflection_property, __construct)
}
/* }}} */
-/* {{{ proto public string ReflectionProperty::__toString()
- Returns a string representation */
-ZEND_METHOD(reflection_property, __toString)
+/* {{{ Returns a string representation */
+ZEND_METHOD(ReflectionProperty, __toString)
{
reflection_object *intern;
property_reference *ref;
smart_str str = {0};
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
- _property_string(&str, &ref->prop, ZSTR_VAL(ref->unmangled_name), "", ref->dynamic);
+ _property_string(&str, ref->prop, ZSTR_VAL(ref->unmangled_name), "");
RETURN_STR(smart_str_extract(&str));
}
/* }}} */
-/* {{{ proto public string ReflectionProperty::getName()
- Returns the class' name */
-ZEND_METHOD(reflection_property, getName)
+/* {{{ Returns the class' name */
+ZEND_METHOD(ReflectionProperty, getName)
{
+ reflection_object *intern;
+ property_reference *ref;
+
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
- _default_get_name(ZEND_THIS, return_value);
+
+ GET_REFLECTION_OBJECT_PTR(ref);
+ RETURN_STR_COPY(ref->unmangled_name);
}
/* }}} */
@@ -5396,96 +5251,100 @@ static void _property_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) /* {{{
property_reference *ref;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
- RETURN_BOOL(ref->prop.flags & mask);
+ RETURN_BOOL(prop_get_flags(ref) & mask);
}
/* }}} */
-/* {{{ proto public bool ReflectionProperty::isPublic()
- Returns whether this property is public */
-ZEND_METHOD(reflection_property, isPublic)
+/* {{{ Returns whether this property is public */
+ZEND_METHOD(ReflectionProperty, isPublic)
{
_property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC);
}
/* }}} */
-/* {{{ proto public bool ReflectionProperty::isPrivate()
- Returns whether this property is private */
-ZEND_METHOD(reflection_property, isPrivate)
+/* {{{ Returns whether this property is private */
+ZEND_METHOD(ReflectionProperty, isPrivate)
{
_property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PRIVATE);
}
/* }}} */
-/* {{{ proto public bool ReflectionProperty::isProtected()
- Returns whether this property is protected */
-ZEND_METHOD(reflection_property, isProtected)
+/* {{{ Returns whether this property is protected */
+ZEND_METHOD(ReflectionProperty, isProtected)
{
_property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PROTECTED);
}
/* }}} */
-/* {{{ proto public bool ReflectionProperty::isStatic()
- Returns whether this property is static */
-ZEND_METHOD(reflection_property, isStatic)
+/* {{{ Returns whether this property is static */
+ZEND_METHOD(ReflectionProperty, isStatic)
{
_property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_STATIC);
}
/* }}} */
-/* {{{ proto public bool ReflectionProperty::isDefault()
- Returns whether this property is default (declared at compilation time). */
-ZEND_METHOD(reflection_property, isDefault)
+/* {{{ Returns whether this property is default (declared at compilation time). */
+ZEND_METHOD(ReflectionProperty, isDefault)
{
reflection_object *intern;
property_reference *ref;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
- RETURN_BOOL(!ref->dynamic);
+ RETURN_BOOL(ref->prop != NULL);
}
/* }}} */
-/* {{{ proto public int ReflectionProperty::getModifiers()
- Returns a bitfield of the access modifiers for this property */
-ZEND_METHOD(reflection_property, getModifiers)
+/* {{{ Returns whether this property has been promoted from a constructor */
+ZEND_METHOD(ReflectionProperty, isPromoted)
+{
+ _property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PROMOTED);
+}
+/* }}} */
+
+/* {{{ Returns a bitfield of the access modifiers for this property */
+ZEND_METHOD(ReflectionProperty, getModifiers)
{
reflection_object *intern;
property_reference *ref;
uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
- RETURN_LONG((ref->prop.flags & keep_flags));
+ RETURN_LONG(prop_get_flags(ref) & keep_flags);
}
/* }}} */
-/* {{{ proto public mixed ReflectionProperty::getValue([stdclass object])
- Returns this property's value */
-ZEND_METHOD(reflection_property, getValue)
+/* {{{ Returns this property's value */
+ZEND_METHOD(ReflectionProperty, getValue)
{
reflection_object *intern;
property_reference *ref;
- zval *object, *name;
+ zval *object = NULL;
zval *member_p = NULL;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|o!", &object) == FAILURE) {
+ RETURN_THROWS();
+ }
+
GET_REFLECTION_OBJECT_PTR(ref);
- if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
- name = _default_load_name(ZEND_THIS);
+ if (!(prop_get_flags(ref) & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Cannot access non-public member %s::$%s", ZSTR_VAL(intern->ce->name), Z_STRVAL_P(name));
- return;
+ "Cannot access non-public property %s::$%s",
+ ZSTR_VAL(intern->ce->name), ZSTR_VAL(ref->unmangled_name));
+ RETURN_THROWS();
}
- if (ref->prop.flags & ZEND_ACC_STATIC) {
+ if (prop_get_flags(ref) & ZEND_ACC_STATIC) {
member_p = zend_read_static_property_ex(intern->ce, ref->unmangled_name, 0);
if (member_p) {
ZVAL_COPY_DEREF(return_value, member_p);
@@ -5493,16 +5352,18 @@ ZEND_METHOD(reflection_property, getValue)
} else {
zval rv;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &object) == FAILURE) {
- return;
+ if (!object) {
+ zend_argument_type_error(1, "must be provided for instance properties");
+ RETURN_THROWS();
}
- if (!instanceof_function(Z_OBJCE_P(object), ref->prop.ce)) {
+ /* TODO: Should this always use intern->ce? */
+ if (!instanceof_function(Z_OBJCE_P(object), ref->prop ? ref->prop->ce : intern->ce)) {
_DO_THROW("Given object is not an instance of the class this property was declared in");
- return;
+ RETURN_THROWS();
}
- member_p = zend_read_property_ex(intern->ce, object, ref->unmangled_name, 0, &rv);
+ member_p = zend_read_property_ex(intern->ce, Z_OBJ_P(object), ref->unmangled_name, 0, &rv);
if (member_p != &rv) {
ZVAL_COPY_DEREF(return_value, member_p);
} else {
@@ -5515,85 +5376,87 @@ ZEND_METHOD(reflection_property, getValue)
}
/* }}} */
-/* {{{ proto public void ReflectionProperty::setValue([stdclass object,] mixed value)
- Sets this property's value */
-ZEND_METHOD(reflection_property, setValue)
+/* {{{ Sets this property's value */
+ZEND_METHOD(ReflectionProperty, setValue)
{
reflection_object *intern;
property_reference *ref;
- zval *object, *name;
+ zval *object;
zval *value;
zval *tmp;
GET_REFLECTION_OBJECT_PTR(ref);
- if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
- name = _default_load_name(ZEND_THIS);
+ if (!(prop_get_flags(ref) & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Cannot access non-public member %s::$%s", ZSTR_VAL(intern->ce->name), Z_STRVAL_P(name));
- return;
+ "Cannot access non-public property %s::$%s",
+ ZSTR_VAL(intern->ce->name), ZSTR_VAL(ref->unmangled_name));
+ RETURN_THROWS();
}
- if (ref->prop.flags & ZEND_ACC_STATIC) {
+ if (prop_get_flags(ref) & ZEND_ACC_STATIC) {
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "z", &value) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &tmp, &value) == FAILURE) {
- return;
+ RETURN_THROWS();
}
}
zend_update_static_property_ex(intern->ce, ref->unmangled_name, value);
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "oz", &object, &value) == FAILURE) {
- return;
+ RETURN_THROWS();
}
- zend_update_property_ex(intern->ce, object, ref->unmangled_name, value);
+ zend_update_property_ex(intern->ce, Z_OBJ_P(object), ref->unmangled_name, value);
}
}
/* }}} */
-/* {{{ proto public mixed ReflectionProperty::isInitialized([stdclass object])
- Returns this property's value */
-ZEND_METHOD(reflection_property, isInitialized)
+/* {{{ Returns this property's value */
+ZEND_METHOD(ReflectionProperty, isInitialized)
{
reflection_object *intern;
property_reference *ref;
- zval *object, *name;
+ zval *object = NULL;
zval *member_p = NULL;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|o!", &object) == FAILURE) {
+ RETURN_THROWS();
+ }
+
GET_REFLECTION_OBJECT_PTR(ref);
- if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
- name = _default_load_name(getThis());
+ if (!(prop_get_flags(ref) & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Cannot access non-public member %s::$%s", ZSTR_VAL(intern->ce->name), Z_STRVAL_P(name));
- return;
+ "Cannot access non-public property %s::$%s",
+ ZSTR_VAL(intern->ce->name), ZSTR_VAL(ref->unmangled_name));
+ RETURN_THROWS();
}
- if (ref->prop.flags & ZEND_ACC_STATIC) {
+ if (prop_get_flags(ref) & ZEND_ACC_STATIC) {
member_p = zend_read_static_property_ex(intern->ce, ref->unmangled_name, 1);
if (member_p) {
- RETURN_BOOL(!Z_ISUNDEF_P(member_p))
+ RETURN_BOOL(!Z_ISUNDEF_P(member_p));
}
RETURN_FALSE;
} else {
- zval name_zv;
zend_class_entry *old_scope;
int retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &object) == FAILURE) {
- return;
+ if (!object) {
+ zend_argument_type_error(1, "must be provided for instance properties");
+ RETURN_THROWS();
}
- if (!instanceof_function(Z_OBJCE_P(object), ref->prop.ce)) {
+ /* TODO: Should this always use intern->ce? */
+ if (!instanceof_function(Z_OBJCE_P(object), ref->prop ? ref->prop->ce : intern->ce)) {
_DO_THROW("Given object is not an instance of the class this property was declared in");
- return;
+ RETURN_THROWS();
}
old_scope = EG(fake_scope);
EG(fake_scope) = intern->ce;
- ZVAL_STR(&name_zv, ref->unmangled_name);
- retval = Z_OBJ_HT_P(object)->has_property(object, &name_zv, ZEND_PROPERTY_EXISTS, NULL);
+ retval = Z_OBJ_HT_P(object)->has_property(Z_OBJ_P(object), ref->unmangled_name, ZEND_PROPERTY_EXISTS, NULL);
EG(fake_scope) = old_scope;
RETVAL_BOOL(retval);
@@ -5601,65 +5464,66 @@ ZEND_METHOD(reflection_property, isInitialized)
}
/* }}} */
-/* {{{ proto public ReflectionClass ReflectionProperty::getDeclaringClass()
- Get the declaring class */
-ZEND_METHOD(reflection_property, getDeclaringClass)
+/* {{{ Get the declaring class */
+ZEND_METHOD(ReflectionProperty, getDeclaringClass)
{
reflection_object *intern;
property_reference *ref;
- zend_class_entry *tmp_ce, *ce;
- zend_property_info *tmp_info;
+ zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
- ce = tmp_ce = intern->ce;
- while (tmp_ce && (tmp_info = zend_hash_find_ptr(&tmp_ce->properties_info, ref->unmangled_name)) != NULL) {
- if (tmp_info->flags & ZEND_ACC_PRIVATE) {
- /* it's a private property, so it can't be inherited */
- break;
- }
- ce = tmp_ce;
- if (tmp_ce == tmp_info->ce) {
- /* declared in this class, done */
- break;
- }
- tmp_ce = tmp_ce->parent;
- }
-
+ ce = ref->prop ? ref->prop->ce : intern->ce;
zend_reflection_class_factory(ce, return_value);
}
/* }}} */
-/* {{{ proto public string ReflectionProperty::getDocComment()
- Returns the doc comment for this property */
-ZEND_METHOD(reflection_property, getDocComment)
+/* {{{ Returns the doc comment for this property */
+ZEND_METHOD(ReflectionProperty, getDocComment)
{
reflection_object *intern;
property_reference *ref;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
- if (ref->prop.doc_comment) {
- RETURN_STR_COPY(ref->prop.doc_comment);
+ if (ref->prop && ref->prop->doc_comment) {
+ RETURN_STR_COPY(ref->prop->doc_comment);
}
RETURN_FALSE;
}
/* }}} */
-/* {{{ proto public int ReflectionProperty::setAccessible(bool visible)
- Sets whether non-public properties can be requested */
-ZEND_METHOD(reflection_property, setAccessible)
+/* {{{ Returns the attributes of this property */
+ZEND_METHOD(ReflectionProperty, getAttributes)
+{
+ reflection_object *intern;
+ property_reference *ref;
+
+ GET_REFLECTION_OBJECT_PTR(ref);
+
+ if (ref->prop == NULL) {
+ RETURN_EMPTY_ARRAY();
+ }
+
+ reflect_attributes(INTERNAL_FUNCTION_PARAM_PASSTHRU,
+ ref->prop->attributes, 0, ref->prop->ce, ZEND_ATTRIBUTE_TARGET_PROPERTY,
+ ref->prop->ce->type == ZEND_USER_CLASS ? ref->prop->ce->info.user.filename : NULL);
+}
+/* }}} */
+
+/* {{{ Sets whether non-public properties can be requested */
+ZEND_METHOD(ReflectionProperty, setAccessible)
{
reflection_object *intern;
zend_bool visible;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &visible) == FAILURE) {
- return;
+ RETURN_THROWS();
}
intern = Z_REFLECTION_P(ZEND_THIS);
@@ -5668,55 +5532,108 @@ ZEND_METHOD(reflection_property, setAccessible)
}
/* }}} */
-/* {{{ proto public ReflectionType ReflectionProperty::getType()
- Returns the type associated with the property */
-ZEND_METHOD(reflection_property, getType)
+/* {{{ Returns the type associated with the property */
+ZEND_METHOD(ReflectionProperty, getType)
{
reflection_object *intern;
property_reference *ref;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
- if (!ZEND_TYPE_IS_SET(ref->prop.type)) {
+ if (!ref->prop || !ZEND_TYPE_IS_SET(ref->prop->type)) {
RETURN_NULL();
}
- reflection_type_factory(ref->prop.type, return_value);
+ reflection_type_factory(ref->prop->type, return_value, 1);
}
/* }}} */
-/* {{{ proto public bool ReflectionProperty::hasType()
- Returns whether property has a type */
-ZEND_METHOD(reflection_property, hasType)
+/* {{{ Returns whether property has a type */
+ZEND_METHOD(ReflectionProperty, hasType)
{
reflection_object *intern;
property_reference *ref;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(ref);
- RETVAL_BOOL(ZEND_TYPE_IS_SET(ref->prop.type));
+ RETVAL_BOOL(ref->prop && ZEND_TYPE_IS_SET(ref->prop->type));
}
/* }}} */
-/* {{{ proto public static mixed ReflectionExtension::export(string name [, bool return]) throws ReflectionException
- Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
-ZEND_METHOD(reflection_extension, export)
+/* {{{ Returns whether property has a default value */
+ZEND_METHOD(ReflectionProperty, hasDefaultValue)
{
- _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_extension_ptr, 1);
+ reflection_object *intern;
+ property_reference *ref;
+ zend_property_info *prop_info;
+ zval *prop;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ GET_REFLECTION_OBJECT_PTR(ref);
+
+ prop_info = ref->prop;
+
+ if (prop_info == NULL) {
+ RETURN_FALSE;
+ }
+
+ prop = property_get_default(prop_info);
+ RETURN_BOOL(!Z_ISUNDEF_P(prop));
}
/* }}} */
-/* {{{ proto public void ReflectionExtension::__construct(string name)
- Constructor. Throws an Exception in case the given extension does not exist */
-ZEND_METHOD(reflection_extension, __construct)
+/* {{{ Returns the default value of a property */
+ZEND_METHOD(ReflectionProperty, getDefaultValue)
+{
+ reflection_object *intern;
+ property_reference *ref;
+ zend_property_info *prop_info;
+ zval *prop;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ GET_REFLECTION_OBJECT_PTR(ref);
+
+ prop_info = ref->prop;
+
+ if (prop_info == NULL) {
+ return; // throw exception?
+ }
+
+ prop = property_get_default(prop_info);
+ if (Z_ISUNDEF_P(prop)) {
+ return;
+ }
+
+ /* copy: enforce read only access */
+ ZVAL_DEREF(prop);
+ ZVAL_COPY_OR_DUP(return_value, prop);
+
+ /* this is necessary to make it able to work with default array
+ * properties, returned to user */
+ if (Z_TYPE_P(return_value) == IS_CONSTANT_AST) {
+ if (UNEXPECTED(zval_update_constant_ex(return_value, prop_info->ce) != SUCCESS)) {
+ RETURN_THROWS();
+ }
+ }
+}
+/* }}} */
+
+/* {{{ Constructor. Throws an Exception in case the given extension does not exist */
+ZEND_METHOD(ReflectionExtension, __construct)
{
zval *object;
char *lcname;
@@ -5726,8 +5643,8 @@ ZEND_METHOD(reflection_extension, __construct)
size_t name_len;
ALLOCA_FLAG(use_heap)
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
- return;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
+ RETURN_THROWS();
}
object = ZEND_THIS;
@@ -5737,8 +5654,8 @@ ZEND_METHOD(reflection_extension, __construct)
if ((module = zend_hash_str_find_ptr(&module_registry, lcname, name_len)) == NULL) {
free_alloca(lcname, use_heap);
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Extension %s does not exist", name_str);
- return;
+ "Extension \"%s\" does not exist", name_str);
+ RETURN_THROWS();
}
free_alloca(lcname, use_heap);
ZVAL_STRING(reflection_prop_name(object), module->name);
@@ -5748,16 +5665,15 @@ ZEND_METHOD(reflection_extension, __construct)
}
/* }}} */
-/* {{{ proto public string ReflectionExtension::__toString()
- Returns a string representation */
-ZEND_METHOD(reflection_extension, __toString)
+/* {{{ Returns a string representation */
+ZEND_METHOD(ReflectionExtension, __toString)
{
reflection_object *intern;
zend_module_entry *module;
smart_str str = {0};
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(module);
_extension_string(&str, module, "");
@@ -5765,26 +5681,29 @@ ZEND_METHOD(reflection_extension, __toString)
}
/* }}} */
-/* {{{ proto public string ReflectionExtension::getName()
- Returns this extension's name */
-ZEND_METHOD(reflection_extension, getName)
+/* {{{ Returns this extension's name */
+ZEND_METHOD(ReflectionExtension, getName)
{
+ reflection_object *intern;
+ zend_module_entry *module;
+
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
- _default_get_name(ZEND_THIS, return_value);
+
+ GET_REFLECTION_OBJECT_PTR(module);
+ RETURN_STRING(module->name);
}
/* }}} */
-/* {{{ proto public string ReflectionExtension::getVersion()
- Returns this extension's version */
-ZEND_METHOD(reflection_extension, getVersion)
+/* {{{ Returns this extension's version */
+ZEND_METHOD(ReflectionExtension, getVersion)
{
reflection_object *intern;
zend_module_entry *module;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(module);
@@ -5797,9 +5716,8 @@ ZEND_METHOD(reflection_extension, getVersion)
}
/* }}} */
-/* {{{ proto public ReflectionFunction[] ReflectionExtension::getFunctions()
- Returns an array of this extension's functions */
-ZEND_METHOD(reflection_extension, getFunctions)
+/* {{{ Returns an array of this extension's functions */
+ZEND_METHOD(ReflectionExtension, getFunctions)
{
reflection_object *intern;
zend_module_entry *module;
@@ -5807,7 +5725,7 @@ ZEND_METHOD(reflection_extension, getFunctions)
zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(module);
@@ -5822,16 +5740,15 @@ ZEND_METHOD(reflection_extension, getFunctions)
}
/* }}} */
-/* {{{ proto public array ReflectionExtension::getConstants()
- Returns an associative array containing this extension's constants and their values */
-ZEND_METHOD(reflection_extension, getConstants)
+/* {{{ Returns an associative array containing this extension's constants and their values */
+ZEND_METHOD(ReflectionExtension, getConstants)
{
reflection_object *intern;
zend_module_entry *module;
zend_constant *constant;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(module);
@@ -5861,16 +5778,15 @@ static void _addinientry(zend_ini_entry *ini_entry, zval *retval, int number)
}
/* }}} */
-/* {{{ proto public array ReflectionExtension::getINIEntries()
- Returns an associative array containing this extension's INI entries and their values */
-ZEND_METHOD(reflection_extension, getINIEntries)
+/* {{{ Returns an associative array containing this extension's INI entries and their values */
+ZEND_METHOD(ReflectionExtension, getINIEntries)
{
reflection_object *intern;
zend_module_entry *module;
zend_ini_entry *ini_entry;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(module);
@@ -5905,9 +5821,8 @@ static void add_extension_class(zend_class_entry *ce, zend_string *key, zval *cl
}
/* }}} */
-/* {{{ proto public ReflectionClass[] ReflectionExtension::getClasses()
- Returns an array containing ReflectionClass objects for all classes of this extension */
-ZEND_METHOD(reflection_extension, getClasses)
+/* {{{ Returns an array containing ReflectionClass objects for all classes of this extension */
+ZEND_METHOD(ReflectionExtension, getClasses)
{
reflection_object *intern;
zend_module_entry *module;
@@ -5915,7 +5830,7 @@ ZEND_METHOD(reflection_extension, getClasses)
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(module);
@@ -5926,9 +5841,8 @@ ZEND_METHOD(reflection_extension, getClasses)
}
/* }}} */
-/* {{{ proto public array ReflectionExtension::getClassNames()
- Returns an array containing all names of all classes of this extension */
-ZEND_METHOD(reflection_extension, getClassNames)
+/* {{{ Returns an array containing all names of all classes of this extension */
+ZEND_METHOD(ReflectionExtension, getClassNames)
{
reflection_object *intern;
zend_module_entry *module;
@@ -5936,7 +5850,7 @@ ZEND_METHOD(reflection_extension, getClassNames)
zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(module);
@@ -5947,16 +5861,15 @@ ZEND_METHOD(reflection_extension, getClassNames)
}
/* }}} */
-/* {{{ proto public array ReflectionExtension::getDependencies()
- Returns an array containing all names of all extensions this extension depends on */
-ZEND_METHOD(reflection_extension, getDependencies)
+/* {{{ Returns an array containing all names of all extensions this extension depends on */
+ZEND_METHOD(ReflectionExtension, getDependencies)
{
reflection_object *intern;
zend_module_entry *module;
const zend_module_dep *dep;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(module);
@@ -6013,15 +5926,14 @@ ZEND_METHOD(reflection_extension, getDependencies)
}
/* }}} */
-/* {{{ proto public void ReflectionExtension::info()
- Prints phpinfo block for the extension */
-ZEND_METHOD(reflection_extension, info)
+/* {{{ Prints phpinfo block for the extension */
+ZEND_METHOD(ReflectionExtension, info)
{
reflection_object *intern;
zend_module_entry *module;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(module);
@@ -6029,15 +5941,14 @@ ZEND_METHOD(reflection_extension, info)
}
/* }}} */
-/* {{{ proto public bool ReflectionExtension::isPersistent()
- Returns whether this extension is persistent */
-ZEND_METHOD(reflection_extension, isPersistent)
+/* {{{ Returns whether this extension is persistent */
+ZEND_METHOD(ReflectionExtension, isPersistent)
{
reflection_object *intern;
zend_module_entry *module;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(module);
@@ -6045,15 +5956,14 @@ ZEND_METHOD(reflection_extension, isPersistent)
}
/* }}} */
-/* {{{ proto public bool ReflectionExtension::isTemporary()
- Returns whether this extension is temporary */
-ZEND_METHOD(reflection_extension, isTemporary)
+/* {{{ Returns whether this extension is temporary */
+ZEND_METHOD(ReflectionExtension, isTemporary)
{
reflection_object *intern;
zend_module_entry *module;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(module);
@@ -6061,17 +5971,8 @@ ZEND_METHOD(reflection_extension, isTemporary)
}
/* }}} */
-/* {{{ proto public static mixed ReflectionZendExtension::export(string name [, bool return]) throws ReflectionException
- * Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
-ZEND_METHOD(reflection_zend_extension, export)
-{
- _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_zend_extension_ptr, 1);
-}
-/* }}} */
-
-/* {{{ proto public void ReflectionZendExtension::__construct(string name)
- Constructor. Throws an Exception in case the given Zend extension does not exist */
-ZEND_METHOD(reflection_zend_extension, __construct)
+/* {{{ Constructor. Throws an Exception in case the given Zend extension does not exist */
+ZEND_METHOD(ReflectionZendExtension, __construct)
{
zval *object;
reflection_object *intern;
@@ -6079,8 +5980,8 @@ ZEND_METHOD(reflection_zend_extension, __construct)
char *name_str;
size_t name_len;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
- return;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
+ RETURN_THROWS();
}
object = ZEND_THIS;
@@ -6089,8 +5990,8 @@ ZEND_METHOD(reflection_zend_extension, __construct)
extension = zend_get_extension(name_str);
if (!extension) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Zend Extension %s does not exist", name_str);
- return;
+ "Zend Extension \"%s\" does not exist", name_str);
+ RETURN_THROWS();
}
ZVAL_STRING(reflection_prop_name(object), extension->name);
intern->ptr = extension;
@@ -6099,16 +6000,15 @@ ZEND_METHOD(reflection_zend_extension, __construct)
}
/* }}} */
-/* {{{ proto public string ReflectionZendExtension::__toString()
- Returns a string representation */
-ZEND_METHOD(reflection_zend_extension, __toString)
+/* {{{ Returns a string representation */
+ZEND_METHOD(ReflectionZendExtension, __toString)
{
reflection_object *intern;
zend_extension *extension;
smart_str str = {0};
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(extension);
_zend_extension_string(&str, extension, "");
@@ -6116,15 +6016,14 @@ ZEND_METHOD(reflection_zend_extension, __toString)
}
/* }}} */
-/* {{{ proto public string ReflectionZendExtension::getName()
- Returns the name of this Zend extension */
-ZEND_METHOD(reflection_zend_extension, getName)
+/* {{{ Returns the name of this Zend extension */
+ZEND_METHOD(ReflectionZendExtension, getName)
{
reflection_object *intern;
zend_extension *extension;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(extension);
@@ -6132,15 +6031,14 @@ ZEND_METHOD(reflection_zend_extension, getName)
}
/* }}} */
-/* {{{ proto public string ReflectionZendExtension::getVersion()
- Returns the version information of this Zend extension */
-ZEND_METHOD(reflection_zend_extension, getVersion)
+/* {{{ Returns the version information of this Zend extension */
+ZEND_METHOD(ReflectionZendExtension, getVersion)
{
reflection_object *intern;
zend_extension *extension;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(extension);
@@ -6152,15 +6050,14 @@ ZEND_METHOD(reflection_zend_extension, getVersion)
}
/* }}} */
-/* {{{ proto public void ReflectionZendExtension::getAuthor()
- * Returns the name of this Zend extension's author */
-ZEND_METHOD(reflection_zend_extension, getAuthor)
+/* {{{ Returns the name of this Zend extension's author */
+ZEND_METHOD(ReflectionZendExtension, getAuthor)
{
reflection_object *intern;
zend_extension *extension;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(extension);
@@ -6172,15 +6069,14 @@ ZEND_METHOD(reflection_zend_extension, getAuthor)
}
/* }}} */
-/* {{{ proto public void ReflectionZendExtension::getURL()
- Returns this Zend extension's URL*/
-ZEND_METHOD(reflection_zend_extension, getURL)
+/* {{{ Returns this Zend extension's URL*/
+ZEND_METHOD(ReflectionZendExtension, getURL)
{
reflection_object *intern;
zend_extension *extension;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(extension);
@@ -6192,15 +6088,14 @@ ZEND_METHOD(reflection_zend_extension, getURL)
}
/* }}} */
-/* {{{ proto public void ReflectionZendExtension::getCopyright()
- Returns this Zend extension's copyright information */
-ZEND_METHOD(reflection_zend_extension, getCopyright)
+/* {{{ Returns this Zend extension's copyright information */
+ZEND_METHOD(ReflectionZendExtension, getCopyright)
{
reflection_object *intern;
zend_extension *extension;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
GET_REFLECTION_OBJECT_PTR(extension);
@@ -6212,9 +6107,8 @@ ZEND_METHOD(reflection_zend_extension, getCopyright)
}
/* }}} */
-/* {{{ proto public ReflectionReference::__construct()
- * Dummy constructor -- always throws ReflectionExceptions. */
-ZEND_METHOD(reflection_reference, __construct)
+/* {{{ Dummy constructor -- always throws ReflectionExceptions. */
+ZEND_METHOD(ReflectionReference, __construct)
{
_DO_THROW(
"Cannot directly instantiate ReflectionReference. "
@@ -6233,30 +6127,29 @@ static zend_bool is_ignorable_reference(HashTable *ht, zval *ref) {
return Z_TYPE_P(Z_REFVAL_P(ref)) != IS_ARRAY || Z_ARRVAL_P(Z_REFVAL_P(ref)) != ht;
}
-/* {{{ proto public ReflectionReference|null ReflectionReference::fromArrayElement(array array, mixed key)
- * Create ReflectionReference for array item. Returns null if not a reference. */
-ZEND_METHOD(reflection_reference, fromArrayElement)
+/* {{{ Create ReflectionReference for array item. Returns null if not a reference. */
+ZEND_METHOD(ReflectionReference, fromArrayElement)
{
HashTable *ht;
- zval *key, *item;
+ zval *item;
+ zend_string *string_key = NULL;
+ zend_long int_key = 0;
reflection_object *intern;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "hz", &ht, &key) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_ARRAY_HT(ht)
+ Z_PARAM_STR_OR_LONG(string_key, int_key)
+ ZEND_PARSE_PARAMETERS_END();
- if (Z_TYPE_P(key) == IS_LONG) {
- item = zend_hash_index_find(ht, Z_LVAL_P(key));
- } else if (Z_TYPE_P(key) == IS_STRING) {
- item = zend_symtable_find(ht, Z_STR_P(key));
+ if (string_key) {
+ item = zend_hash_find(ht, string_key);
} else {
- zend_type_error("Key must be array or string");
- return;
+ item = zend_hash_index_find(ht, int_key);
}
if (!item) {
_DO_THROW("Array key not found");
- return;
+ RETURN_THROWS();
}
if (Z_TYPE_P(item) != IS_REFERENCE || is_ignorable_reference(ht, item)) {
@@ -6270,28 +6163,27 @@ ZEND_METHOD(reflection_reference, fromArrayElement)
}
/* }}} */
-/* {{{ proto public int|string ReflectionReference::getId()
- * Returns a unique identifier for the reference.
+/* {{{ Returns a unique identifier for the reference.
* The format of the return value is unspecified and may change. */
-ZEND_METHOD(reflection_reference, getId)
+ZEND_METHOD(ReflectionReference, getId)
{
reflection_object *intern;
unsigned char digest[20];
PHP_SHA1_CTX context;
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
intern = Z_REFLECTION_P(getThis());
if (Z_TYPE(intern->obj) != IS_REFERENCE) {
_DO_THROW("Corrupted ReflectionReference object");
- return;
+ RETURN_THROWS();
}
if (!REFLECTION_G(key_initialized)) {
if (php_random_bytes_throw(&REFLECTION_G(key_initialized), 16) == FAILURE) {
- return;
+ RETURN_THROWS();
}
REFLECTION_G(key_initialized) = 1;
@@ -6307,521 +6199,286 @@ ZEND_METHOD(reflection_reference, getId)
}
/* }}} */
-/* {{{ method tables */
-static const zend_function_entry reflection_exception_functions[] = {
- PHP_FE_END
-};
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection__void, 0)
-ZEND_END_ARG_INFO()
-
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_getModifierNames, 0)
- ZEND_ARG_INFO(0, modifiers)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_export, 0, 0, 1)
- ZEND_ARG_OBJ_INFO(0, reflector, Reflector, 0)
- ZEND_ARG_INFO(0, return)
-ZEND_END_ARG_INFO()
-
-static const zend_function_entry reflection_functions[] = {
- ZEND_ME(reflection, getModifierNames, arginfo_reflection_getModifierNames, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- ZEND_DEP_ME(reflection, export, arginfo_reflection_export, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- PHP_FE_END
-};
-
-static const zend_function_entry reflector_functions[] = {
- ZEND_ABSTRACT_ME(reflector, __toString, arginfo_reflection__void)
- PHP_FE_END
-};
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_function_export, 0, 0, 1)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, return)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_function___construct, 0)
- ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_function_invoke, 0, 0, 0)
- ZEND_ARG_INFO(0, args)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_function_invokeArgs, 0)
- ZEND_ARG_ARRAY_INFO(0, args, 0)
-ZEND_END_ARG_INFO()
-
-static const zend_function_entry reflection_function_abstract_functions[] = {
- ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
- ZEND_ME(reflection_function, inNamespace, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, isClosure, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, isDeprecated, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, isInternal, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, isUserDefined, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, isGenerator, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, isVariadic, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getClosureThis, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getClosureScopeClass, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getDocComment, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getEndLine, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getExtension, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getExtensionName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getFileName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getNamespaceName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getNumberOfParameters, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getNumberOfRequiredParameters, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getParameters, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getShortName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getStartLine, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getStaticVariables, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, returnsReference, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, hasReturnType, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, getReturnType, arginfo_reflection__void, 0)
- PHP_FE_END
-};
-
-static const zend_function_entry reflection_function_functions[] = {
- ZEND_ME(reflection_function, __construct, arginfo_reflection_function___construct, 0)
- ZEND_ME(reflection_function, __toString, arginfo_reflection__void, 0)
- ZEND_DEP_ME(reflection_function, export, arginfo_reflection_function_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
- ZEND_ME(reflection_function, isDisabled, arginfo_reflection__void, 0)
- ZEND_ME(reflection_function, invoke, arginfo_reflection_function_invoke, 0)
- ZEND_ME(reflection_function, invokeArgs, arginfo_reflection_function_invokeArgs, 0)
- ZEND_ME(reflection_function, getClosure, arginfo_reflection__void, 0)
- PHP_FE_END
-};
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_generator___construct, 0)
- ZEND_ARG_INFO(0, generator)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_generator_trace, 0, 0, 0)
- ZEND_ARG_INFO(0, options)
-ZEND_END_ARG_INFO()
-
-static const zend_function_entry reflection_generator_functions[] = {
- ZEND_ME(reflection_generator, __construct, arginfo_reflection_generator___construct, 0)
- ZEND_ME(reflection_generator, getExecutingLine, arginfo_reflection__void, 0)
- ZEND_ME(reflection_generator, getExecutingFile, arginfo_reflection__void, 0)
- ZEND_ME(reflection_generator, getTrace, arginfo_reflection_generator_trace, 0)
- ZEND_ME(reflection_generator, getFunction, arginfo_reflection__void, 0)
- ZEND_ME(reflection_generator, getThis, arginfo_reflection__void, 0)
- ZEND_ME(reflection_generator, getExecutingGenerator, arginfo_reflection__void, 0)
- PHP_FE_END
-};
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_method_export, 0, 0, 2)
- ZEND_ARG_INFO(0, class)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, return)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_method___construct, 0, 0, 1)
- ZEND_ARG_INFO(0, class_or_method)
- ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_method_invoke, 0)
- ZEND_ARG_INFO(0, object)
- ZEND_ARG_INFO(0, args)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_method_invokeArgs, 0)
- ZEND_ARG_INFO(0, object)
- ZEND_ARG_ARRAY_INFO(0, args, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_method_setAccessible, 0)
- ZEND_ARG_INFO(0, value)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_method_getClosure, 0, 0, 0)
- ZEND_ARG_INFO(0, object)
-ZEND_END_ARG_INFO()
-
-static const zend_function_entry reflection_method_functions[] = {
- ZEND_DEP_ME(reflection_method, export, arginfo_reflection_method_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
- ZEND_ME(reflection_method, __construct, arginfo_reflection_method___construct, 0)
- ZEND_ME(reflection_method, __toString, arginfo_reflection__void, 0)
- ZEND_ME(reflection_method, isPublic, arginfo_reflection__void, 0)
- ZEND_ME(reflection_method, isPrivate, arginfo_reflection__void, 0)
- ZEND_ME(reflection_method, isProtected, arginfo_reflection__void, 0)
- ZEND_ME(reflection_method, isAbstract, arginfo_reflection__void, 0)
- ZEND_ME(reflection_method, isFinal, arginfo_reflection__void, 0)
- ZEND_ME(reflection_method, isStatic, arginfo_reflection__void, 0)
- ZEND_ME(reflection_method, isConstructor, arginfo_reflection__void, 0)
- ZEND_ME(reflection_method, isDestructor, arginfo_reflection__void, 0)
- ZEND_ME(reflection_method, getClosure, arginfo_reflection_method_getClosure, 0)
- ZEND_ME(reflection_method, getModifiers, arginfo_reflection__void, 0)
- ZEND_ME(reflection_method, invoke, arginfo_reflection_method_invoke, 0)
- ZEND_ME(reflection_method, invokeArgs, arginfo_reflection_method_invokeArgs, 0)
- ZEND_ME(reflection_method, getDeclaringClass, arginfo_reflection__void, 0)
- ZEND_ME(reflection_method, getPrototype, arginfo_reflection__void, 0)
- ZEND_ME(reflection_method, setAccessible, arginfo_reflection_method_setAccessible, 0)
- PHP_FE_END
-};
-
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_export, 0, 0, 1)
- ZEND_ARG_INFO(0, argument)
- ZEND_ARG_INFO(0, return)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class___construct, 0)
- ZEND_ARG_INFO(0, argument)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_getStaticPropertyValue, 0, 0, 1)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, default)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_setStaticPropertyValue, 0)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, value)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_hasMethod, 0)
- ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_getMethod, 0)
- ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_getMethods, 0, 0, 0)
- ZEND_ARG_INFO(0, filter)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_hasProperty, 0)
- ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_getProperty, 0)
- ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_getProperties, 0, 0, 0)
- ZEND_ARG_INFO(0, filter)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_hasConstant, 0)
- ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_getConstant, 0)
- ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_isInstance, 0)
- ZEND_ARG_INFO(0, object)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_newInstance, 0)
- ZEND_ARG_INFO(0, args)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_newInstanceWithoutConstructor, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_newInstanceArgs, 0, 0, 0)
- ZEND_ARG_ARRAY_INFO(0, args, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_isSubclassOf, 0)
- ZEND_ARG_INFO(0, class)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_implementsInterface, 0)
- ZEND_ARG_INFO(0, interface)
-ZEND_END_ARG_INFO()
-
-static const zend_function_entry reflection_class_functions[] = {
- ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
- ZEND_DEP_ME(reflection_class, export, arginfo_reflection_class_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
- ZEND_ME(reflection_class, __construct, arginfo_reflection_class___construct, 0)
- ZEND_ME(reflection_class, __toString, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, isInternal, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, isUserDefined, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, isAnonymous, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, isInstantiable, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, isCloneable, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getFileName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getStartLine, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getEndLine, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getDocComment, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getConstructor, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, hasMethod, arginfo_reflection_class_hasMethod, 0)
- ZEND_ME(reflection_class, getMethod, arginfo_reflection_class_getMethod, 0)
- ZEND_ME(reflection_class, getMethods, arginfo_reflection_class_getMethods, 0)
- ZEND_ME(reflection_class, hasProperty, arginfo_reflection_class_hasProperty, 0)
- ZEND_ME(reflection_class, getProperty, arginfo_reflection_class_getProperty, 0)
- ZEND_ME(reflection_class, getProperties, arginfo_reflection_class_getProperties, 0)
- ZEND_ME(reflection_class, hasConstant, arginfo_reflection_class_hasConstant, 0)
- ZEND_ME(reflection_class, getConstants, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getReflectionConstants, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getConstant, arginfo_reflection_class_getConstant, 0)
- ZEND_ME(reflection_class, getReflectionConstant, arginfo_reflection_class_getConstant, 0)
- ZEND_ME(reflection_class, getInterfaces, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getInterfaceNames, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, isInterface, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getTraits, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getTraitNames, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getTraitAliases, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, isTrait, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, isAbstract, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, isFinal, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getModifiers, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, isInstance, arginfo_reflection_class_isInstance, 0)
- ZEND_ME(reflection_class, newInstance, arginfo_reflection_class_newInstance, 0)
- ZEND_ME(reflection_class, newInstanceWithoutConstructor, arginfo_reflection_class_newInstanceWithoutConstructor, 0)
- ZEND_ME(reflection_class, newInstanceArgs, arginfo_reflection_class_newInstanceArgs, 0)
- ZEND_ME(reflection_class, getParentClass, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, isSubclassOf, arginfo_reflection_class_isSubclassOf, 0)
- ZEND_ME(reflection_class, getStaticProperties, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getStaticPropertyValue, arginfo_reflection_class_getStaticPropertyValue, 0)
- ZEND_ME(reflection_class, setStaticPropertyValue, arginfo_reflection_class_setStaticPropertyValue, 0)
- ZEND_ME(reflection_class, getDefaultProperties, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, isIterable, arginfo_reflection__void, 0)
- ZEND_MALIAS(reflection_class, isIterateable, isIterable, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, implementsInterface, arginfo_reflection_class_implementsInterface, 0)
- ZEND_ME(reflection_class, getExtension, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getExtensionName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, inNamespace, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getNamespaceName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class, getShortName, arginfo_reflection__void, 0)
- PHP_FE_END
-};
-
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_object_export, 0, 0, 1)
- ZEND_ARG_INFO(0, argument)
- ZEND_ARG_INFO(0, return)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_object___construct, 0)
- ZEND_ARG_INFO(0, argument)
-ZEND_END_ARG_INFO()
-
-static const zend_function_entry reflection_object_functions[] = {
- ZEND_DEP_ME(reflection_object, export, arginfo_reflection_object_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
- ZEND_ME(reflection_object, __construct, arginfo_reflection_object___construct, 0)
- PHP_FE_END
-};
-
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property_export, 0, 0, 2)
- ZEND_ARG_INFO(0, class)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, return)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property___construct, 0, 0, 2)
- ZEND_ARG_INFO(0, class)
- ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property_getValue, 0, 0, 0)
- ZEND_ARG_INFO(0, object)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property_setValue, 0, 0, 1)
- ZEND_ARG_INFO(0, object)
- ZEND_ARG_INFO(0, value)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property_isInitialized, 0, 0, 0)
- ZEND_ARG_INFO(0, object)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_property_setAccessible, 0)
- ZEND_ARG_INFO(0, visible)
-ZEND_END_ARG_INFO()
-
-static const zend_function_entry reflection_property_functions[] = {
- ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
- ZEND_DEP_ME(reflection_property, export, arginfo_reflection_property_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
- ZEND_ME(reflection_property, __construct, arginfo_reflection_property___construct, 0)
- ZEND_ME(reflection_property, __toString, arginfo_reflection__void, 0)
- ZEND_ME(reflection_property, getName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_property, getValue, arginfo_reflection_property_getValue, 0)
- ZEND_ME(reflection_property, setValue, arginfo_reflection_property_setValue, 0)
- ZEND_ME(reflection_property, isInitialized, arginfo_reflection_property_isInitialized, 0)
- ZEND_ME(reflection_property, isPublic, arginfo_reflection__void, 0)
- ZEND_ME(reflection_property, isPrivate, arginfo_reflection__void, 0)
- ZEND_ME(reflection_property, isProtected, arginfo_reflection__void, 0)
- ZEND_ME(reflection_property, isStatic, arginfo_reflection__void, 0)
- ZEND_ME(reflection_property, isDefault, arginfo_reflection__void, 0)
- ZEND_ME(reflection_property, getModifiers, arginfo_reflection__void, 0)
- ZEND_ME(reflection_property, getDeclaringClass, arginfo_reflection__void, 0)
- ZEND_ME(reflection_property, getDocComment, arginfo_reflection__void, 0)
- ZEND_ME(reflection_property, setAccessible, arginfo_reflection_property_setAccessible, 0)
- ZEND_ME(reflection_property, getType, arginfo_reflection__void, 0)
- ZEND_ME(reflection_property, hasType, arginfo_reflection__void, 0)
- PHP_FE_END
-};
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_constant_export, 0, 0, 2)
- ZEND_ARG_INFO(0, class)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, return)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_constant___construct, 0, 0, 2)
- ZEND_ARG_INFO(0, class)
- ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-static const zend_function_entry reflection_class_constant_functions[] = {
- ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
- ZEND_DEP_ME(reflection_class_constant, export, arginfo_reflection_class_constant_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
- ZEND_ME(reflection_class_constant, __construct, arginfo_reflection_class_constant___construct, 0)
- ZEND_ME(reflection_class_constant, __toString, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class_constant, getName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class_constant, getValue, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class_constant, isPublic, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class_constant, isPrivate, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class_constant, isProtected, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class_constant, getModifiers, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class_constant, getDeclaringClass, arginfo_reflection__void, 0)
- ZEND_ME(reflection_class_constant, getDocComment, arginfo_reflection__void, 0)
- PHP_FE_END
-};
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_parameter_export, 0, 0, 2)
- ZEND_ARG_INFO(0, function)
- ZEND_ARG_INFO(0, parameter)
- ZEND_ARG_INFO(0, return)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_parameter___construct, 0)
- ZEND_ARG_INFO(0, function)
- ZEND_ARG_INFO(0, parameter)
-ZEND_END_ARG_INFO()
-
-static const zend_function_entry reflection_parameter_functions[] = {
- ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
- ZEND_DEP_ME(reflection_parameter, export, arginfo_reflection_parameter_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
- ZEND_ME(reflection_parameter, __construct, arginfo_reflection_parameter___construct, 0)
- ZEND_ME(reflection_parameter, __toString, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, getName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, isPassedByReference, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, canBePassedByValue, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, getDeclaringFunction, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, getDeclaringClass, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, getClass, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, hasType, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, getType, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, isArray, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, isCallable, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, allowsNull, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, getPosition, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, isOptional, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, isDefaultValueAvailable, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, getDefaultValue, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, isDefaultValueConstant, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, getDefaultValueConstantName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_parameter, isVariadic, arginfo_reflection__void, 0)
- PHP_FE_END
-};
-
-static const zend_function_entry reflection_type_functions[] = {
- ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
- ZEND_ME(reflection_type, allowsNull, arginfo_reflection__void, 0)
- ZEND_ME(reflection_type, isBuiltin, arginfo_reflection__void, 0)
- ZEND_ME(reflection_type, __toString, arginfo_reflection__void, ZEND_ACC_DEPRECATED)
- PHP_FE_END
-};
-
-static const zend_function_entry reflection_named_type_functions[] = {
- ZEND_ME(reflection_named_type, getName, arginfo_reflection__void, 0)
- PHP_FE_END
-};
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_extension_export, 0, 0, 1)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, return)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_extension___construct, 0)
- ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-static const zend_function_entry reflection_extension_functions[] = {
- ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
- ZEND_DEP_ME(reflection_extension, export, arginfo_reflection_extension_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
- ZEND_ME(reflection_extension, __construct, arginfo_reflection_extension___construct, 0)
- ZEND_ME(reflection_extension, __toString, arginfo_reflection__void, 0)
- ZEND_ME(reflection_extension, getName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_extension, getVersion, arginfo_reflection__void, 0)
- ZEND_ME(reflection_extension, getFunctions, arginfo_reflection__void, 0)
- ZEND_ME(reflection_extension, getConstants, arginfo_reflection__void, 0)
- ZEND_ME(reflection_extension, getINIEntries, arginfo_reflection__void, 0)
- ZEND_ME(reflection_extension, getClasses, arginfo_reflection__void, 0)
- ZEND_ME(reflection_extension, getClassNames, arginfo_reflection__void, 0)
- ZEND_ME(reflection_extension, getDependencies, arginfo_reflection__void, 0)
- ZEND_ME(reflection_extension, info, arginfo_reflection__void, 0)
- ZEND_ME(reflection_extension, isPersistent, arginfo_reflection__void, 0)
- ZEND_ME(reflection_extension, isTemporary, arginfo_reflection__void, 0)
- PHP_FE_END
-};
-
-ZEND_BEGIN_ARG_INFO(arginfo_reflection_zend_extension___construct, 0)
- ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-static const zend_function_entry reflection_zend_extension_functions[] = {
- ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
- ZEND_DEP_ME(reflection_zend_extension, export, arginfo_reflection_extension_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
- ZEND_ME(reflection_zend_extension, __construct, arginfo_reflection_zend_extension___construct, 0)
- ZEND_ME(reflection_zend_extension, __toString, arginfo_reflection__void, 0)
- ZEND_ME(reflection_zend_extension, getName, arginfo_reflection__void, 0)
- ZEND_ME(reflection_zend_extension, getVersion, arginfo_reflection__void, 0)
- ZEND_ME(reflection_zend_extension, getAuthor, arginfo_reflection__void, 0)
- ZEND_ME(reflection_zend_extension, getURL, arginfo_reflection__void, 0)
- ZEND_ME(reflection_zend_extension, getCopyright, arginfo_reflection__void, 0)
- PHP_FE_END
-};
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_reference_fromArrayElement, 0, 0, 2)
- ZEND_ARG_INFO(0, array)
- ZEND_ARG_INFO(0, key)
-ZEND_END_ARG_INFO()
-
-static const zend_function_entry reflection_reference_functions[] = {
- ZEND_ME(reflection_reference, fromArrayElement, arginfo_reflection_reference_fromArrayElement, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- ZEND_ME(reflection_reference, getId, arginfo_reflection__void, ZEND_ACC_PUBLIC)
-
- /* Always throwing dummy methods */
- ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE)
- ZEND_ME(reflection_reference, __construct, arginfo_reflection__void, ZEND_ACC_PRIVATE)
- PHP_FE_END
-};
-/* }}} */
-
-static const zend_function_entry reflection_ext_functions[] = { /* {{{ */
- PHP_FE_END
-}; /* }}} */
+ZEND_METHOD(ReflectionAttribute, __construct)
+{
+}
+
+ZEND_METHOD(ReflectionAttribute, __clone)
+{
+ /* Should never be executable */
+ _DO_THROW("Cannot clone object using __clone()");
+}
+
+/* {{{ * Returns the name of the attribute */
+ZEND_METHOD(ReflectionAttribute, getName)
+{
+ reflection_object *intern;
+ attribute_reference *attr;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+ GET_REFLECTION_OBJECT_PTR(attr);
+
+ RETURN_STR_COPY(attr->data->name);
+}
+/* }}} */
+
+/* {{{ * Returns the target of the attribute */
+ZEND_METHOD(ReflectionAttribute, getTarget)
+{
+ reflection_object *intern;
+ attribute_reference *attr;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+ GET_REFLECTION_OBJECT_PTR(attr);
+
+ RETURN_LONG(attr->target);
+}
+/* }}} */
+
+/* {{{ * Returns true if the attribute is repeated */
+ZEND_METHOD(ReflectionAttribute, isRepeated)
+{
+ reflection_object *intern;
+ attribute_reference *attr;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+ GET_REFLECTION_OBJECT_PTR(attr);
+
+ RETURN_BOOL(zend_is_attribute_repeated(attr->attributes, attr->data));
+}
+/* }}} */
+
+/* {{{ * Returns the arguments passed to the attribute */
+ZEND_METHOD(ReflectionAttribute, getArguments)
+{
+ reflection_object *intern;
+ attribute_reference *attr;
+
+ zval tmp;
+ uint32_t i;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+ GET_REFLECTION_OBJECT_PTR(attr);
+
+ array_init(return_value);
+
+ for (i = 0; i < attr->data->argc; i++) {
+ if (FAILURE == zend_get_attribute_value(&tmp, attr->data, i, attr->scope)) {
+ RETURN_THROWS();
+ }
+
+ if (attr->data->args[i].name) {
+ /* We ensured at compile-time that there are no duplicate parameter names. */
+ zend_hash_add_new(Z_ARRVAL_P(return_value), attr->data->args[i].name, &tmp);
+ } else {
+ add_next_index_zval(return_value, &tmp);
+ }
+ }
+}
+/* }}} */
+
+static int call_attribute_constructor(
+ zend_attribute *attr, zend_class_entry *ce, zend_object *obj,
+ zval *args, uint32_t argc, HashTable *named_params, zend_string *filename)
+{
+ zend_function *ctor = ce->constructor;
+ zend_execute_data *prev_execute_data, dummy_frame;
+ zend_function dummy_func;
+ zend_op dummy_opline;
+ ZEND_ASSERT(ctor != NULL);
+
+ if (!(ctor->common.fn_flags & ZEND_ACC_PUBLIC)) {
+ zend_throw_error(NULL, "Attribute constructor of class %s must be public", ZSTR_VAL(ce->name));
+ return FAILURE;
+ }
+
+ if (filename) {
+ /* Set up dummy call frame that makes it look like the attribute was invoked
+ * from where it occurs in the code. */
+ memset(&dummy_frame, 0, sizeof(zend_execute_data));
+ memset(&dummy_func, 0, sizeof(zend_function));
+ memset(&dummy_opline, 0, sizeof(zend_op));
+
+ prev_execute_data = EG(current_execute_data);
+ dummy_frame.prev_execute_data = prev_execute_data;
+ dummy_frame.func = &dummy_func;
+ dummy_frame.opline = &dummy_opline;
+
+ dummy_func.type = ZEND_USER_FUNCTION;
+ dummy_func.common.fn_flags =
+ attr->flags & ZEND_ATTRIBUTE_STRICT_TYPES ? ZEND_ACC_STRICT_TYPES : 0;
+ dummy_func.op_array.filename = filename;
+
+ dummy_opline.opcode = ZEND_DO_FCALL;
+ dummy_opline.lineno = attr->lineno;
+
+ EG(current_execute_data) = &dummy_frame;
+ }
+
+ zend_call_known_function(ctor, obj, obj->ce, NULL, argc, args, named_params);
+
+ if (filename) {
+ EG(current_execute_data) = prev_execute_data;
+ }
+
+ if (EG(exception)) {
+ zend_object_store_ctor_failed(obj);
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
+static void attribute_ctor_cleanup(
+ zval *obj, zval *args, uint32_t argc, HashTable *named_params) /* {{{ */
+{
+ if (obj) {
+ zval_ptr_dtor(obj);
+ }
+
+ if (args) {
+ uint32_t i;
+
+ for (i = 0; i < argc; i++) {
+ zval_ptr_dtor(&args[i]);
+ }
+
+ efree(args);
+ }
+
+ if (named_params) {
+ zend_array_destroy(named_params);
+ }
+}
+/* }}} */
+
+/* {{{ * Returns the attribute as an object */
+ZEND_METHOD(ReflectionAttribute, newInstance)
+{
+ reflection_object *intern;
+ attribute_reference *attr;
+ zend_attribute *marker;
+
+ zend_class_entry *ce;
+ zval obj;
+
+ zval *args = NULL;
+ HashTable *named_params = NULL;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ GET_REFLECTION_OBJECT_PTR(attr);
+
+ if (NULL == (ce = zend_lookup_class(attr->data->name))) {
+ zend_throw_error(NULL, "Attribute class \"%s\" not found", ZSTR_VAL(attr->data->name));
+ RETURN_THROWS();
+ }
+
+ if (NULL == (marker = zend_get_attribute_str(ce->attributes, ZEND_STRL("attribute")))) {
+ zend_throw_error(NULL, "Attempting to use non-attribute class \"%s\" as attribute", ZSTR_VAL(attr->data->name));
+ RETURN_THROWS();
+ }
+
+ if (ce->type == ZEND_USER_CLASS) {
+ uint32_t flags = ZEND_ATTRIBUTE_TARGET_ALL;
+
+ if (marker->argc > 0) {
+ zval tmp;
+
+ if (FAILURE == zend_get_attribute_value(&tmp, marker, 0, ce)) {
+ RETURN_THROWS();
+ }
+
+ flags = (uint32_t) Z_LVAL(tmp);
+ }
+
+ if (!(attr->target & flags)) {
+ zend_string *location = zend_get_attribute_target_names(attr->target);
+ zend_string *allowed = zend_get_attribute_target_names(flags);
+
+ zend_throw_error(NULL, "Attribute \"%s\" cannot target %s (allowed targets: %s)",
+ ZSTR_VAL(attr->data->name), ZSTR_VAL(location), ZSTR_VAL(allowed)
+ );
+
+ zend_string_release(location);
+ zend_string_release(allowed);
+
+ RETURN_THROWS();
+ }
+
+ if (!(flags & ZEND_ATTRIBUTE_IS_REPEATABLE)) {
+ if (zend_is_attribute_repeated(attr->attributes, attr->data)) {
+ zend_throw_error(NULL, "Attribute \"%s\" must not be repeated", ZSTR_VAL(attr->data->name));
+ RETURN_THROWS();
+ }
+ }
+ }
+
+ if (SUCCESS != object_init_ex(&obj, ce)) {
+ RETURN_THROWS();
+ }
+
+ uint32_t argc = 0;
+ if (attr->data->argc) {
+ args = emalloc(attr->data->argc * sizeof(zval));
+
+ for (uint32_t i = 0; i < attr->data->argc; i++) {
+ zval val;
+ if (FAILURE == zend_get_attribute_value(&val, attr->data, i, attr->scope)) {
+ attribute_ctor_cleanup(&obj, args, i, named_params);
+ RETURN_THROWS();
+ }
+ if (attr->data->args[i].name) {
+ if (!named_params) {
+ named_params = zend_new_array(0);
+ }
+ zend_hash_add_new(named_params, attr->data->args[i].name, &val);
+ } else {
+ ZVAL_COPY_VALUE(&args[i], &val);
+ argc++;
+ }
+ }
+ }
+
+ if (ce->constructor) {
+ if (FAILURE == call_attribute_constructor(attr->data, ce, Z_OBJ(obj), args, argc, named_params, attr->filename)) {
+ attribute_ctor_cleanup(&obj, args, argc, named_params);
+ RETURN_THROWS();
+ }
+ } else if (argc || named_params) {
+ attribute_ctor_cleanup(&obj, args, argc, named_params);
+ zend_throw_error(NULL, "Attribute class %s does not have a constructor, cannot pass arguments", ZSTR_VAL(ce->name));
+ RETURN_THROWS();
+ }
+
+ attribute_ctor_cleanup(NULL, args, argc, named_params);
+
+ RETURN_COPY_VALUE(&obj);
+}
/* {{{ _reflection_write_property */
-static zval *_reflection_write_property(zval *object, zval *member, zval *value, void **cache_slot)
+static zval *_reflection_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot)
{
- if ((Z_TYPE_P(member) == IS_STRING)
- && zend_hash_exists(&Z_OBJCE_P(object)->properties_info, Z_STR_P(member))
- && ((Z_STRLEN_P(member) == sizeof("name") - 1 && !memcmp(Z_STRVAL_P(member), "name", sizeof("name")))
- || (Z_STRLEN_P(member) == sizeof("class") - 1 && !memcmp(Z_STRVAL_P(member), "class", sizeof("class")))))
+ if (zend_hash_exists(&object->ce->properties_info, name)
+ && (zend_string_equals_literal(name, "name") || zend_string_equals_literal(name, "class")))
{
zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Cannot set read-only property %s::$%s", ZSTR_VAL(Z_OBJCE_P(object)->name), Z_STRVAL_P(member));
+ "Cannot set read-only property %s::$%s", ZSTR_VAL(object->ce->name), ZSTR_VAL(name));
return &EG(uninitialized_zval);
}
else
{
- return zend_std_write_property(object, member, value, cache_slot);
+ return zend_std_write_property(object, name, value, cache_slot);
}
}
/* }}} */
@@ -6843,47 +6500,55 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
reflection_object_handlers.write_property = _reflection_write_property;
reflection_object_handlers.get_gc = reflection_get_gc;
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionException", reflection_exception_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionException", class_ReflectionException_methods);
reflection_exception_ptr = zend_register_internal_class_ex(&_reflection_entry, zend_ce_exception);
- INIT_CLASS_ENTRY(_reflection_entry, "Reflection", reflection_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "Reflection", class_Reflection_methods);
reflection_ptr = zend_register_internal_class(&_reflection_entry);
- INIT_CLASS_ENTRY(_reflection_entry, "Reflector", reflector_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "Reflector", class_Reflector_methods);
reflector_ptr = zend_register_internal_interface(&_reflection_entry);
+ zend_class_implements(reflector_ptr, 1, zend_ce_stringable);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionFunctionAbstract", reflection_function_abstract_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionFunctionAbstract", class_ReflectionFunctionAbstract_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_function_abstract_ptr = zend_register_internal_class(&_reflection_entry);
zend_class_implements(reflection_function_abstract_ptr, 1, reflector_ptr);
zend_declare_property_string(reflection_function_abstract_ptr, "name", sizeof("name")-1, "", ZEND_ACC_ABSTRACT);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionFunction", reflection_function_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionFunction", class_ReflectionFunction_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_function_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr);
zend_declare_property_string(reflection_function_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC);
REGISTER_REFLECTION_CLASS_CONST_LONG(function, "IS_DEPRECATED", ZEND_ACC_DEPRECATED);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionGenerator", reflection_generator_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionGenerator", class_ReflectionGenerator_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_generator_ptr = zend_register_internal_class(&_reflection_entry);
+ reflection_generator_ptr->ce_flags |= ZEND_ACC_FINAL;
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionParameter", reflection_parameter_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionParameter", class_ReflectionParameter_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_parameter_ptr = zend_register_internal_class(&_reflection_entry);
zend_class_implements(reflection_parameter_ptr, 1, reflector_ptr);
zend_declare_property_string(reflection_parameter_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionType", reflection_type_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionType", class_ReflectionType_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_type_ptr = zend_register_internal_class(&_reflection_entry);
+ reflection_type_ptr->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
+ zend_class_implements(reflection_type_ptr, 1, zend_ce_stringable);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionNamedType", reflection_named_type_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionNamedType", class_ReflectionNamedType_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_named_type_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_type_ptr);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionMethod", reflection_method_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionUnionType", class_ReflectionUnionType_methods);
+ reflection_init_class_handlers(&_reflection_entry);
+ reflection_union_type_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_type_ptr);
+
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionMethod", class_ReflectionMethod_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_method_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr);
zend_declare_property_string(reflection_method_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC);
@@ -6896,7 +6561,7 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_ABSTRACT", ZEND_ACC_ABSTRACT);
REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_FINAL", ZEND_ACC_FINAL);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionClass", reflection_class_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionClass", class_ReflectionClass_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_class_ptr = zend_register_internal_class(&_reflection_entry);
zend_class_implements(reflection_class_ptr, 1, reflector_ptr);
@@ -6907,46 +6572,57 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_EXPLICIT_ABSTRACT", ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_FINAL", ZEND_ACC_FINAL);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionObject", reflection_object_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionObject", class_ReflectionObject_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_object_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_class_ptr);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionProperty", reflection_property_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionProperty", class_ReflectionProperty_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_property_ptr = zend_register_internal_class(&_reflection_entry);
zend_class_implements(reflection_property_ptr, 1, reflector_ptr);
zend_declare_property_string(reflection_property_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC);
zend_declare_property_string(reflection_property_ptr, "class", sizeof("class")-1, "", ZEND_ACC_PUBLIC);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionClassConstant", reflection_class_constant_functions);
+ REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_STATIC", ZEND_ACC_STATIC);
+ REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PUBLIC", ZEND_ACC_PUBLIC);
+ REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PROTECTED", ZEND_ACC_PROTECTED);
+ REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PRIVATE", ZEND_ACC_PRIVATE);
+
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionClassConstant", class_ReflectionClassConstant_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_class_constant_ptr = zend_register_internal_class(&_reflection_entry);
zend_class_implements(reflection_class_constant_ptr, 1, reflector_ptr);
zend_declare_property_string(reflection_class_constant_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC);
zend_declare_property_string(reflection_class_constant_ptr, "class", sizeof("class")-1, "", ZEND_ACC_PUBLIC);
- REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_STATIC", ZEND_ACC_STATIC);
- REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PUBLIC", ZEND_ACC_PUBLIC);
- REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PROTECTED", ZEND_ACC_PROTECTED);
- REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PRIVATE", ZEND_ACC_PRIVATE);
+ REGISTER_REFLECTION_CLASS_CONST_LONG(class_constant, "IS_PUBLIC", ZEND_ACC_PUBLIC);
+ REGISTER_REFLECTION_CLASS_CONST_LONG(class_constant, "IS_PROTECTED", ZEND_ACC_PROTECTED);
+ REGISTER_REFLECTION_CLASS_CONST_LONG(class_constant, "IS_PRIVATE", ZEND_ACC_PRIVATE);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionExtension", reflection_extension_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionExtension", class_ReflectionExtension_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_extension_ptr = zend_register_internal_class(&_reflection_entry);
zend_class_implements(reflection_extension_ptr, 1, reflector_ptr);
zend_declare_property_string(reflection_extension_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionZendExtension", reflection_zend_extension_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionZendExtension", class_ReflectionZendExtension_methods);
reflection_init_class_handlers(&_reflection_entry);
reflection_zend_extension_ptr = zend_register_internal_class(&_reflection_entry);
zend_class_implements(reflection_zend_extension_ptr, 1, reflector_ptr);
zend_declare_property_string(reflection_zend_extension_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC);
- INIT_CLASS_ENTRY(_reflection_entry, "ReflectionReference", reflection_reference_functions);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionReference", class_ReflectionReference_methods);
reflection_init_class_handlers(&_reflection_entry);
_reflection_entry.ce_flags |= ZEND_ACC_FINAL;
reflection_reference_ptr = zend_register_internal_class(&_reflection_entry);
+ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionAttribute", class_ReflectionAttribute_methods);
+ reflection_init_class_handlers(&_reflection_entry);
+ _reflection_entry.ce_flags |= ZEND_ACC_FINAL;
+ reflection_attribute_ptr = zend_register_internal_class(&_reflection_entry);
+
+ REGISTER_REFLECTION_CLASS_CONST_LONG(attribute, "IS_INSTANCEOF", REFLECTION_ATTRIBUTE_IS_INSTANCEOF);
+
REFLECTION_G(key_initialized) = 0;
return SUCCESS;
@@ -6962,7 +6638,7 @@ PHP_MINFO_FUNCTION(reflection) /* {{{ */
zend_module_entry reflection_module_entry = { /* {{{ */
STANDARD_MODULE_HEADER,
"Reflection",
- reflection_ext_functions,
+ NULL,
PHP_MINIT(reflection),
NULL,
NULL,
diff --git a/ext/reflection/php_reflection.h b/ext/reflection/php_reflection.h
index b1d5717e3f..654ba55256 100644
--- a/ext/reflection/php_reflection.h
+++ b/ext/reflection/php_reflection.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -44,6 +42,7 @@ extern PHPAPI zend_class_entry *reflection_property_ptr;
extern PHPAPI zend_class_entry *reflection_extension_ptr;
extern PHPAPI zend_class_entry *reflection_zend_extension_ptr;
extern PHPAPI zend_class_entry *reflection_reference_ptr;
+extern PHPAPI zend_class_entry *reflection_attribute_ptr;
PHPAPI void zend_reflection_class_factory(zend_class_entry *ce, zval *object);
diff --git a/ext/reflection/php_reflection.stub.php b/ext/reflection/php_reflection.stub.php
new file mode 100644
index 0000000000..d12d10bd81
--- /dev/null
+++ b/ext/reflection/php_reflection.stub.php
@@ -0,0 +1,667 @@
+<?php
+
+/** @generate-function-entries */
+
+class ReflectionException extends Exception
+{
+}
+
+class Reflection
+{
+ /** @return string[] */
+ public static function getModifierNames(int $modifiers) {}
+}
+
+interface Reflector extends Stringable
+{
+}
+
+abstract class ReflectionFunctionAbstract implements Reflector
+{
+ /** @implementation-alias ReflectionClass::__clone */
+ final private function __clone(): void {}
+
+ /** @return bool */
+ public function inNamespace() {}
+
+ /** @return bool */
+ public function isClosure() {}
+
+ /** @return bool */
+ public function isDeprecated() {}
+
+ /** @return bool */
+ public function isInternal() {}
+
+ /** @return bool */
+ public function isUserDefined() {}
+
+ /** @return bool */
+ public function isGenerator() {}
+
+ /** @return bool */
+ public function isVariadic() {}
+
+ /** @return object|null */
+ public function getClosureThis() {}
+
+ /** @return ReflectionClass|null */
+ public function getClosureScopeClass() {}
+
+ /** @return string|false */
+ public function getDocComment() {}
+
+ /** @return int|false */
+ public function getEndLine() {}
+
+ /** @return ReflectionExtension|null */
+ public function getExtension() {}
+
+ /** @return string|false */
+ public function getExtensionName() {}
+
+ /** @return string|false */
+ public function getFileName() {}
+
+ /** @return string */
+ public function getName() {}
+
+ /** @return string */
+ public function getNamespaceName() {}
+
+ /** @return int */
+ public function getNumberOfParameters() {}
+
+ /** @return int */
+ public function getNumberOfRequiredParameters() {}
+
+ /** @return ReflectionParameter[] */
+ public function getParameters() {}
+
+ /** @return string */
+ public function getShortName() {}
+
+ /** @return int|false */
+ public function getStartLine() {}
+
+ /** @return array */
+ public function getStaticVariables() {}
+
+ /** @return bool */
+ public function returnsReference() {}
+
+ /** @return bool */
+ public function hasReturnType() {}
+
+ /** @return ReflectionType|null */
+ public function getReturnType() {}
+
+ /** @return ReflectionAttribute[] */
+ public function getAttributes(?string $name = null, int $flags = 0): array {}
+}
+
+class ReflectionFunction extends ReflectionFunctionAbstract
+{
+ public function __construct(Closure|string $function) {}
+
+ public function __toString(): string {}
+
+ /**
+ * @return bool
+ * @deprecated ReflectionFunction can no longer be constructed for disabled functions
+ */
+ public function isDisabled() {}
+
+ /** @return mixed */
+ public function invoke(mixed ...$args) {}
+
+ /** @return mixed */
+ public function invokeArgs(array $args) {}
+
+ /** @return Closure */
+ public function getClosure() {}
+}
+
+final class ReflectionGenerator
+{
+ public function __construct(Generator $generator) {}
+
+ /** @return int */
+ public function getExecutingLine() {}
+
+ /** @return string */
+ public function getExecutingFile() {}
+
+ /** @return array */
+ public function getTrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT) {}
+
+ /** @return ReflectionFunctionAbstract */
+ public function getFunction() {}
+
+ /** @return object|null */
+ public function getThis() {}
+
+ /** @return Generator */
+ public function getExecutingGenerator() {}
+}
+
+class ReflectionMethod extends ReflectionFunctionAbstract
+{
+ public function __construct(object|string $objectOrMethod, ?string $method = null) {}
+
+ public function __toString(): string {}
+
+ /** @return bool */
+ public function isPublic() {}
+
+ /** @return bool */
+ public function isPrivate() {}
+
+ /** @return bool */
+ public function isProtected() {}
+
+ /** @return bool */
+ public function isAbstract() {}
+
+ /** @return bool */
+ public function isFinal() {}
+
+ /** @return bool */
+ public function isStatic() {}
+
+ /** @return bool */
+ public function isConstructor() {}
+
+ /** @return bool */
+ public function isDestructor() {}
+
+ /** @return Closure */
+ public function getClosure(?object $object = null) {}
+
+ /** @return int */
+ public function getModifiers() {}
+
+ /** @return mixed */
+ public function invoke(?object $object, mixed ...$args) {}
+
+ /** @return mixed */
+ public function invokeArgs(?object $object, array $args) {}
+
+ /** @return ReflectionClass */
+ public function getDeclaringClass() {}
+
+ /** @return ReflectionMethod */
+ public function getPrototype() {}
+
+ /** @return void */
+ public function setAccessible(bool $accessible) {}
+}
+
+class ReflectionClass implements Reflector
+{
+ final private function __clone(): void {}
+
+ public function __construct(object|string $objectOrClass) {}
+
+ public function __toString(): string {}
+
+ /** @return string */
+ public function getName() {}
+
+ /** @return bool */
+ public function isInternal() {}
+
+ /** @return bool */
+ public function isUserDefined() {}
+
+ /** @return bool */
+ public function isAnonymous() {}
+
+ /** @return bool */
+ public function isInstantiable() {}
+
+ /** @return bool */
+ public function isCloneable() {}
+
+ /** @return string|false */
+ public function getFileName() {}
+
+ /** @return int|false */
+ public function getStartLine() {}
+
+ /** @return int|false */
+ public function getEndLine() {}
+
+ /** @return string|false */
+ public function getDocComment() {}
+
+ /** @return ReflectionMethod|null */
+ public function getConstructor() {}
+
+ /** @return bool */
+ public function hasMethod(string $name) {}
+
+ /** @return ReflectionMethod */
+ public function getMethod(string $name) {}
+
+ /** @return ReflectionMethod[] */
+ public function getMethods(?int $filter = null) {}
+
+ /** @return bool */
+ public function hasProperty(string $name) {}
+
+ /** @return ReflectionProperty */
+ public function getProperty(string $name) {}
+
+ /** @return ReflectionProperty[] */
+ public function getProperties(?int $filter = null) {}
+
+ /** @return bool */
+ public function hasConstant(string $name) {}
+
+ /** @return array */
+ public function getConstants(?int $filter = null) {}
+
+ /** @return ReflectionClassConstant[] */
+ public function getReflectionConstants(?int $filter = null) {}
+
+ /** @return mixed */
+ public function getConstant(string $name) {}
+
+ /** @return ReflectionClassConstant|false */
+ public function getReflectionConstant(string $name) {}
+
+ /** @return ReflectionClass[] */
+ public function getInterfaces() {}
+
+ /** @return string[] */
+ public function getInterfaceNames() {}
+
+ /** @return bool */
+ public function isInterface() {}
+
+ /** @return ReflectionClass[] */
+ public function getTraits() {}
+
+ /** @return string[] */
+ public function getTraitNames() {}
+
+ /** @return string[] */
+ public function getTraitAliases() {}
+
+ /** @return bool */
+ public function isTrait() {}
+
+ /** @return bool */
+ public function isAbstract() {}
+
+ /** @return bool */
+ public function isFinal() {}
+
+ /** @return int */
+ public function getModifiers() {}
+
+ /** @return bool */
+ public function isInstance(object $object) {}
+
+ /** @return object */
+ public function newInstance(mixed ...$args) {}
+
+ /** @return object */
+ public function newInstanceWithoutConstructor() {}
+
+ /** @return object */
+ public function newInstanceArgs(array $args = []) {}
+
+ /** @return ReflectionClass|false */
+ public function getParentClass() {}
+
+ /** @return bool */
+ public function isSubclassOf(ReflectionClass|string $class) {}
+
+ /** @return array|null */
+ public function getStaticProperties() {}
+
+ /** @return mixed */
+ public function getStaticPropertyValue(string $name, mixed $default = UNKNOWN) {}
+
+ /** @return void */
+ public function setStaticPropertyValue(string $name, mixed $value) {}
+
+ /** @return array */
+ public function getDefaultProperties() {}
+
+ /** @return bool */
+ public function isIterable() {}
+
+ /**
+ * @return bool
+ * @alias ReflectionClass::isIterable
+ */
+ public function isIterateable() {}
+
+ /** @return bool */
+ public function implementsInterface(ReflectionClass|string $interface) {}
+
+ /** @return ReflectionExtension|null */
+ public function getExtension() {}
+
+ /** @return string|false */
+ public function getExtensionName() {}
+
+ /** @return bool */
+ public function inNamespace() {}
+
+ /** @return string */
+ public function getNamespaceName() {}
+
+ /** @return string */
+ public function getShortName() {}
+
+ /** @return ReflectionAttribute[] */
+ public function getAttributes(?string $name = null, int $flags = 0): array {}
+}
+
+class ReflectionObject extends ReflectionClass
+{
+ public function __construct(object $object) {}
+}
+
+class ReflectionProperty implements Reflector
+{
+ /** @implementation-alias ReflectionClass::__clone */
+ final private function __clone(): void {}
+
+ public function __construct(object|string $class, string $property) {}
+
+ public function __toString(): string {}
+
+ /** @return string */
+ public function getName() {}
+
+ /** @return mixed */
+ public function getValue(?object $object = null) {}
+
+ /** @return void */
+ public function setValue(mixed $objectOrValue, mixed $value = UNKNOWN) {}
+
+ /** @return bool */
+ public function isInitialized(?object $object = null) {}
+
+ /** @return bool */
+ public function isPublic() {}
+
+ /** @return bool */
+ public function isPrivate() {}
+
+ /** @return bool */
+ public function isProtected() {}
+
+ /** @return bool */
+ public function isStatic() {}
+
+ /** @return bool */
+ public function isDefault() {}
+
+ public function isPromoted(): bool {}
+
+ /** @return int */
+ public function getModifiers() {}
+
+ /** @return ReflectionClass */
+ public function getDeclaringClass() {}
+
+ /** @return string|false */
+ public function getDocComment() {}
+
+ /** @return void */
+ public function setAccessible(bool $accessible) {}
+
+ /** @return ReflectionType|null */
+ public function getType() {}
+
+ /** @return bool */
+ public function hasType() {}
+
+ public function hasDefaultValue(): bool {}
+
+ /** @return mixed */
+ public function getDefaultValue() {}
+
+ /** @return ReflectionAttribute[] */
+ public function getAttributes(?string $name = null, int $flags = 0): array {}
+}
+
+class ReflectionClassConstant implements Reflector
+{
+ /** @implementation-alias ReflectionClass::__clone */
+ final private function __clone(): void {}
+
+ public function __construct(object|string $class, string $constant) {}
+
+ public function __toString(): string {}
+
+ /** @return string|false */
+ public function getName() {}
+
+ /** @return mixed */
+ public function getValue() {}
+
+ /** @return bool */
+ public function isPublic() {}
+
+ /** @return bool */
+ public function isPrivate() {}
+
+ /** @return bool */
+ public function isProtected() {}
+
+ /** @return int */
+ public function getModifiers() {}
+
+ /** @return ReflectionClass */
+ public function getDeclaringClass() {}
+
+ /** @return string|false */
+ public function getDocComment() {}
+
+ /** @return ReflectionAttribute[] */
+ public function getAttributes(?string $name = null, int $flags = 0): array {}
+}
+
+class ReflectionParameter implements Reflector
+{
+ /** @implementation-alias ReflectionClass::__clone */
+ final private function __clone(): void {}
+
+ /** @param string|array|object $function */
+ public function __construct($function, int|string $param) {}
+
+ public function __toString(): string {}
+
+ /** @return string */
+ public function getName() {}
+
+ /** @return bool */
+ public function isPassedByReference() {}
+
+ /** @return bool */
+ public function canBePassedByValue() {}
+
+ /** @return ReflectionFunctionAbstract */
+ public function getDeclaringFunction() {}
+
+ /** @return ReflectionClass|null */
+ public function getDeclaringClass() {}
+
+ /**
+ * @return ReflectionClass|null
+ * @deprecated Use ReflectionParameter::getType() instead
+ */
+ public function getClass() {}
+
+ /** @return bool */
+ public function hasType() {}
+
+ /** @return ReflectionType|null */
+ public function getType() {}
+
+ /**
+ * @return bool
+ * @deprecated Use ReflectionParameter::getType() instead
+ */
+ public function isArray() {}
+
+ /**
+ * @return bool
+ * @deprecated Use ReflectionParameter::getType() instead
+ */
+ public function isCallable() {}
+
+ /** @return bool */
+ public function allowsNull() {}
+
+ /** @return int */
+ public function getPosition() {}
+
+ /** @return bool */
+ public function isOptional() {}
+
+ /** @return bool */
+ public function isDefaultValueAvailable() {}
+
+ /** @return mixed */
+ public function getDefaultValue() {}
+
+ /** @return bool */
+ public function isDefaultValueConstant() {}
+
+ /** @return string|null */
+ public function getDefaultValueConstantName() {}
+
+ /** @return bool */
+ public function isVariadic() {}
+
+ public function isPromoted(): bool {}
+
+ /** @return ReflectionAttribute[] */
+ public function getAttributes(?string $name = null, int $flags = 0): array {}
+}
+
+abstract class ReflectionType implements Stringable
+{
+ /** @implementation-alias ReflectionClass::__clone */
+ final private function __clone(): void {}
+
+ /** @return bool */
+ public function allowsNull() {}
+
+ public function __toString(): string {}
+}
+
+class ReflectionNamedType extends ReflectionType
+{
+ /** @return string */
+ public function getName() {}
+
+ /** @return bool */
+ public function isBuiltin() {}
+}
+
+class ReflectionUnionType extends ReflectionType
+{
+ public function getTypes(): array {}
+}
+
+class ReflectionExtension implements Reflector
+{
+ /** @implementation-alias ReflectionClass::__clone */
+ final private function __clone(): void {}
+
+ public function __construct(string $name) {}
+
+ public function __toString(): string {}
+
+ /** @return string */
+ public function getName() {}
+
+ /** @return string|null */
+ public function getVersion() {}
+
+ /** @return ReflectionFunction[] */
+ public function getFunctions() {}
+
+ /** @return array */
+ public function getConstants() {}
+
+ /** @return array */
+ public function getINIEntries() {}
+
+ /** @return ReflectionClass[] */
+ public function getClasses() {}
+
+ /** @return string[] */
+ public function getClassNames() {}
+
+ /** @return array */
+ public function getDependencies() {}
+
+ /** @return void */
+ public function info() {}
+
+ /** @return bool */
+ public function isPersistent() {}
+
+ /** @return bool */
+ public function isTemporary() {}
+}
+
+class ReflectionZendExtension implements Reflector
+{
+ /** @implementation-alias ReflectionClass::__clone */
+ final private function __clone(): void {}
+
+ public function __construct(string $name) {}
+
+ public function __toString(): string {}
+
+ /** @return string */
+ public function getName() {}
+
+ /** @return string */
+ public function getVersion() {}
+
+ /** @return string */
+ public function getAuthor() {}
+
+ /** @return string */
+ public function getURL() {}
+
+ /** @return string */
+ public function getCopyright() {}
+}
+
+final class ReflectionReference
+{
+ public static function fromArrayElement(array $array, int|string $key): ?ReflectionReference {}
+
+ public function getId(): string {}
+
+ /** @implementation-alias ReflectionClass::__clone */
+ private function __clone(): void {}
+
+ private function __construct() {}
+}
+
+final class ReflectionAttribute
+{
+ public function getName(): string {}
+ public function getTarget(): int {}
+ public function isRepeated(): bool {}
+ public function getArguments(): array {}
+ public function newInstance(): object {}
+
+ private function __clone(): void {}
+
+ private function __construct() {}
+}
diff --git a/ext/reflection/php_reflection_arginfo.h b/ext/reflection/php_reflection_arginfo.h
new file mode 100644
index 0000000000..ba524b4f6d
--- /dev/null
+++ b/ext/reflection/php_reflection_arginfo.h
@@ -0,0 +1,996 @@
+/* This is a generated file, edit the .stub.php file instead.
+ * Stub hash: 6849bff1f2b343df4bd7e6da9c8adc555731e2d3 */
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionFunctionAbstract___clone, 0, 0, IS_VOID, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionFunctionAbstract_inNamespace, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionFunctionAbstract_isClosure arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_isDeprecated arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_isInternal arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_isUserDefined arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_isGenerator arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_isVariadic arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getClosureThis arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getClosureScopeClass arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getDocComment arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getEndLine arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getExtension arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getExtensionName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getFileName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getNamespaceName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getNumberOfParameters arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getNumberOfRequiredParameters arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getParameters arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getShortName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getStartLine arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getStaticVariables arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_returnsReference arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_hasReturnType arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionFunctionAbstract_getReturnType arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionFunctionAbstract_getAttributes, 0, 0, IS_ARRAY, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionFunction___construct, 0, 0, 1)
+ ZEND_ARG_OBJ_TYPE_MASK(0, function, Closure, MAY_BE_STRING, NULL)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionFunction___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionFunction_isDisabled arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionFunction_invoke, 0, 0, 0)
+ ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionFunction_invokeArgs, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, args, IS_ARRAY, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionFunction_getClosure arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionGenerator___construct, 0, 0, 1)
+ ZEND_ARG_OBJ_INFO(0, generator, Generator, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionGenerator_getExecutingLine arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionGenerator_getExecutingFile arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionGenerator_getTrace, 0, 0, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "DEBUG_BACKTRACE_PROVIDE_OBJECT")
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionGenerator_getFunction arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionGenerator_getThis arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionGenerator_getExecutingGenerator arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionMethod___construct, 0, 0, 1)
+ ZEND_ARG_TYPE_MASK(0, objectOrMethod, MAY_BE_OBJECT|MAY_BE_STRING, NULL)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, method, IS_STRING, 1, "null")
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionMethod___toString arginfo_class_ReflectionFunction___toString
+
+#define arginfo_class_ReflectionMethod_isPublic arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionMethod_isPrivate arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionMethod_isProtected arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionMethod_isAbstract arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionMethod_isFinal arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionMethod_isStatic arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionMethod_isConstructor arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionMethod_isDestructor arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionMethod_getClosure, 0, 0, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, object, IS_OBJECT, 1, "null")
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionMethod_getModifiers arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionMethod_invoke, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 1)
+ ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionMethod_invokeArgs, 0, 0, 2)
+ ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 1)
+ ZEND_ARG_TYPE_INFO(0, args, IS_ARRAY, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionMethod_getDeclaringClass arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionMethod_getPrototype arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionMethod_setAccessible, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, accessible, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionClass___clone arginfo_class_ReflectionFunctionAbstract___clone
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClass___construct, 0, 0, 1)
+ ZEND_ARG_TYPE_MASK(0, objectOrClass, MAY_BE_OBJECT|MAY_BE_STRING, NULL)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionClass___toString arginfo_class_ReflectionFunction___toString
+
+#define arginfo_class_ReflectionClass_getName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_isInternal arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_isUserDefined arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_isAnonymous arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_isInstantiable arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_isCloneable arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getFileName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getStartLine arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getEndLine arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getDocComment arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getConstructor arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClass_hasMethod, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionClass_getMethod arginfo_class_ReflectionClass_hasMethod
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClass_getMethods, 0, 0, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, filter, IS_LONG, 1, "null")
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionClass_hasProperty arginfo_class_ReflectionClass_hasMethod
+
+#define arginfo_class_ReflectionClass_getProperty arginfo_class_ReflectionClass_hasMethod
+
+#define arginfo_class_ReflectionClass_getProperties arginfo_class_ReflectionClass_getMethods
+
+#define arginfo_class_ReflectionClass_hasConstant arginfo_class_ReflectionClass_hasMethod
+
+#define arginfo_class_ReflectionClass_getConstants arginfo_class_ReflectionClass_getMethods
+
+#define arginfo_class_ReflectionClass_getReflectionConstants arginfo_class_ReflectionClass_getMethods
+
+#define arginfo_class_ReflectionClass_getConstant arginfo_class_ReflectionClass_hasMethod
+
+#define arginfo_class_ReflectionClass_getReflectionConstant arginfo_class_ReflectionClass_hasMethod
+
+#define arginfo_class_ReflectionClass_getInterfaces arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getInterfaceNames arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_isInterface arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getTraits arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getTraitNames arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getTraitAliases arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_isTrait arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_isAbstract arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_isFinal arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getModifiers arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClass_isInstance, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionClass_newInstance arginfo_class_ReflectionFunction_invoke
+
+#define arginfo_class_ReflectionClass_newInstanceWithoutConstructor arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClass_newInstanceArgs, 0, 0, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, args, IS_ARRAY, 0, "[]")
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionClass_getParentClass arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClass_isSubclassOf, 0, 0, 1)
+ ZEND_ARG_OBJ_TYPE_MASK(0, class, ReflectionClass, MAY_BE_STRING, NULL)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionClass_getStaticProperties arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClass_getStaticPropertyValue, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, default, IS_MIXED, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClass_setStaticPropertyValue, 0, 0, 2)
+ ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionClass_getDefaultProperties arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_isIterable arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_isIterateable arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClass_implementsInterface, 0, 0, 1)
+ ZEND_ARG_OBJ_TYPE_MASK(0, interface, ReflectionClass, MAY_BE_STRING, NULL)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionClass_getExtension arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getExtensionName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_inNamespace arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getNamespaceName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getShortName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClass_getAttributes arginfo_class_ReflectionFunctionAbstract_getAttributes
+
+#define arginfo_class_ReflectionObject___construct arginfo_class_ReflectionClass_isInstance
+
+#define arginfo_class_ReflectionProperty___clone arginfo_class_ReflectionFunctionAbstract___clone
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionProperty___construct, 0, 0, 2)
+ ZEND_ARG_TYPE_MASK(0, class, MAY_BE_OBJECT|MAY_BE_STRING, NULL)
+ ZEND_ARG_TYPE_INFO(0, property, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionProperty___toString arginfo_class_ReflectionFunction___toString
+
+#define arginfo_class_ReflectionProperty_getName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionProperty_getValue arginfo_class_ReflectionMethod_getClosure
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionProperty_setValue, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, objectOrValue, IS_MIXED, 0)
+ ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionProperty_isInitialized arginfo_class_ReflectionMethod_getClosure
+
+#define arginfo_class_ReflectionProperty_isPublic arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionProperty_isPrivate arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionProperty_isProtected arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionProperty_isStatic arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionProperty_isDefault arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionProperty_isPromoted, 0, 0, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionProperty_getModifiers arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionProperty_getDeclaringClass arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionProperty_getDocComment arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionProperty_setAccessible arginfo_class_ReflectionMethod_setAccessible
+
+#define arginfo_class_ReflectionProperty_getType arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionProperty_hasType arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionProperty_hasDefaultValue arginfo_class_ReflectionProperty_isPromoted
+
+#define arginfo_class_ReflectionProperty_getDefaultValue arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionProperty_getAttributes arginfo_class_ReflectionFunctionAbstract_getAttributes
+
+#define arginfo_class_ReflectionClassConstant___clone arginfo_class_ReflectionFunctionAbstract___clone
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClassConstant___construct, 0, 0, 2)
+ ZEND_ARG_TYPE_MASK(0, class, MAY_BE_OBJECT|MAY_BE_STRING, NULL)
+ ZEND_ARG_TYPE_INFO(0, constant, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionClassConstant___toString arginfo_class_ReflectionFunction___toString
+
+#define arginfo_class_ReflectionClassConstant_getName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClassConstant_getValue arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClassConstant_isPublic arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClassConstant_isPrivate arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClassConstant_isProtected arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClassConstant_getModifiers arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClassConstant_getDeclaringClass arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClassConstant_getDocComment arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionClassConstant_getAttributes arginfo_class_ReflectionFunctionAbstract_getAttributes
+
+#define arginfo_class_ReflectionParameter___clone arginfo_class_ReflectionFunctionAbstract___clone
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionParameter___construct, 0, 0, 2)
+ ZEND_ARG_INFO(0, function)
+ ZEND_ARG_TYPE_MASK(0, param, MAY_BE_LONG|MAY_BE_STRING, NULL)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionParameter___toString arginfo_class_ReflectionFunction___toString
+
+#define arginfo_class_ReflectionParameter_getName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_isPassedByReference arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_canBePassedByValue arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_getDeclaringFunction arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_getDeclaringClass arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_getClass arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_hasType arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_getType arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_isArray arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_isCallable arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_allowsNull arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_getPosition arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_isOptional arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_isDefaultValueAvailable arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_getDefaultValue arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_isDefaultValueConstant arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_getDefaultValueConstantName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_isVariadic arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionParameter_isPromoted arginfo_class_ReflectionProperty_isPromoted
+
+#define arginfo_class_ReflectionParameter_getAttributes arginfo_class_ReflectionFunctionAbstract_getAttributes
+
+#define arginfo_class_ReflectionType___clone arginfo_class_ReflectionFunctionAbstract___clone
+
+#define arginfo_class_ReflectionType_allowsNull arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionType___toString arginfo_class_ReflectionFunction___toString
+
+#define arginfo_class_ReflectionNamedType_getName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionNamedType_isBuiltin arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionUnionType_getTypes, 0, 0, IS_ARRAY, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionExtension___clone arginfo_class_ReflectionFunctionAbstract___clone
+
+#define arginfo_class_ReflectionExtension___construct arginfo_class_ReflectionClass_hasMethod
+
+#define arginfo_class_ReflectionExtension___toString arginfo_class_ReflectionFunction___toString
+
+#define arginfo_class_ReflectionExtension_getName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionExtension_getVersion arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionExtension_getFunctions arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionExtension_getConstants arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionExtension_getINIEntries arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionExtension_getClasses arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionExtension_getClassNames arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionExtension_getDependencies arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionExtension_info arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionExtension_isPersistent arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionExtension_isTemporary arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionZendExtension___clone arginfo_class_ReflectionFunctionAbstract___clone
+
+#define arginfo_class_ReflectionZendExtension___construct arginfo_class_ReflectionClass_hasMethod
+
+#define arginfo_class_ReflectionZendExtension___toString arginfo_class_ReflectionFunction___toString
+
+#define arginfo_class_ReflectionZendExtension_getName arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionZendExtension_getVersion arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionZendExtension_getAuthor arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionZendExtension_getURL arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionZendExtension_getCopyright arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_ReflectionReference_fromArrayElement, 0, 2, ReflectionReference, 1)
+ ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0)
+ ZEND_ARG_TYPE_MASK(0, key, MAY_BE_LONG|MAY_BE_STRING, NULL)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionReference_getId arginfo_class_ReflectionFunction___toString
+
+#define arginfo_class_ReflectionReference___clone arginfo_class_ReflectionFunctionAbstract___clone
+
+#define arginfo_class_ReflectionReference___construct arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+#define arginfo_class_ReflectionAttribute_getName arginfo_class_ReflectionFunction___toString
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionAttribute_getTarget, 0, 0, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionAttribute_isRepeated arginfo_class_ReflectionProperty_isPromoted
+
+#define arginfo_class_ReflectionAttribute_getArguments arginfo_class_ReflectionUnionType_getTypes
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionAttribute_newInstance, 0, 0, IS_OBJECT, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ReflectionAttribute___clone arginfo_class_ReflectionFunctionAbstract___clone
+
+#define arginfo_class_ReflectionAttribute___construct arginfo_class_ReflectionFunctionAbstract_inNamespace
+
+
+ZEND_METHOD(Reflection, getModifierNames);
+ZEND_METHOD(ReflectionClass, __clone);
+ZEND_METHOD(ReflectionFunctionAbstract, inNamespace);
+ZEND_METHOD(ReflectionFunctionAbstract, isClosure);
+ZEND_METHOD(ReflectionFunctionAbstract, isDeprecated);
+ZEND_METHOD(ReflectionFunctionAbstract, isInternal);
+ZEND_METHOD(ReflectionFunctionAbstract, isUserDefined);
+ZEND_METHOD(ReflectionFunctionAbstract, isGenerator);
+ZEND_METHOD(ReflectionFunctionAbstract, isVariadic);
+ZEND_METHOD(ReflectionFunctionAbstract, getClosureThis);
+ZEND_METHOD(ReflectionFunctionAbstract, getClosureScopeClass);
+ZEND_METHOD(ReflectionFunctionAbstract, getDocComment);
+ZEND_METHOD(ReflectionFunctionAbstract, getEndLine);
+ZEND_METHOD(ReflectionFunctionAbstract, getExtension);
+ZEND_METHOD(ReflectionFunctionAbstract, getExtensionName);
+ZEND_METHOD(ReflectionFunctionAbstract, getFileName);
+ZEND_METHOD(ReflectionFunctionAbstract, getName);
+ZEND_METHOD(ReflectionFunctionAbstract, getNamespaceName);
+ZEND_METHOD(ReflectionFunctionAbstract, getNumberOfParameters);
+ZEND_METHOD(ReflectionFunctionAbstract, getNumberOfRequiredParameters);
+ZEND_METHOD(ReflectionFunctionAbstract, getParameters);
+ZEND_METHOD(ReflectionFunctionAbstract, getShortName);
+ZEND_METHOD(ReflectionFunctionAbstract, getStartLine);
+ZEND_METHOD(ReflectionFunctionAbstract, getStaticVariables);
+ZEND_METHOD(ReflectionFunctionAbstract, returnsReference);
+ZEND_METHOD(ReflectionFunctionAbstract, hasReturnType);
+ZEND_METHOD(ReflectionFunctionAbstract, getReturnType);
+ZEND_METHOD(ReflectionFunctionAbstract, getAttributes);
+ZEND_METHOD(ReflectionFunction, __construct);
+ZEND_METHOD(ReflectionFunction, __toString);
+ZEND_METHOD(ReflectionFunction, isDisabled);
+ZEND_METHOD(ReflectionFunction, invoke);
+ZEND_METHOD(ReflectionFunction, invokeArgs);
+ZEND_METHOD(ReflectionFunction, getClosure);
+ZEND_METHOD(ReflectionGenerator, __construct);
+ZEND_METHOD(ReflectionGenerator, getExecutingLine);
+ZEND_METHOD(ReflectionGenerator, getExecutingFile);
+ZEND_METHOD(ReflectionGenerator, getTrace);
+ZEND_METHOD(ReflectionGenerator, getFunction);
+ZEND_METHOD(ReflectionGenerator, getThis);
+ZEND_METHOD(ReflectionGenerator, getExecutingGenerator);
+ZEND_METHOD(ReflectionMethod, __construct);
+ZEND_METHOD(ReflectionMethod, __toString);
+ZEND_METHOD(ReflectionMethod, isPublic);
+ZEND_METHOD(ReflectionMethod, isPrivate);
+ZEND_METHOD(ReflectionMethod, isProtected);
+ZEND_METHOD(ReflectionMethod, isAbstract);
+ZEND_METHOD(ReflectionMethod, isFinal);
+ZEND_METHOD(ReflectionMethod, isStatic);
+ZEND_METHOD(ReflectionMethod, isConstructor);
+ZEND_METHOD(ReflectionMethod, isDestructor);
+ZEND_METHOD(ReflectionMethod, getClosure);
+ZEND_METHOD(ReflectionMethod, getModifiers);
+ZEND_METHOD(ReflectionMethod, invoke);
+ZEND_METHOD(ReflectionMethod, invokeArgs);
+ZEND_METHOD(ReflectionMethod, getDeclaringClass);
+ZEND_METHOD(ReflectionMethod, getPrototype);
+ZEND_METHOD(ReflectionMethod, setAccessible);
+ZEND_METHOD(ReflectionClass, __construct);
+ZEND_METHOD(ReflectionClass, __toString);
+ZEND_METHOD(ReflectionClass, getName);
+ZEND_METHOD(ReflectionClass, isInternal);
+ZEND_METHOD(ReflectionClass, isUserDefined);
+ZEND_METHOD(ReflectionClass, isAnonymous);
+ZEND_METHOD(ReflectionClass, isInstantiable);
+ZEND_METHOD(ReflectionClass, isCloneable);
+ZEND_METHOD(ReflectionClass, getFileName);
+ZEND_METHOD(ReflectionClass, getStartLine);
+ZEND_METHOD(ReflectionClass, getEndLine);
+ZEND_METHOD(ReflectionClass, getDocComment);
+ZEND_METHOD(ReflectionClass, getConstructor);
+ZEND_METHOD(ReflectionClass, hasMethod);
+ZEND_METHOD(ReflectionClass, getMethod);
+ZEND_METHOD(ReflectionClass, getMethods);
+ZEND_METHOD(ReflectionClass, hasProperty);
+ZEND_METHOD(ReflectionClass, getProperty);
+ZEND_METHOD(ReflectionClass, getProperties);
+ZEND_METHOD(ReflectionClass, hasConstant);
+ZEND_METHOD(ReflectionClass, getConstants);
+ZEND_METHOD(ReflectionClass, getReflectionConstants);
+ZEND_METHOD(ReflectionClass, getConstant);
+ZEND_METHOD(ReflectionClass, getReflectionConstant);
+ZEND_METHOD(ReflectionClass, getInterfaces);
+ZEND_METHOD(ReflectionClass, getInterfaceNames);
+ZEND_METHOD(ReflectionClass, isInterface);
+ZEND_METHOD(ReflectionClass, getTraits);
+ZEND_METHOD(ReflectionClass, getTraitNames);
+ZEND_METHOD(ReflectionClass, getTraitAliases);
+ZEND_METHOD(ReflectionClass, isTrait);
+ZEND_METHOD(ReflectionClass, isAbstract);
+ZEND_METHOD(ReflectionClass, isFinal);
+ZEND_METHOD(ReflectionClass, getModifiers);
+ZEND_METHOD(ReflectionClass, isInstance);
+ZEND_METHOD(ReflectionClass, newInstance);
+ZEND_METHOD(ReflectionClass, newInstanceWithoutConstructor);
+ZEND_METHOD(ReflectionClass, newInstanceArgs);
+ZEND_METHOD(ReflectionClass, getParentClass);
+ZEND_METHOD(ReflectionClass, isSubclassOf);
+ZEND_METHOD(ReflectionClass, getStaticProperties);
+ZEND_METHOD(ReflectionClass, getStaticPropertyValue);
+ZEND_METHOD(ReflectionClass, setStaticPropertyValue);
+ZEND_METHOD(ReflectionClass, getDefaultProperties);
+ZEND_METHOD(ReflectionClass, isIterable);
+ZEND_METHOD(ReflectionClass, implementsInterface);
+ZEND_METHOD(ReflectionClass, getExtension);
+ZEND_METHOD(ReflectionClass, getExtensionName);
+ZEND_METHOD(ReflectionClass, inNamespace);
+ZEND_METHOD(ReflectionClass, getNamespaceName);
+ZEND_METHOD(ReflectionClass, getShortName);
+ZEND_METHOD(ReflectionClass, getAttributes);
+ZEND_METHOD(ReflectionObject, __construct);
+ZEND_METHOD(ReflectionProperty, __construct);
+ZEND_METHOD(ReflectionProperty, __toString);
+ZEND_METHOD(ReflectionProperty, getName);
+ZEND_METHOD(ReflectionProperty, getValue);
+ZEND_METHOD(ReflectionProperty, setValue);
+ZEND_METHOD(ReflectionProperty, isInitialized);
+ZEND_METHOD(ReflectionProperty, isPublic);
+ZEND_METHOD(ReflectionProperty, isPrivate);
+ZEND_METHOD(ReflectionProperty, isProtected);
+ZEND_METHOD(ReflectionProperty, isStatic);
+ZEND_METHOD(ReflectionProperty, isDefault);
+ZEND_METHOD(ReflectionProperty, isPromoted);
+ZEND_METHOD(ReflectionProperty, getModifiers);
+ZEND_METHOD(ReflectionProperty, getDeclaringClass);
+ZEND_METHOD(ReflectionProperty, getDocComment);
+ZEND_METHOD(ReflectionProperty, setAccessible);
+ZEND_METHOD(ReflectionProperty, getType);
+ZEND_METHOD(ReflectionProperty, hasType);
+ZEND_METHOD(ReflectionProperty, hasDefaultValue);
+ZEND_METHOD(ReflectionProperty, getDefaultValue);
+ZEND_METHOD(ReflectionProperty, getAttributes);
+ZEND_METHOD(ReflectionClassConstant, __construct);
+ZEND_METHOD(ReflectionClassConstant, __toString);
+ZEND_METHOD(ReflectionClassConstant, getName);
+ZEND_METHOD(ReflectionClassConstant, getValue);
+ZEND_METHOD(ReflectionClassConstant, isPublic);
+ZEND_METHOD(ReflectionClassConstant, isPrivate);
+ZEND_METHOD(ReflectionClassConstant, isProtected);
+ZEND_METHOD(ReflectionClassConstant, getModifiers);
+ZEND_METHOD(ReflectionClassConstant, getDeclaringClass);
+ZEND_METHOD(ReflectionClassConstant, getDocComment);
+ZEND_METHOD(ReflectionClassConstant, getAttributes);
+ZEND_METHOD(ReflectionParameter, __construct);
+ZEND_METHOD(ReflectionParameter, __toString);
+ZEND_METHOD(ReflectionParameter, getName);
+ZEND_METHOD(ReflectionParameter, isPassedByReference);
+ZEND_METHOD(ReflectionParameter, canBePassedByValue);
+ZEND_METHOD(ReflectionParameter, getDeclaringFunction);
+ZEND_METHOD(ReflectionParameter, getDeclaringClass);
+ZEND_METHOD(ReflectionParameter, getClass);
+ZEND_METHOD(ReflectionParameter, hasType);
+ZEND_METHOD(ReflectionParameter, getType);
+ZEND_METHOD(ReflectionParameter, isArray);
+ZEND_METHOD(ReflectionParameter, isCallable);
+ZEND_METHOD(ReflectionParameter, allowsNull);
+ZEND_METHOD(ReflectionParameter, getPosition);
+ZEND_METHOD(ReflectionParameter, isOptional);
+ZEND_METHOD(ReflectionParameter, isDefaultValueAvailable);
+ZEND_METHOD(ReflectionParameter, getDefaultValue);
+ZEND_METHOD(ReflectionParameter, isDefaultValueConstant);
+ZEND_METHOD(ReflectionParameter, getDefaultValueConstantName);
+ZEND_METHOD(ReflectionParameter, isVariadic);
+ZEND_METHOD(ReflectionParameter, isPromoted);
+ZEND_METHOD(ReflectionParameter, getAttributes);
+ZEND_METHOD(ReflectionType, allowsNull);
+ZEND_METHOD(ReflectionType, __toString);
+ZEND_METHOD(ReflectionNamedType, getName);
+ZEND_METHOD(ReflectionNamedType, isBuiltin);
+ZEND_METHOD(ReflectionUnionType, getTypes);
+ZEND_METHOD(ReflectionExtension, __construct);
+ZEND_METHOD(ReflectionExtension, __toString);
+ZEND_METHOD(ReflectionExtension, getName);
+ZEND_METHOD(ReflectionExtension, getVersion);
+ZEND_METHOD(ReflectionExtension, getFunctions);
+ZEND_METHOD(ReflectionExtension, getConstants);
+ZEND_METHOD(ReflectionExtension, getINIEntries);
+ZEND_METHOD(ReflectionExtension, getClasses);
+ZEND_METHOD(ReflectionExtension, getClassNames);
+ZEND_METHOD(ReflectionExtension, getDependencies);
+ZEND_METHOD(ReflectionExtension, info);
+ZEND_METHOD(ReflectionExtension, isPersistent);
+ZEND_METHOD(ReflectionExtension, isTemporary);
+ZEND_METHOD(ReflectionZendExtension, __construct);
+ZEND_METHOD(ReflectionZendExtension, __toString);
+ZEND_METHOD(ReflectionZendExtension, getName);
+ZEND_METHOD(ReflectionZendExtension, getVersion);
+ZEND_METHOD(ReflectionZendExtension, getAuthor);
+ZEND_METHOD(ReflectionZendExtension, getURL);
+ZEND_METHOD(ReflectionZendExtension, getCopyright);
+ZEND_METHOD(ReflectionReference, fromArrayElement);
+ZEND_METHOD(ReflectionReference, getId);
+ZEND_METHOD(ReflectionReference, __construct);
+ZEND_METHOD(ReflectionAttribute, getName);
+ZEND_METHOD(ReflectionAttribute, getTarget);
+ZEND_METHOD(ReflectionAttribute, isRepeated);
+ZEND_METHOD(ReflectionAttribute, getArguments);
+ZEND_METHOD(ReflectionAttribute, newInstance);
+ZEND_METHOD(ReflectionAttribute, __clone);
+ZEND_METHOD(ReflectionAttribute, __construct);
+
+
+static const zend_function_entry class_ReflectionException_methods[] = {
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_Reflection_methods[] = {
+ ZEND_ME(Reflection, getModifierNames, arginfo_class_Reflection_getModifierNames, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_Reflector_methods[] = {
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionFunctionAbstract_methods[] = {
+ ZEND_MALIAS(ReflectionClass, __clone, __clone, arginfo_class_ReflectionFunctionAbstract___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+ ZEND_ME(ReflectionFunctionAbstract, inNamespace, arginfo_class_ReflectionFunctionAbstract_inNamespace, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, isClosure, arginfo_class_ReflectionFunctionAbstract_isClosure, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, isDeprecated, arginfo_class_ReflectionFunctionAbstract_isDeprecated, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, isInternal, arginfo_class_ReflectionFunctionAbstract_isInternal, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, isUserDefined, arginfo_class_ReflectionFunctionAbstract_isUserDefined, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, isGenerator, arginfo_class_ReflectionFunctionAbstract_isGenerator, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, isVariadic, arginfo_class_ReflectionFunctionAbstract_isVariadic, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getClosureThis, arginfo_class_ReflectionFunctionAbstract_getClosureThis, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getClosureScopeClass, arginfo_class_ReflectionFunctionAbstract_getClosureScopeClass, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getDocComment, arginfo_class_ReflectionFunctionAbstract_getDocComment, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getEndLine, arginfo_class_ReflectionFunctionAbstract_getEndLine, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getExtension, arginfo_class_ReflectionFunctionAbstract_getExtension, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getExtensionName, arginfo_class_ReflectionFunctionAbstract_getExtensionName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getFileName, arginfo_class_ReflectionFunctionAbstract_getFileName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getName, arginfo_class_ReflectionFunctionAbstract_getName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getNamespaceName, arginfo_class_ReflectionFunctionAbstract_getNamespaceName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getNumberOfParameters, arginfo_class_ReflectionFunctionAbstract_getNumberOfParameters, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getNumberOfRequiredParameters, arginfo_class_ReflectionFunctionAbstract_getNumberOfRequiredParameters, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getParameters, arginfo_class_ReflectionFunctionAbstract_getParameters, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getShortName, arginfo_class_ReflectionFunctionAbstract_getShortName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getStartLine, arginfo_class_ReflectionFunctionAbstract_getStartLine, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getStaticVariables, arginfo_class_ReflectionFunctionAbstract_getStaticVariables, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, returnsReference, arginfo_class_ReflectionFunctionAbstract_returnsReference, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, hasReturnType, arginfo_class_ReflectionFunctionAbstract_hasReturnType, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getReturnType, arginfo_class_ReflectionFunctionAbstract_getReturnType, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunctionAbstract, getAttributes, arginfo_class_ReflectionFunctionAbstract_getAttributes, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionFunction_methods[] = {
+ ZEND_ME(ReflectionFunction, __construct, arginfo_class_ReflectionFunction___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunction, __toString, arginfo_class_ReflectionFunction___toString, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunction, isDisabled, arginfo_class_ReflectionFunction_isDisabled, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
+ ZEND_ME(ReflectionFunction, invoke, arginfo_class_ReflectionFunction_invoke, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunction, invokeArgs, arginfo_class_ReflectionFunction_invokeArgs, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionFunction, getClosure, arginfo_class_ReflectionFunction_getClosure, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionGenerator_methods[] = {
+ ZEND_ME(ReflectionGenerator, __construct, arginfo_class_ReflectionGenerator___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionGenerator, getExecutingLine, arginfo_class_ReflectionGenerator_getExecutingLine, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionGenerator, getExecutingFile, arginfo_class_ReflectionGenerator_getExecutingFile, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionGenerator, getTrace, arginfo_class_ReflectionGenerator_getTrace, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionGenerator, getFunction, arginfo_class_ReflectionGenerator_getFunction, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionGenerator, getThis, arginfo_class_ReflectionGenerator_getThis, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionGenerator, getExecutingGenerator, arginfo_class_ReflectionGenerator_getExecutingGenerator, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionMethod_methods[] = {
+ ZEND_ME(ReflectionMethod, __construct, arginfo_class_ReflectionMethod___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, __toString, arginfo_class_ReflectionMethod___toString, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, isPublic, arginfo_class_ReflectionMethod_isPublic, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, isPrivate, arginfo_class_ReflectionMethod_isPrivate, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, isProtected, arginfo_class_ReflectionMethod_isProtected, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, isAbstract, arginfo_class_ReflectionMethod_isAbstract, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, isFinal, arginfo_class_ReflectionMethod_isFinal, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, isStatic, arginfo_class_ReflectionMethod_isStatic, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, isConstructor, arginfo_class_ReflectionMethod_isConstructor, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, isDestructor, arginfo_class_ReflectionMethod_isDestructor, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, getClosure, arginfo_class_ReflectionMethod_getClosure, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, getModifiers, arginfo_class_ReflectionMethod_getModifiers, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, invoke, arginfo_class_ReflectionMethod_invoke, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, invokeArgs, arginfo_class_ReflectionMethod_invokeArgs, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, getDeclaringClass, arginfo_class_ReflectionMethod_getDeclaringClass, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, getPrototype, arginfo_class_ReflectionMethod_getPrototype, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionMethod, setAccessible, arginfo_class_ReflectionMethod_setAccessible, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionClass_methods[] = {
+ ZEND_ME(ReflectionClass, __clone, arginfo_class_ReflectionClass___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+ ZEND_ME(ReflectionClass, __construct, arginfo_class_ReflectionClass___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, __toString, arginfo_class_ReflectionClass___toString, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getName, arginfo_class_ReflectionClass_getName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, isInternal, arginfo_class_ReflectionClass_isInternal, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, isUserDefined, arginfo_class_ReflectionClass_isUserDefined, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, isAnonymous, arginfo_class_ReflectionClass_isAnonymous, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, isInstantiable, arginfo_class_ReflectionClass_isInstantiable, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, isCloneable, arginfo_class_ReflectionClass_isCloneable, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getFileName, arginfo_class_ReflectionClass_getFileName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getStartLine, arginfo_class_ReflectionClass_getStartLine, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getEndLine, arginfo_class_ReflectionClass_getEndLine, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getDocComment, arginfo_class_ReflectionClass_getDocComment, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getConstructor, arginfo_class_ReflectionClass_getConstructor, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, hasMethod, arginfo_class_ReflectionClass_hasMethod, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getMethod, arginfo_class_ReflectionClass_getMethod, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getMethods, arginfo_class_ReflectionClass_getMethods, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, hasProperty, arginfo_class_ReflectionClass_hasProperty, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getProperty, arginfo_class_ReflectionClass_getProperty, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getProperties, arginfo_class_ReflectionClass_getProperties, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, hasConstant, arginfo_class_ReflectionClass_hasConstant, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getConstants, arginfo_class_ReflectionClass_getConstants, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getReflectionConstants, arginfo_class_ReflectionClass_getReflectionConstants, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getConstant, arginfo_class_ReflectionClass_getConstant, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getReflectionConstant, arginfo_class_ReflectionClass_getReflectionConstant, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getInterfaces, arginfo_class_ReflectionClass_getInterfaces, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getInterfaceNames, arginfo_class_ReflectionClass_getInterfaceNames, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, isInterface, arginfo_class_ReflectionClass_isInterface, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getTraits, arginfo_class_ReflectionClass_getTraits, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getTraitNames, arginfo_class_ReflectionClass_getTraitNames, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getTraitAliases, arginfo_class_ReflectionClass_getTraitAliases, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, isTrait, arginfo_class_ReflectionClass_isTrait, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, isAbstract, arginfo_class_ReflectionClass_isAbstract, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, isFinal, arginfo_class_ReflectionClass_isFinal, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getModifiers, arginfo_class_ReflectionClass_getModifiers, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, isInstance, arginfo_class_ReflectionClass_isInstance, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, newInstance, arginfo_class_ReflectionClass_newInstance, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, newInstanceWithoutConstructor, arginfo_class_ReflectionClass_newInstanceWithoutConstructor, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, newInstanceArgs, arginfo_class_ReflectionClass_newInstanceArgs, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getParentClass, arginfo_class_ReflectionClass_getParentClass, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, isSubclassOf, arginfo_class_ReflectionClass_isSubclassOf, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getStaticProperties, arginfo_class_ReflectionClass_getStaticProperties, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getStaticPropertyValue, arginfo_class_ReflectionClass_getStaticPropertyValue, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, setStaticPropertyValue, arginfo_class_ReflectionClass_setStaticPropertyValue, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getDefaultProperties, arginfo_class_ReflectionClass_getDefaultProperties, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, isIterable, arginfo_class_ReflectionClass_isIterable, ZEND_ACC_PUBLIC)
+ ZEND_MALIAS(ReflectionClass, isIterateable, isIterable, arginfo_class_ReflectionClass_isIterateable, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, implementsInterface, arginfo_class_ReflectionClass_implementsInterface, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getExtension, arginfo_class_ReflectionClass_getExtension, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getExtensionName, arginfo_class_ReflectionClass_getExtensionName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, inNamespace, arginfo_class_ReflectionClass_inNamespace, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getNamespaceName, arginfo_class_ReflectionClass_getNamespaceName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getShortName, arginfo_class_ReflectionClass_getShortName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClass, getAttributes, arginfo_class_ReflectionClass_getAttributes, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionObject_methods[] = {
+ ZEND_ME(ReflectionObject, __construct, arginfo_class_ReflectionObject___construct, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionProperty_methods[] = {
+ ZEND_MALIAS(ReflectionClass, __clone, __clone, arginfo_class_ReflectionProperty___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+ ZEND_ME(ReflectionProperty, __construct, arginfo_class_ReflectionProperty___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, __toString, arginfo_class_ReflectionProperty___toString, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, getName, arginfo_class_ReflectionProperty_getName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, getValue, arginfo_class_ReflectionProperty_getValue, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, setValue, arginfo_class_ReflectionProperty_setValue, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, isInitialized, arginfo_class_ReflectionProperty_isInitialized, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, isPublic, arginfo_class_ReflectionProperty_isPublic, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, isPrivate, arginfo_class_ReflectionProperty_isPrivate, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, isProtected, arginfo_class_ReflectionProperty_isProtected, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, isStatic, arginfo_class_ReflectionProperty_isStatic, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, isDefault, arginfo_class_ReflectionProperty_isDefault, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, isPromoted, arginfo_class_ReflectionProperty_isPromoted, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, getModifiers, arginfo_class_ReflectionProperty_getModifiers, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, getDeclaringClass, arginfo_class_ReflectionProperty_getDeclaringClass, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, getDocComment, arginfo_class_ReflectionProperty_getDocComment, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, setAccessible, arginfo_class_ReflectionProperty_setAccessible, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, getType, arginfo_class_ReflectionProperty_getType, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, hasType, arginfo_class_ReflectionProperty_hasType, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, hasDefaultValue, arginfo_class_ReflectionProperty_hasDefaultValue, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, getDefaultValue, arginfo_class_ReflectionProperty_getDefaultValue, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionProperty, getAttributes, arginfo_class_ReflectionProperty_getAttributes, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionClassConstant_methods[] = {
+ ZEND_MALIAS(ReflectionClass, __clone, __clone, arginfo_class_ReflectionClassConstant___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+ ZEND_ME(ReflectionClassConstant, __construct, arginfo_class_ReflectionClassConstant___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClassConstant, __toString, arginfo_class_ReflectionClassConstant___toString, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClassConstant, getName, arginfo_class_ReflectionClassConstant_getName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClassConstant, getValue, arginfo_class_ReflectionClassConstant_getValue, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClassConstant, isPublic, arginfo_class_ReflectionClassConstant_isPublic, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClassConstant, isPrivate, arginfo_class_ReflectionClassConstant_isPrivate, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClassConstant, isProtected, arginfo_class_ReflectionClassConstant_isProtected, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClassConstant, getModifiers, arginfo_class_ReflectionClassConstant_getModifiers, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClassConstant, getDeclaringClass, arginfo_class_ReflectionClassConstant_getDeclaringClass, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClassConstant, getDocComment, arginfo_class_ReflectionClassConstant_getDocComment, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClassConstant, getAttributes, arginfo_class_ReflectionClassConstant_getAttributes, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionParameter_methods[] = {
+ ZEND_MALIAS(ReflectionClass, __clone, __clone, arginfo_class_ReflectionParameter___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+ ZEND_ME(ReflectionParameter, __construct, arginfo_class_ReflectionParameter___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, __toString, arginfo_class_ReflectionParameter___toString, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, getName, arginfo_class_ReflectionParameter_getName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, isPassedByReference, arginfo_class_ReflectionParameter_isPassedByReference, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, canBePassedByValue, arginfo_class_ReflectionParameter_canBePassedByValue, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, getDeclaringFunction, arginfo_class_ReflectionParameter_getDeclaringFunction, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, getDeclaringClass, arginfo_class_ReflectionParameter_getDeclaringClass, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, getClass, arginfo_class_ReflectionParameter_getClass, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
+ ZEND_ME(ReflectionParameter, hasType, arginfo_class_ReflectionParameter_hasType, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, getType, arginfo_class_ReflectionParameter_getType, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, isArray, arginfo_class_ReflectionParameter_isArray, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
+ ZEND_ME(ReflectionParameter, isCallable, arginfo_class_ReflectionParameter_isCallable, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
+ ZEND_ME(ReflectionParameter, allowsNull, arginfo_class_ReflectionParameter_allowsNull, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, getPosition, arginfo_class_ReflectionParameter_getPosition, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, isOptional, arginfo_class_ReflectionParameter_isOptional, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, isDefaultValueAvailable, arginfo_class_ReflectionParameter_isDefaultValueAvailable, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, getDefaultValue, arginfo_class_ReflectionParameter_getDefaultValue, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, isDefaultValueConstant, arginfo_class_ReflectionParameter_isDefaultValueConstant, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, getDefaultValueConstantName, arginfo_class_ReflectionParameter_getDefaultValueConstantName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, isVariadic, arginfo_class_ReflectionParameter_isVariadic, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, isPromoted, arginfo_class_ReflectionParameter_isPromoted, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionParameter, getAttributes, arginfo_class_ReflectionParameter_getAttributes, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionType_methods[] = {
+ ZEND_MALIAS(ReflectionClass, __clone, __clone, arginfo_class_ReflectionType___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+ ZEND_ME(ReflectionType, allowsNull, arginfo_class_ReflectionType_allowsNull, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionType, __toString, arginfo_class_ReflectionType___toString, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionNamedType_methods[] = {
+ ZEND_ME(ReflectionNamedType, getName, arginfo_class_ReflectionNamedType_getName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionNamedType, isBuiltin, arginfo_class_ReflectionNamedType_isBuiltin, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionUnionType_methods[] = {
+ ZEND_ME(ReflectionUnionType, getTypes, arginfo_class_ReflectionUnionType_getTypes, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionExtension_methods[] = {
+ ZEND_MALIAS(ReflectionClass, __clone, __clone, arginfo_class_ReflectionExtension___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+ ZEND_ME(ReflectionExtension, __construct, arginfo_class_ReflectionExtension___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionExtension, __toString, arginfo_class_ReflectionExtension___toString, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionExtension, getName, arginfo_class_ReflectionExtension_getName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionExtension, getVersion, arginfo_class_ReflectionExtension_getVersion, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionExtension, getFunctions, arginfo_class_ReflectionExtension_getFunctions, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionExtension, getConstants, arginfo_class_ReflectionExtension_getConstants, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionExtension, getINIEntries, arginfo_class_ReflectionExtension_getINIEntries, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionExtension, getClasses, arginfo_class_ReflectionExtension_getClasses, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionExtension, getClassNames, arginfo_class_ReflectionExtension_getClassNames, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionExtension, getDependencies, arginfo_class_ReflectionExtension_getDependencies, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionExtension, info, arginfo_class_ReflectionExtension_info, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionExtension, isPersistent, arginfo_class_ReflectionExtension_isPersistent, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionExtension, isTemporary, arginfo_class_ReflectionExtension_isTemporary, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionZendExtension_methods[] = {
+ ZEND_MALIAS(ReflectionClass, __clone, __clone, arginfo_class_ReflectionZendExtension___clone, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
+ ZEND_ME(ReflectionZendExtension, __construct, arginfo_class_ReflectionZendExtension___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionZendExtension, __toString, arginfo_class_ReflectionZendExtension___toString, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionZendExtension, getName, arginfo_class_ReflectionZendExtension_getName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionZendExtension, getVersion, arginfo_class_ReflectionZendExtension_getVersion, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionZendExtension, getAuthor, arginfo_class_ReflectionZendExtension_getAuthor, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionZendExtension, getURL, arginfo_class_ReflectionZendExtension_getURL, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionZendExtension, getCopyright, arginfo_class_ReflectionZendExtension_getCopyright, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionReference_methods[] = {
+ ZEND_ME(ReflectionReference, fromArrayElement, arginfo_class_ReflectionReference_fromArrayElement, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+ ZEND_ME(ReflectionReference, getId, arginfo_class_ReflectionReference_getId, ZEND_ACC_PUBLIC)
+ ZEND_MALIAS(ReflectionClass, __clone, __clone, arginfo_class_ReflectionReference___clone, ZEND_ACC_PRIVATE)
+ ZEND_ME(ReflectionReference, __construct, arginfo_class_ReflectionReference___construct, ZEND_ACC_PRIVATE)
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_ReflectionAttribute_methods[] = {
+ ZEND_ME(ReflectionAttribute, getName, arginfo_class_ReflectionAttribute_getName, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionAttribute, getTarget, arginfo_class_ReflectionAttribute_getTarget, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionAttribute, isRepeated, arginfo_class_ReflectionAttribute_isRepeated, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionAttribute, getArguments, arginfo_class_ReflectionAttribute_getArguments, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionAttribute, newInstance, arginfo_class_ReflectionAttribute_newInstance, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionAttribute, __clone, arginfo_class_ReflectionAttribute___clone, ZEND_ACC_PRIVATE)
+ ZEND_ME(ReflectionAttribute, __construct, arginfo_class_ReflectionAttribute___construct, ZEND_ACC_PRIVATE)
+ ZEND_FE_END
+};
diff --git a/ext/reflection/tests/001.phpt b/ext/reflection/tests/001.phpt
index f68afc950e..7812679ba7 100644
--- a/ext/reflection/tests/001.phpt
+++ b/ext/reflection/tests/001.phpt
@@ -5,24 +5,23 @@ Reflection inheritance
class ReflectionClassEx extends ReflectionClass
{
- public $bla;
+ public $bla;
- function getMethodNames()
- {
- $res = array();
- foreach($this->getMethods() as $m)
- {
- $res[] = $m->class . '::' . $m->name;
- }
- return $res;
- }
+ 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',
@@ -62,10 +61,10 @@ $res = $r->getMethodNames();
foreach($exp as $m)
{
- if (!in_array($m, $exp))
- {
- $miss[] = $m;
- }
+ if (!in_array($m, $exp))
+ {
+ $miss[] = $m;
+ }
}
var_dump($miss);
@@ -75,7 +74,6 @@ sort($props);
var_dump($props);
var_dump($r->name);
?>
-===DONE===
--EXPECT--
array(0) {
}
@@ -86,4 +84,3 @@ array(2) {
string(4) "name"
}
string(17) "ReflectionClassEx"
-===DONE===
diff --git a/ext/reflection/tests/002.phpt b/ext/reflection/tests/002.phpt
index d0fcb32bea..b10013d2a9 100644
--- a/ext/reflection/tests/002.phpt
+++ b/ext/reflection/tests/002.phpt
@@ -5,13 +5,13 @@ Reflection properties are read only
class ReflectionMethodEx extends ReflectionMethod
{
- public $foo = "xyz";
+ public $foo = "xyz";
- function __construct($c,$m)
- {
- echo __METHOD__ . "\n";
- parent::__construct($c,$m);
- }
+ function __construct($c,$m)
+ {
+ echo __METHOD__ . "\n";
+ parent::__construct($c,$m);
+ }
}
$r = new ReflectionMethodEx('ReflectionMethodEx','getName');
@@ -23,11 +23,11 @@ var_dump($r->foo);
try
{
- $r->class = 'bullshit';
+ $r->class = 'bullshit';
}
catch(ReflectionException $e)
{
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try
{
@@ -35,7 +35,7 @@ $r->name = 'bullshit';
}
catch(ReflectionException $e)
{
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
$r->foo = 'bar';
@@ -47,7 +47,6 @@ var_dump($r->foo);
var_dump($r->bar);
?>
-===DONE===
--EXPECT--
ReflectionMethodEx::__construct
string(26) "ReflectionFunctionAbstract"
@@ -60,4 +59,3 @@ string(26) "ReflectionFunctionAbstract"
string(7) "getName"
string(3) "bar"
string(3) "baz"
-===DONE===
diff --git a/ext/reflection/tests/003.phpt b/ext/reflection/tests/003.phpt
index 80bf0a6513..dbafebfb8d 100644
--- a/ext/reflection/tests/003.phpt
+++ b/ext/reflection/tests/003.phpt
@@ -5,18 +5,18 @@ ReflectionMethod::invoke() with base class method
class Foo
{
- function Test()
- {
- echo __METHOD__ . "\n";
- }
+ function Test()
+ {
+ echo __METHOD__ . "\n";
+ }
}
class Bar extends Foo
{
- function Test()
- {
- echo __METHOD__ . "\n";
- }
+ function Test()
+ {
+ echo __METHOD__ . "\n";
+ }
}
$o = new Bar;
@@ -25,7 +25,5 @@ $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
index 36ae406b43..3739d2e55c 100644
--- a/ext/reflection/tests/004.phpt
+++ b/ext/reflection/tests/004.phpt
@@ -4,8 +4,8 @@ ReflectionMethod::invoke() with non object or null value
<?php
class a {
- function a(){
- }
+ function __construct(){
+ }
}
class b {
}
@@ -13,7 +13,7 @@ class b {
$b = new b();
$a=new ReflectionClass("a");
-$m=$a->getMethod("a");
+$m=$a->getMethod("__construct");
try {
$m->invoke(null);
@@ -35,9 +35,7 @@ try {
echo $E->getMessage()."\n";
}
-echo "===DONE===\n";?>
---EXPECTF--
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; a has a deprecated constructor in %s on line %d
-Trying to invoke non static method a::a() without an object
+?>
+--EXPECT--
+Trying to invoke non static method a::__construct() without an object
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
index e40fcc3099..58411f98c8 100644
--- a/ext/reflection/tests/005.phpt
+++ b/ext/reflection/tests/005.phpt
@@ -7,18 +7,18 @@ opcache.save_comments=1
function strip_doc_comment($c)
{
- if (!strlen($c) || $c === false) return $c;
- return trim(substr($c, 3, -2));
+ if (!strlen($c) || $c === false) return $c;
+ return trim(substr($c, 3, -2));
}
/** Comment for class A */
class A
{
- /** Method A::bla()
- */
- function bla()
- {
- }
+ /** Method A::bla()
+ */
+ function bla()
+ {
+ }
function foo() {
/**
@@ -42,15 +42,13 @@ var_dump(strip_doc_comment($r->getDocComment()));
foreach($r->getMethods() as $m)
{
- var_dump(strip_doc_comment($m->getDocComment()));
+ 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
index 0e33e0a6a1..2b03f3e694 100644
--- a/ext/reflection/tests/006.phpt
+++ b/ext/reflection/tests/006.phpt
@@ -9,81 +9,79 @@ ReflectionClass::[gs]etStaticPropertyValue
Class Test
{
- static public $pub = 'pub';
- static protected $pro = 'pro';
- static private $pri = 'pri';
+ static public $pub = 'pub';
+ static protected $pro = 'pro';
+ static private $pri = 'pri';
- static function testing()
- {
- $ref = new ReflectionClass('Test');
+ 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";
- }
- }
- }
+ 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 private $pri = 'pri';
- static function testing()
- {
- $ref = new ReflectionClass('Test');
+ 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";
- }
- }
- }
+ 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";
- }
+ 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"
@@ -112,4 +110,3 @@ string(7) "updated"
string(7) "updated"
string(7) "updated"
string(7) "updated"
-===DONE===
diff --git a/ext/reflection/tests/007.phpt b/ext/reflection/tests/007.phpt
index 8babf24282..53622ec19c 100644
--- a/ext/reflection/tests/007.phpt
+++ b/ext/reflection/tests/007.phpt
@@ -5,56 +5,56 @@ ReflectionClass::newInstance[Args]
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());
- }
- catch (Throwable $e)
- {
- echo "Exception: " . $e->getMessage() . "\n";
- }
-
- 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";
+ 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());
+ }
+ catch (Throwable $e)
+ {
+ echo "Exception: " . $e->getMessage() . "\n";
+ }
+
+ 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";
}
spl_autoload_register(function ($class) {
- echo __FUNCTION__ . "($class)\n";
+ echo __FUNCTION__ . "($class)\n";
});
test('Class_does_not_exist');
@@ -67,33 +67,31 @@ test('NoCtor');
Class WithCtor
{
- function __construct()
- {
- echo __METHOD__ . "()\n";
- var_dump(func_get_args());
- }
+ 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());
- }
+ function __construct($arg)
+ {
+ echo __METHOD__ . "($arg)\n";
+ var_dump(func_get_args());
+ }
}
test('WithCtorWithArgs');
?>
-===DONE===
-<?php exit(0); ?>
--EXPECTF--
====>Class_does_not_exist
{closure}(Class_does_not_exist)
-string(41) "Class Class_does_not_exist does not exist"
+string(43) "Class "Class_does_not_exist" does not exist"
====>NoCtor
====>newInstance()
object(NoCtor)#%d (0) {
@@ -150,5 +148,3 @@ array(2) {
}
object(WithCtorWithArgs)#%d (0) {
}
-
-===DONE===
diff --git a/ext/reflection/tests/008.phpt b/ext/reflection/tests/008.phpt
index 80a4a39218..d33aa23a9f 100644
--- a/ext/reflection/tests/008.phpt
+++ b/ext/reflection/tests/008.phpt
@@ -6,34 +6,34 @@ ReflectionMethod::__construct() tests
$a = array("", 1, "::", "a::", "::b", "a::b");
foreach ($a as $val) {
- try {
- new ReflectionMethod($val);
- } catch (Exception $e) {
- var_dump($e->getMessage());
- }
+ 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());
- }
+ try {
+ new ReflectionMethod($val, $b[$key]);
+ } catch (Exception $e) {
+ var_dump($e->getMessage());
+ }
}
echo "Done\n";
?>
--EXPECT--
-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"
+string(90) "ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name"
+string(90) "ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name"
+string(23) "Class "" does not exist"
+string(24) "Class "a" does not exist"
+string(23) "Class "" does not exist"
+string(24) "Class "a" does not exist"
+string(23) "Class "" does not exist"
+string(24) "Class "1" does not exist"
+string(23) "Class "" does not exist"
Done
diff --git a/ext/reflection/tests/009.phpt b/ext/reflection/tests/009.phpt
index d582623cbd..8a57ed9d1d 100644
--- a/ext/reflection/tests/009.phpt
+++ b/ext/reflection/tests/009.phpt
@@ -9,7 +9,7 @@ opcache.save_comments=1
hoho
*/
function test ($a, $b = 1, $c = "") {
- static $var = 1;
+ static $var = 1;
}
$func = new ReflectionFunction("test");
diff --git a/ext/reflection/tests/010.phpt b/ext/reflection/tests/010.phpt
index 8345dc35bf..ae1e4dff0b 100644
--- a/ext/reflection/tests/010.phpt
+++ b/ext/reflection/tests/010.phpt
@@ -1,14 +1,14 @@
--TEST--
-ReflectionMethod::__toString() tests (overriden method)
+ReflectionMethod::__toString() tests (overridden method)
--FILE--
<?php
class Foo {
- function func() {
- }
+ function func() {
+ }
}
class Bar extends Foo {
- function func() {
- }
+ function func() {
+ }
}
$m = new ReflectionMethod("Bar::func");
echo $m;
diff --git a/ext/reflection/tests/012.phpt b/ext/reflection/tests/012.phpt
index d2d1c5f384..4eeeb98f3d 100644
--- a/ext/reflection/tests/012.phpt
+++ b/ext/reflection/tests/012.phpt
@@ -3,7 +3,7 @@ ReflectionClass::getDefaultProperties()
--FILE--
<?php
class Foo {
- public $test = "ok";
+ public $test = "ok";
}
$class = new ReflectionClass("Foo");
$props = $class->getDefaultProperties();
diff --git a/ext/reflection/tests/017.phpt b/ext/reflection/tests/017.phpt
index 322065bf20..be306b53c6 100644
--- a/ext/reflection/tests/017.phpt
+++ b/ext/reflection/tests/017.phpt
@@ -3,7 +3,7 @@ ReflectionClass::__toString() (constants)
--FILE--
<?php
class Foo {
- const test = "ok";
+ const test = "ok";
}
$class = new ReflectionClass("Foo");
echo $class;
diff --git a/ext/reflection/tests/020.phpt b/ext/reflection/tests/020.phpt
index 13ae6fe275..491eed7d1f 100644
--- a/ext/reflection/tests/020.phpt
+++ b/ext/reflection/tests/020.phpt
@@ -3,14 +3,14 @@ ReflectionObject::hasProperty
--FILE--
<?php
class Foo {
- public $p1;
- protected $p2;
- private $p3;
+ public $p1;
+ protected $p2;
+ private $p3;
- function __isset($name) {
- var_dump($name);
- return false;
- }
+ function __isset($name) {
+ var_dump($name);
+ return false;
+ }
}
$obj = new ReflectionObject(new Foo());
var_dump($obj->hasProperty("p1"));
diff --git a/ext/reflection/tests/021.phpt b/ext/reflection/tests/021.phpt
index 42d11cc445..fefcf34e78 100644
--- a/ext/reflection/tests/021.phpt
+++ b/ext/reflection/tests/021.phpt
@@ -3,7 +3,7 @@ ReflectionClass::hasConstant
--FILE--
<?php
class Foo {
- const c1 = 1;
+ const c1 = 1;
}
$class = new ReflectionClass("Foo");
var_dump($class->hasConstant("c1"));
diff --git a/ext/reflection/tests/022.phpt b/ext/reflection/tests/022.phpt
index 2cfd603dad..4a6738f97c 100644
--- a/ext/reflection/tests/022.phpt
+++ b/ext/reflection/tests/022.phpt
@@ -3,7 +3,7 @@ ReflectionClass::getConstant
--FILE--
<?php
class Foo {
- const c1 = 1;
+ const c1 = 1;
}
$class = new ReflectionClass("Foo");
var_dump($class->getConstant("c1"));
diff --git a/ext/reflection/tests/023.phpt b/ext/reflection/tests/023.phpt
index fe10b2531a..7f8c500015 100644
--- a/ext/reflection/tests/023.phpt
+++ b/ext/reflection/tests/023.phpt
@@ -3,14 +3,14 @@ ReflectionClass::getDefaultProperties (filtering parent privates)
--FILE--
<?php
class C1 {
- private $p1 = 1;
- protected $p2 = 2;
- public $p3 = 3;
+ private $p1 = 1;
+ protected $p2 = 2;
+ public $p3 = 3;
}
class C2 extends C1 {
- private $p4 = 4;
- protected $p5 = 5;
- public $p6 = 6;
+ private $p4 = 4;
+ protected $p5 = 5;
+ public $p6 = 6;
}
$class = new ReflectionClass("C2");
var_dump($class->getDefaultProperties());
diff --git a/ext/reflection/tests/024.phpt b/ext/reflection/tests/024.phpt
index 2b894d3f31..46db75c911 100644
--- a/ext/reflection/tests/024.phpt
+++ b/ext/reflection/tests/024.phpt
@@ -3,9 +3,9 @@ ReflectionObject::__toString (filtering privates/protected dynamic properties)
--FILE--
<?php
class C1 {
- private $p1 = 1;
- protected $p2 = 2;
- public $p3 = 3;
+ private $p1 = 1;
+ protected $p2 = 2;
+ public $p3 = 3;
}
$x = new C1();
@@ -29,9 +29,9 @@ Object of class [ <user> class C1 ] {
}
- Properties [3] {
- Property [ <default> private $p1 ]
- Property [ <default> protected $p2 ]
- Property [ <default> public $p3 ]
+ Property [ private $p1 = 1 ]
+ Property [ protected $p2 = 2 ]
+ Property [ public $p3 = 3 ]
}
- Dynamic properties [1] {
diff --git a/ext/reflection/tests/025.phpt b/ext/reflection/tests/025.phpt
index c18a0f5b8e..2e3316d3c0 100644
--- a/ext/reflection/tests/025.phpt
+++ b/ext/reflection/tests/025.phpt
@@ -9,7 +9,7 @@ opcache.save_comments=1
hoho
*/
function test ($a, $b = 1, $c = "") {
- static $var = 1;
+ static $var = 1;
}
$func = new ReflectionFunction("test");
diff --git a/ext/reflection/tests/027.phpt b/ext/reflection/tests/027.phpt
index e750682ab6..add38f1476 100644
--- a/ext/reflection/tests/027.phpt
+++ b/ext/reflection/tests/027.phpt
@@ -4,7 +4,7 @@ ReflectionGenerator::getTrace()
<?php
function foo()
{
- yield 1;
+ yield 1;
}
$g = foo();
@@ -13,9 +13,9 @@ $r = new ReflectionGenerator($g);
$g->next();
try {
- $r->getTrace();
+ $r->getTrace();
} catch (ReflectionException $e) {
- echo $e->getMessage();
+ echo $e->getMessage();
}
?>
--EXPECT--
diff --git a/ext/reflection/tests/028.phpt b/ext/reflection/tests/028.phpt
index ed6950fce3..bf16785c18 100644
--- a/ext/reflection/tests/028.phpt
+++ b/ext/reflection/tests/028.phpt
@@ -4,16 +4,16 @@ ReflectionGenerator::__construct()
<?php
function foo()
{
- yield 1;
+ yield 1;
}
$g = foo();
$g->next();
try {
- $r = new ReflectionGenerator($g);
+ $r = new ReflectionGenerator($g);
} catch (ReflectionException $e) {
- echo "Done!\n";
+ echo "Done!\n";
}
?>
--EXPECT--
diff --git a/ext/reflection/tests/ReflectionAttribute_final.phpt b/ext/reflection/tests/ReflectionAttribute_final.phpt
new file mode 100644
index 0000000000..f2899d9724
--- /dev/null
+++ b/ext/reflection/tests/ReflectionAttribute_final.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Check that ReflectionAttribute is final
+--FILE--
+<?php
+
+class T extends ReflectionAttribute {}
+
+?>
+--EXPECTF--
+Fatal error: Class T may not inherit from final class (ReflectionAttribute) in %s on line %d
diff --git a/ext/reflection/tests/ReflectionClassConstant_basic1.phpt b/ext/reflection/tests/ReflectionClassConstant_basic1.phpt
index 181360d733..2ab8990d95 100644
--- a/ext/reflection/tests/ReflectionClassConstant_basic1.phpt
+++ b/ext/reflection/tests/ReflectionClassConstant_basic1.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test usage of ReflectionClassConstant methods __toString(), export(), getName(), getValue(), isPublic(), isPrivate(), isProtected(), getModifiers(), getDeclaringClass() and getDocComment().
+Test usage of ReflectionClassConstant methods __toString(), getName(), getValue(), isPublic(), isPrivate(), isProtected(), getModifiers(), getDeclaringClass() and getDocComment().
--FILE--
<?php
@@ -10,10 +10,6 @@ function reflectClassConstant($base, $constant) {
echo "Reflecting on class constant $class::$constant\n\n";
echo "__toString():\n";
var_dump($constInfo->__toString());
- echo "export():\n";
- var_dump(ReflectionClassConstant::export($base, $constant, true));
- echo "export():\n";
- var_dump(ReflectionClassConstant::export($base, $constant, false));
echo "getName():\n";
var_dump($constInfo->getName());
echo "getValue():\n";
@@ -55,17 +51,6 @@ Reflecting on class constant TestClass::PUB
__toString():
string(35) "Constant [ public bool PUB ] { 1 }
"
-export():
-
-Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d
-string(35) "Constant [ public bool PUB ] { 1 }
-"
-export():
-
-Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d
-Constant [ public bool PUB ] { 1 }
-
-NULL
getName():
string(3) "PUB"
getValue():
@@ -93,17 +78,6 @@ Reflecting on class constant TestClass::PROT
__toString():
string(38) "Constant [ protected int PROT ] { 4 }
"
-export():
-
-Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d
-string(38) "Constant [ protected int PROT ] { 4 }
-"
-export():
-
-Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d
-Constant [ protected int PROT ] { 4 }
-
-NULL
getName():
string(4) "PROT"
getValue():
@@ -131,17 +105,6 @@ Reflecting on class constant TestClass::PRIV
__toString():
string(45) "Constant [ private string PRIV ] { keepOut }
"
-export():
-
-Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d
-string(45) "Constant [ private string PRIV ] { keepOut }
-"
-export():
-
-Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d
-Constant [ private string PRIV ] { keepOut }
-
-NULL
getName():
string(4) "PRIV"
getValue():
@@ -169,17 +132,6 @@ Reflecting on class constant TestClass::PRIV
__toString():
string(45) "Constant [ private string PRIV ] { keepOut }
"
-export():
-
-Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d
-string(45) "Constant [ private string PRIV ] { keepOut }
-"
-export():
-
-Deprecated: Function ReflectionClassConstant::export() is deprecated in %s on line %d
-Constant [ private string PRIV ] { keepOut }
-
-NULL
getName():
string(4) "PRIV"
getValue():
@@ -202,7 +154,7 @@ bool(false)
**********************************
-Fatal error: Uncaught ReflectionException: Class Constant TestClass::BAD_CONST does not exist in %s:%d
+Fatal error: Uncaught ReflectionException: Constant TestClass::BAD_CONST does not exist in %s:%d
Stack trace:
#0 %s(%d): ReflectionClassConstant->__construct(Object(TestClass), 'BAD_CONST')
#1 %s(%d): reflectClassConstant(Object(TestClass), 'BAD_CONST')
diff --git a/ext/reflection/tests/ReflectionClassConstant_toString_error.phpt b/ext/reflection/tests/ReflectionClassConstant_toString_error.phpt
index cd4dfa3765..54290e97aa 100644
--- a/ext/reflection/tests/ReflectionClassConstant_toString_error.phpt
+++ b/ext/reflection/tests/ReflectionClassConstant_toString_error.phpt
@@ -15,4 +15,4 @@ try {
?>
--EXPECT--
-Undefined class constant 'self::UNKNOWN'
+Undefined constant self::UNKNOWN
diff --git a/ext/reflection/tests/ReflectionClass_constructor_001.phpt b/ext/reflection/tests/ReflectionClass_constructor_001.phpt
index 1a70fe1f59..0d4fa670c3 100644
--- a/ext/reflection/tests/ReflectionClass_constructor_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_constructor_001.phpt
@@ -8,10 +8,10 @@ $myInstance = new stdClass;
$r2 = new ReflectionClass($myInstance);
class TrickClass {
- function __toString() {
- //Return the name of another class
- return "Exception";
- }
+ function __toString() {
+ //Return the name of another class
+ return "Exception";
+ }
}
$myTrickClass = new TrickClass;
$r3 = new ReflectionClass($myTrickClass);
diff --git a/ext/reflection/tests/ReflectionClass_constructor_002.phpt b/ext/reflection/tests/ReflectionClass_constructor_002.phpt
index c463bb72c1..7df620eaaa 100644
--- a/ext/reflection/tests/ReflectionClass_constructor_002.phpt
+++ b/ext/reflection/tests/ReflectionClass_constructor_002.phpt
@@ -3,64 +3,53 @@ ReflectionClass::__constructor() - bad arguments
--FILE--
<?php
try {
- var_dump(new ReflectionClass());
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump(new ReflectionClass());
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump(new ReflectionClass(null));
+ var_dump(new ReflectionClass(null));
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump(new ReflectionClass(true));
+ var_dump(new ReflectionClass(true));
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump(new ReflectionClass(1));
+ var_dump(new ReflectionClass(1));
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump(new ReflectionClass(array(1,2,3)));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump(new ReflectionClass(array(1,2,3)));
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump(new ReflectionClass("stdClass", 1));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump(new ReflectionClass("stdClass", 1));
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump(new ReflectionClass("X"));
+ var_dump(new ReflectionClass("X"));
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ 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
+--EXPECT--
+ReflectionClass::__construct() expects exactly 1 argument, 0 given
+Class "" does not exist
+Class "1" does not exist
+Class "1" does not exist
+ReflectionClass::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given
+ReflectionClass::__construct() expects exactly 1 argument, 2 given
+Class "X" does not exist
diff --git a/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt b/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt
index 80d2be2585..2e050af209 100644
--- a/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt
+++ b/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt
@@ -3,8 +3,8 @@ ReflectionClass::__toString() - array constants
--FILE--
<?php
Class A {
- const A = 8;
- const B = ["a", "b"];
+ const A = 8;
+ const B = ["a", "b"];
}
echo new ReflectionClass("A"), "\n";
?>
diff --git a/ext/reflection/tests/ReflectionClass_export_basic1.phpt b/ext/reflection/tests/ReflectionClass_export_basic1.phpt
index d9183442c4..318e47b355 100644
--- a/ext/reflection/tests/ReflectionClass_export_basic1.phpt
+++ b/ext/reflection/tests/ReflectionClass_export_basic1.phpt
@@ -3,15 +3,15 @@ ReflectionClass::__toString() - 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) {}
+ 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 { }
@@ -50,12 +50,12 @@ Class [ <user> class C extends A ] {
- Parameters [8] {
Parameter #0 [ <required> A $a ]
Parameter #1 [ <required> $b ]
- Parameter #2 [ <optional> C or NULL $c = NULL ]
+ Parameter #2 [ <optional> ?C $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 ]
+ Parameter #7 [ <optional> ?array $h = NULL ]
}
}
}
diff --git a/ext/reflection/tests/ReflectionClass_export_basic2.phpt b/ext/reflection/tests/ReflectionClass_export_basic2.phpt
index 12cee4e6e3..5ed4ad5d7b 100644
--- a/ext/reflection/tests/ReflectionClass_export_basic2.phpt
+++ b/ext/reflection/tests/ReflectionClass_export_basic2.phpt
@@ -3,8 +3,10 @@ ReflectionClass::__toString() - ensure inherited private props are hidden.
--FILE--
<?php
Class c {
- private $a;
- static private $b;
+ private $a;
+ static private $b;
+ public ?int $c = 42;
+ public Foo $d;
}
class d extends c {}
@@ -14,20 +16,22 @@ echo new ReflectionClass("d"), "\n";
?>
--EXPECTF--
Class [ <user> class c ] {
- @@ %s 2-5
+ @@ %s 2-7
- Constants [0] {
}
- Static properties [1] {
- Property [ private static $b ]
+ Property [ private static $b = NULL ]
}
- Static methods [0] {
}
- - Properties [1] {
- Property [ <default> private $a ]
+ - Properties [3] {
+ Property [ private $a = NULL ]
+ Property [ public ?int $c = 42 ]
+ Property [ public Foo $d ]
}
- Methods [0] {
@@ -35,7 +39,7 @@ Class [ <user> class c ] {
}
Class [ <user> class d extends c ] {
- @@ %s 7-7
+ @@ %s 9-9
- Constants [0] {
}
@@ -46,7 +50,9 @@ Class [ <user> class d extends c ] {
- Static methods [0] {
}
- - Properties [0] {
+ - Properties [2] {
+ Property [ public ?int $c = 42 ]
+ Property [ public Foo $d ]
}
- Methods [0] {
diff --git a/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt b/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt
index cbed1252fa..67d1eee7e8 100644
--- a/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_getConstant_basic.phpt
@@ -1,41 +1,41 @@
--TEST--
-ReflectionClass::getConstants()
+ReflectionClass::getConstant()
--FILE--
<?php
class C {
- const a = 'hello from C';
+ const a = 'hello from C';
}
class D extends C {
}
class E extends D {
}
class F extends E {
- const a = 'hello from F';
+ 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'));
+ echo "Reflecting on class $class:\n";
+ $rc = new ReflectionClass($class);
+ var_dump($rc->getConstant('a'));
+ var_dump($rc->getConstant('doesnotexist'));
}
?>
--EXPECT--
-Reflecting on class C:
+Reflecting on class C:
string(12) "hello from C"
bool(false)
-Reflecting on class D:
+Reflecting on class D:
string(12) "hello from C"
bool(false)
-Reflecting on class E:
+Reflecting on class E:
string(12) "hello from C"
bool(false)
-Reflecting on class F:
+Reflecting on class F:
string(12) "hello from F"
bool(false)
-Reflecting on class X:
+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
index 5260e719a3..ca9bc0ce2d 100644
--- a/ext/reflection/tests/ReflectionClass_getConstant_error.phpt
+++ b/ext/reflection/tests/ReflectionClass_getConstant_error.phpt
@@ -3,35 +3,19 @@ ReflectionClass::getConstant() - bad params
--FILE--
<?php
class C {
- const myConst = 1;
+ 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--
+--EXPECT--
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
diff --git a/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt b/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt
index a9c0cd4225..c4d2c5267f 100644
--- a/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_getConstants_basic.phpt
@@ -3,23 +3,23 @@ ReflectionClass::getConstants()
--FILE--
<?php
class C {
- const a = 'hello from C';
+ const a = 'hello from C';
}
class D extends C {
}
class E extends D {
}
class F extends E {
- const a = 'hello from F';
+ 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());
+ echo "Constants from class $class: \n";
+ $rc = new ReflectionClass($class);
+ var_dump($rc->getConstants());
}
?>
--EXPECT--
diff --git a/ext/reflection/tests/ReflectionClass_getConstants_filter.phpt b/ext/reflection/tests/ReflectionClass_getConstants_filter.phpt
new file mode 100644
index 0000000000..00dd961b77
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getConstants_filter.phpt
@@ -0,0 +1,53 @@
+--TEST--
+ReflectionClass::getConstants() with $filter
+--FILE--
+<?php
+class A {
+ public const PUBLIC_CONST = 'BAR';
+ public const ANOTHER_PUBLIC_CONST = 'BAZ';
+ protected const PROTECTED_CONST = 'FOO';
+ private const PRIVATE_CONST = 'QUOZ';
+}
+
+class B {
+ public const PUBLIC_CONST = 'BAR';
+ protected const ANOTHER_PROTECTED_CONST = 'BAZ';
+ protected const PROTECTED_CONST = 'FOO';
+ private const PRIVATE_CONST = 'QUOZ';
+}
+
+class C {
+ public const PUBLIC_CONST = 'BAR';
+ protected const PROTECTED_CONST = 'FOO';
+ private const PRIVATE_CONST = 'QUOZ';
+ private const ANOTHER_PRIVATE_CONST = 'BAZ';
+}
+
+$reflectionClassA = new ReflectionClass(A::class);
+var_dump($reflectionClassA->getConstants(ReflectionClassConstant::IS_PUBLIC));
+
+$reflectionClassB = new ReflectionClass(B::class);
+var_dump($reflectionClassB->getConstants(ReflectionClassConstant::IS_PROTECTED));
+
+$reflectionClassC = new ReflectionClass(C::class);
+var_dump($reflectionClassC->getConstants(ReflectionClassConstant::IS_PRIVATE));
+?>
+--EXPECTF--
+array(%d) {
+ ["PUBLIC_CONST"]=>
+ string(%d) "BAR"
+ ["ANOTHER_PUBLIC_CONST"]=>
+ string(%d) "BAZ"
+}
+array(%d) {
+ ["ANOTHER_PROTECTED_CONST"]=>
+ string(%d) "BAZ"
+ ["PROTECTED_CONST"]=>
+ string(%d) "FOO"
+}
+array(%d) {
+ ["PRIVATE_CONST"]=>
+ string(%d) "QUOZ"
+ ["ANOTHER_PRIVATE_CONST"]=>
+ string(%d) "BAZ"
+}
diff --git a/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt b/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt
index 5db9d8f3d3..bbf26e04a5 100644
--- a/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt
@@ -3,81 +3,25 @@ ReflectionClass::getConstructor()
--FILE--
<?php
class NewCtor {
- function __construct() {}
+ 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');
-
+$classes = array('NewCtor', 'ExtendsNewCtor');
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";
- }
+ $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--
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; OldCtor has a deprecated constructor in %s on line %d
-
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in %s on line %d
-
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; C has a deprecated constructor in %s on line %d
+--EXPECT--
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_getDefaultProperties_001.phpt b/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt
index 3778adb403..0adbd34335 100644
--- a/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt
@@ -8,68 +8,68 @@ Steve Seear <stevseea@php.net>
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 $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";
+ 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 $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";
+ 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 $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";
+ 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 $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";
+ 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";
+ 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";
+ 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";
+ 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";
+ 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());
+ $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());
}
?>
diff --git a/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt b/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt
index 9171a8dd25..28b92abedb 100644
--- a/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt
@@ -10,9 +10,9 @@ opcache.save_comments=1
/**
- My
+ My
Doc
- * Comment
+ * Comment
for A
* */
@@ -48,9 +48,9 @@ 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());
+ echo "\n\n---> Doc comment for class $class:\n";
+ $rc = new ReflectionClass($class);
+ var_dump($rc->getDocComment());
}
@@ -60,9 +60,9 @@ foreach ($classes as $class) {
string(%d) "/**
- My
+ My
Doc
- * Comment
+ * Comment
for A
* */"
diff --git a/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt b/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt
index 310b22e695..84e38b0802 100644
--- a/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt
@@ -7,8 +7,8 @@ Rein Velt <rein@velt.org>
#testFest Roosendaal 2008-05-10
--FILE--
<?php
- $rc=new reflectionClass('domDocument');
- var_dump( $rc->getExtensionName()) ;
+ $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
index 4f78343081..4b4ed125a4 100644
--- a/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt
+++ b/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt
@@ -6,13 +6,13 @@ Rein Velt <rein@velt.org>
--FILE--
<?php
- class myClass
- {
- public $varX;
- public $varY;
- }
- $rc=new reflectionClass('myClass');
- var_dump( $rc->getExtensionName()) ;
+ 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
index dbe157acd6..8cd1caad74 100644
--- a/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt
@@ -7,8 +7,8 @@ Rein Velt <rein@velt.org>
#testFest Roosendaal 2008-05-10
--FILE--
<?php
- $rc=new reflectionClass('domDocument');
- var_dump($rc->getExtension()) ;
+ $rc=new reflectionClass('domDocument');
+ var_dump($rc->getExtension()) ;
?>
--EXPECTF--
object(ReflectionExtension)#%d (1) {
diff --git a/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt b/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt
index f3697792db..b8a881f9b3 100644
--- a/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt
+++ b/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt
@@ -6,13 +6,13 @@ Rein Velt <rein@velt.org>
--FILE--
<?php
- class myClass
- {
- public $varX;
- public $varY;
- }
- $rc=new reflectionClass('myClass');
- var_dump( $rc->getExtension()) ;
+ class myClass
+ {
+ public $varX;
+ public $varY;
+ }
+ $rc=new reflectionClass('myClass');
+ var_dump( $rc->getExtension()) ;
?>
--EXPECT--
NULL
diff --git a/ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt b/ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt
index 6f7561c462..feaa703c98 100644
--- a/ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt
@@ -29,16 +29,16 @@ 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' );
+ '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);
+ 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);
}
?>
diff --git a/ext/reflection/tests/ReflectionClass_getMethod_001.phpt b/ext/reflection/tests/ReflectionClass_getMethod_001.phpt
index 59887991ec..4e89466af0 100644
--- a/ext/reflection/tests/ReflectionClass_getMethod_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_getMethod_001.phpt
@@ -6,43 +6,43 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class pubf {
- public function f() {}
- static public function s() {}
+ public function f() {}
+ static public function s() {}
}
class subpubf extends pubf {
}
class protf {
- protected function f() {}
- static protected function s() {}
+ protected function f() {}
+ static protected function s() {}
}
class subprotf extends protf {
}
class privf {
- private function f() {}
- static private function s() {}
+ private function f() {}
+ static private function s() {}
}
class subprivf extends privf {
}
$classes = array("pubf", "subpubf", "protf", "subprotf",
- "privf", "subprivf");
+ "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";
- }
+ 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 doesNotExist(): ";
+ try {
+ var_dump($rc->getMethod("doesNotExist"));
+ } catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+ }
}
?>
--EXPECTF--
@@ -65,7 +65,7 @@ Reflecting on class pubf:
["class"]=>
string(4) "pubf"
}
- --> Check for doesntExist(): Method doesntExist does not exist
+ --> Check for doesNotExist(): Method pubf::doesNotExist() does not exist
Reflecting on class subpubf:
--> Check for f(): object(ReflectionMethod)#%d (2) {
["name"]=>
@@ -85,7 +85,7 @@ Reflecting on class subpubf:
["class"]=>
string(4) "pubf"
}
- --> Check for doesntExist(): Method doesntExist does not exist
+ --> Check for doesNotExist(): Method subpubf::doesNotExist() does not exist
Reflecting on class protf:
--> Check for f(): object(ReflectionMethod)#%d (2) {
["name"]=>
@@ -105,7 +105,7 @@ Reflecting on class protf:
["class"]=>
string(5) "protf"
}
- --> Check for doesntExist(): Method doesntExist does not exist
+ --> Check for doesNotExist(): Method protf::doesNotExist() does not exist
Reflecting on class subprotf:
--> Check for f(): object(ReflectionMethod)#%d (2) {
["name"]=>
@@ -125,7 +125,7 @@ Reflecting on class subprotf:
["class"]=>
string(5) "protf"
}
- --> Check for doesntExist(): Method doesntExist does not exist
+ --> Check for doesNotExist(): Method subprotf::doesNotExist() does not exist
Reflecting on class privf:
--> Check for f(): object(ReflectionMethod)#%d (2) {
["name"]=>
@@ -145,7 +145,7 @@ Reflecting on class privf:
["class"]=>
string(5) "privf"
}
- --> Check for doesntExist(): Method doesntExist does not exist
+ --> Check for doesNotExist(): Method privf::doesNotExist() does not exist
Reflecting on class subprivf:
--> Check for f(): object(ReflectionMethod)#%d (2) {
["name"]=>
@@ -165,4 +165,4 @@ Reflecting on class subprivf:
["class"]=>
string(5) "privf"
}
- --> Check for doesntExist(): Method doesntExist does not exist
+ --> Check for doesNotExist(): Method subprivf::doesNotExist() does not exist
diff --git a/ext/reflection/tests/ReflectionClass_getMethod_002.phpt b/ext/reflection/tests/ReflectionClass_getMethod_002.phpt
index 1eb084214b..8271822884 100644
--- a/ext/reflection/tests/ReflectionClass_getMethod_002.phpt
+++ b/ext/reflection/tests/ReflectionClass_getMethod_002.phpt
@@ -6,69 +6,61 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class C {
- function f() {}
+ function f() {}
}
$rc = new ReflectionClass("C");
echo "Check invalid params:\n";
try {
- var_dump($rc->getMethod());
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->getMethod());
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getMethod("f", "f"));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->getMethod("f", "f"));
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getMethod(null));
+ var_dump($rc->getMethod(null));
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getMethod(1));
+ var_dump($rc->getMethod(1));
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getMethod(1.5));
+ var_dump($rc->getMethod(1.5));
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getMethod(true));
+ var_dump($rc->getMethod(true));
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getMethod(array(1,2,3)));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->getMethod(array(1,2,3)));
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getMethod(new C));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->getMethod(new C));
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
?>
---EXPECTF--
+--EXPECT--
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
+ReflectionClass::getMethod() expects exactly 1 argument, 0 given
+ReflectionClass::getMethod() expects exactly 1 argument, 2 given
+Method C::() does not exist
+Method C::1() does not exist
+Method C::1.5() does not exist
+Method C::1() does not exist
+ReflectionClass::getMethod(): Argument #1 ($name) must be of type string, array given
+ReflectionClass::getMethod(): Argument #1 ($name) must be of type string, C given
diff --git a/ext/reflection/tests/ReflectionClass_getMethods_001.phpt b/ext/reflection/tests/ReflectionClass_getMethods_001.phpt
index dca9adb56d..4e008e8710 100644
--- a/ext/reflection/tests/ReflectionClass_getMethods_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_getMethods_001.phpt
@@ -6,32 +6,32 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class pubf {
- public function f() {}
- static public function s() {}
+ public function f() {}
+ static public function s() {}
}
class subpubf extends pubf {
}
class protf {
- protected function f() {}
- static protected function s() {}
+ protected function f() {}
+ static protected function s() {}
}
class subprotf extends protf {
}
class privf {
- private function f() {}
- static private function s() {}
+ private function f() {}
+ static private function s() {}
}
class subprivf extends privf {
}
$classes = array("pubf", "subpubf", "protf", "subprotf",
- "privf", "subprivf");
+ "privf", "subprivf");
foreach($classes as $class) {
- echo "Reflecting on class $class: \n";
- $rc = new ReflectionClass($class);
- var_dump($rc->getMethods());
+ echo "Reflecting on class $class: \n";
+ $rc = new ReflectionClass($class);
+ var_dump($rc->getMethods());
}
?>
@@ -122,19 +122,5 @@ array(2) {
}
}
Reflecting on class subprivf:
-array(2) {
- [0]=>
- object(ReflectionMethod)#%d (2) {
- ["name"]=>
- string(1) "f"
- ["class"]=>
- string(5) "privf"
- }
- [1]=>
- object(ReflectionMethod)#%d (2) {
- ["name"]=>
- string(1) "s"
- ["class"]=>
- string(5) "privf"
- }
+array(0) {
}
diff --git a/ext/reflection/tests/ReflectionClass_getMethods_003.phpt b/ext/reflection/tests/ReflectionClass_getMethods_003.phpt
index b08fcaa4d4..d40e0b9122 100644
--- a/ext/reflection/tests/ReflectionClass_getMethods_003.phpt
+++ b/ext/reflection/tests/ReflectionClass_getMethods_003.phpt
@@ -6,14 +6,14 @@ 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() {}
+ 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");
diff --git a/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt b/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt
index 91a0a18f1a..f792031a01 100644
--- a/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_getModifierNames_basic.phpt
@@ -11,34 +11,34 @@ 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() {}
+ 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();
+ abstract function a();
+ abstract protected function b();
}
function dump_modifierNames($class) {
- $obj = new ReflectionClass($class);
- var_dump($obj->getName(), Reflection::getModifierNames($obj->getModifiers()));
+ $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()));
- }
+ $obj = new ReflectionClass($class);
+ foreach($obj->getMethods() as $method) {
+ var_dump($obj->getName() . "::" . $method->getName(), Reflection::getModifierNames($method->getModifiers()));
+ }
}
dump_modifierNames('a');
@@ -49,7 +49,6 @@ dump_methodModifierNames('x');
dump_methodModifierNames('y');
?>
-==DONE==
--EXPECT--
string(1) "a"
array(0) {
@@ -136,4 +135,3 @@ array(2) {
[1]=>
string(9) "protected"
}
-==DONE==
diff --git a/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt
index ffe8876133..447f8d2edc 100644
--- a/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt
@@ -14,8 +14,8 @@ interface f extends d {}
class g extends b {}
function dump_modifiers($class) {
- $obj = new ReflectionClass($class);
- var_dump($obj->getModifiers());
+ $obj = new ReflectionClass($class);
+ var_dump($obj->getModifiers());
}
dump_modifiers('a');
diff --git a/ext/reflection/tests/ReflectionClass_getName_basic.phpt b/ext/reflection/tests/ReflectionClass_getName_basic.phpt
index 37cec4bc81..f230165f0d 100644
--- a/ext/reflection/tests/ReflectionClass_getName_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_getName_basic.phpt
@@ -3,10 +3,10 @@ ReflectionClass::getName()
--FILE--
<?php
class TrickClass {
- function __toString() {
- //Return the name of another class
- return "Exception";
- }
+ function __toString() {
+ //Return the name of another class
+ return "Exception";
+ }
}
$r1 = new ReflectionClass("stdClass");
diff --git a/ext/reflection/tests/ReflectionClass_getParentClass.phpt b/ext/reflection/tests/ReflectionClass_getParentClass.phpt
index 382948d3d3..ef64de5ecb 100644
--- a/ext/reflection/tests/ReflectionClass_getParentClass.phpt
+++ b/ext/reflection/tests/ReflectionClass_getParentClass.phpt
@@ -10,11 +10,14 @@ class Foo {}
class Bar extends Foo {}
-$rc1 = new ReflectionClass("Bar");
-var_dump($rc1->getParentClass());
+$rc = new ReflectionClass("Bar");
+$parent = $rc->getParentClass();
+$grandParent = $parent->getParentClass();
+var_dump($parent, $grandParent);
?>
--EXPECTF--
object(ReflectionClass)#%d (1) {
["name"]=>
string(3) "Foo"
}
+bool(false)
diff --git a/ext/reflection/tests/ReflectionClass_getParentClass_001.phpt b/ext/reflection/tests/ReflectionClass_getParentClass_001.phpt
deleted file mode 100644
index be50dbb730..0000000000
--- a/ext/reflection/tests/ReflectionClass_getParentClass_001.phpt
+++ /dev/null
@@ -1,38 +0,0 @@
---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
index 3554af3890..0607822a20 100644
--- a/ext/reflection/tests/ReflectionClass_getProperties_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_getProperties_001.phpt
@@ -6,32 +6,32 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class pubf {
- public $a;
- static public $s;
+ public $a;
+ static public $s;
}
class subpubf extends pubf {
}
class protf {
- protected $a;
- static protected $s;
+ protected $a;
+ static protected $s;
}
class subprotf extends protf {
}
class privf {
- private $a;
- static private $s;
+ private $a;
+ static private $s;
}
class subprivf extends privf {
}
$classes = array("pubf", "subpubf", "protf", "subprotf",
- "privf", "subprivf");
+ "privf", "subprivf");
foreach($classes as $class) {
- echo "Reflecting on class $class: \n";
- $rc = new ReflectionClass($class);
- var_dump($rc->getProperties());
+ echo "Reflecting on class $class: \n";
+ $rc = new ReflectionClass($class);
+ var_dump($rc->getProperties());
}
?>
diff --git a/ext/reflection/tests/ReflectionClass_getProperties_003.phpt b/ext/reflection/tests/ReflectionClass_getProperties_003.phpt
index fe3792a30f..63d5d476b4 100644
--- a/ext/reflection/tests/ReflectionClass_getProperties_003.phpt
+++ b/ext/reflection/tests/ReflectionClass_getProperties_003.phpt
@@ -6,14 +6,14 @@ 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;
+ public $pub1;
+ public $pub2;
+ private $priv1;
+ private $priv2;
+ static public $pubs;
+ static public $pubs2;
+ static private $privs1;
+ static private $privs2;
}
$rc = new ReflectionClass("C");
diff --git a/ext/reflection/tests/ReflectionClass_getProperty_001.phpt b/ext/reflection/tests/ReflectionClass_getProperty_001.phpt
index 830608e0ca..e2e6e3ba3c 100644
--- a/ext/reflection/tests/ReflectionClass_getProperty_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_getProperty_001.phpt
@@ -6,55 +6,55 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class pubf {
- public $a;
- static public $s;
+ public $a;
+ static public $s;
}
class subpubf extends pubf {
}
class protf {
- protected $a;
- static protected $s;
+ protected $a;
+ static protected $s;
}
class subprotf extends protf {
}
class privf {
- private $a;
- static protected $s;
+ private $a;
+ static protected $s;
}
class subprivf extends privf {
}
$classes = array("pubf", "subpubf", "protf", "subprotf",
- "privf", "subprivf");
+ "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";
- }
+ 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 doesNotExist: ";
+ var_dump($rc->getProperty("doesNotExist"));
+ } catch (exception $e) {
+ echo $e->getMessage() . "\n";
+ }
}
?>
@@ -72,8 +72,8 @@ Reflecting on class pubf:
["class"]=>
string(4) "pubf"
}
- --> Check for A: Property A does not exist
- --> Check for doesntExist: Property doesntExist does not exist
+ --> Check for A: Property pubf::$A does not exist
+ --> Check for doesNotExist: Property pubf::$doesNotExist does not exist
Reflecting on class subpubf:
--> Check for s: object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -87,8 +87,8 @@ Reflecting on class subpubf:
["class"]=>
string(4) "pubf"
}
- --> Check for A: Property A does not exist
- --> Check for doesntExist: Property doesntExist does not exist
+ --> Check for A: Property subpubf::$A does not exist
+ --> Check for doesNotExist: Property subpubf::$doesNotExist does not exist
Reflecting on class protf:
--> Check for s: object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -102,8 +102,8 @@ Reflecting on class protf:
["class"]=>
string(5) "protf"
}
- --> Check for A: Property A does not exist
- --> Check for doesntExist: Property doesntExist does not exist
+ --> Check for A: Property protf::$A does not exist
+ --> Check for doesNotExist: Property protf::$doesNotExist does not exist
Reflecting on class subprotf:
--> Check for s: object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -117,8 +117,8 @@ Reflecting on class subprotf:
["class"]=>
string(5) "protf"
}
- --> Check for A: Property A does not exist
- --> Check for doesntExist: Property doesntExist does not exist
+ --> Check for A: Property subprotf::$A does not exist
+ --> Check for doesNotExist: Property subprotf::$doesNotExist does not exist
Reflecting on class privf:
--> Check for s: object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -132,8 +132,8 @@ Reflecting on class privf:
["class"]=>
string(5) "privf"
}
- --> Check for A: Property A does not exist
- --> Check for doesntExist: Property doesntExist does not exist
+ --> Check for A: Property privf::$A does not exist
+ --> Check for doesNotExist: Property privf::$doesNotExist does not exist
Reflecting on class subprivf:
--> Check for s: object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -141,6 +141,6 @@ Reflecting on class subprivf:
["class"]=>
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
+ --> Check for a: Property subprivf::$a does not exist
+ --> Check for A: Property subprivf::$A does not exist
+ --> Check for doesNotExist: Property subprivf::$doesNotExist does not exist
diff --git a/ext/reflection/tests/ReflectionClass_getProperty_002.phpt b/ext/reflection/tests/ReflectionClass_getProperty_002.phpt
index 68522e097a..80ef77c8a3 100644
--- a/ext/reflection/tests/ReflectionClass_getProperty_002.phpt
+++ b/ext/reflection/tests/ReflectionClass_getProperty_002.phpt
@@ -6,67 +6,59 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class C {
- public $a;
+ public $a;
}
$rc = new ReflectionClass("C");
echo "Check invalid params:\n";
try {
- var_dump($rc->getProperty());
-} catch (exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->getProperty());
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getProperty("a", "a"));
-} catch (exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->getProperty("a", "a"));
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getProperty(null));
+ var_dump($rc->getProperty(null));
} catch (exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getProperty(1));
+ var_dump($rc->getProperty(1));
} catch (exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getProperty(1.5));
+ var_dump($rc->getProperty(1.5));
} catch (exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getProperty(true));
+ var_dump($rc->getProperty(true));
} catch (exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getProperty(array(1,2,3)));
-} catch (exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->getProperty(array(1,2,3)));
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getProperty(new C));
-} catch (exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->getProperty(new C));
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
?>
---EXPECTF--
+--EXPECT--
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
+ReflectionClass::getProperty() expects exactly 1 argument, 0 given
+ReflectionClass::getProperty() expects exactly 1 argument, 2 given
+Property C::$ does not exist
+Property C::$1 does not exist
+Property C::$1.5 does not exist
+Property C::$1 does not exist
+ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, array given
+ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, C given
diff --git a/ext/reflection/tests/ReflectionClass_getProperty_003.phpt b/ext/reflection/tests/ReflectionClass_getProperty_003.phpt
index 61d63362dc..b3c2ceb88a 100644
--- a/ext/reflection/tests/ReflectionClass_getProperty_003.phpt
+++ b/ext/reflection/tests/ReflectionClass_getProperty_003.phpt
@@ -6,56 +6,56 @@ 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 $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";
+ 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 $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";
+ 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";
+ 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";
+ 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;
- }
+ 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;
+ }
}
@@ -70,7 +70,7 @@ showInfo("privB");
showInfo("pubC");
showInfo("protC");
showInfo("privC");
-showInfo("doesntExist");
+showInfo("doesNotExist");
showInfo("A::pubC");
showInfo("A::protC");
@@ -89,9 +89,9 @@ showInfo("C::privC");
showInfo("X::pubC");
showInfo("X::protC");
showInfo("X::privC");
-showInfo("X::doesntExist");
+showInfo("X::doesNotExist");
-showInfo("doesntexist::doesntExist");
+showInfo("doesNotexist::doesNotExist");
?>
--EXPECTF--
@@ -110,9 +110,9 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "A"
}
-Cannot access non-public member C::$protA
+Cannot access non-public property C::$protA
--- (Reflecting on privA) ---
-Property privA does not exist
+Property C::$privA does not exist
--- (Reflecting on pubB) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -128,9 +128,9 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "B"
}
-Cannot access non-public member C::$protB
+Cannot access non-public property C::$protB
--- (Reflecting on privB) ---
-Property privB does not exist
+Property C::$privB does not exist
--- (Reflecting on pubC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -146,7 +146,7 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "C"
}
-Cannot access non-public member C::$protC
+Cannot access non-public property C::$protC
--- (Reflecting on privC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -154,9 +154,9 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "C"
}
-Cannot access non-public member C::$privC
---- (Reflecting on doesntExist) ---
-Property doesntExist does not exist
+Cannot access non-public property C::$privC
+--- (Reflecting on doesNotExist) ---
+Property C::$doesNotExist does not exist
--- (Reflecting on A::pubC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -172,7 +172,7 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "A"
}
-Cannot access non-public member A::$protC
+Cannot access non-public property A::$protC
--- (Reflecting on A::privC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -180,7 +180,7 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "A"
}
-Cannot access non-public member A::$privC
+Cannot access non-public property A::$privC
--- (Reflecting on B::pubC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -196,7 +196,7 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "B"
}
-Cannot access non-public member B::$protC
+Cannot access non-public property B::$protC
--- (Reflecting on B::privC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -204,7 +204,7 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "B"
}
-Cannot access non-public member B::$privC
+Cannot access non-public property B::$privC
--- (Reflecting on c::pubC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -214,7 +214,7 @@ object(ReflectionProperty)#%d (2) {
}
string(9) "pubC in C"
--- (Reflecting on c::PUBC) ---
-Property PUBC does not exist
+Property C::$PUBC does not exist
--- (Reflecting on C::pubC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -230,7 +230,7 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "C"
}
-Cannot access non-public member C::$protC
+Cannot access non-public property C::$protC
--- (Reflecting on C::privC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -238,14 +238,14 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "C"
}
-Cannot access non-public member C::$privC
+Cannot access non-public property C::$privC
--- (Reflecting on X::pubC) ---
-Fully qualified property name X::pubC does not specify a base class of C
+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
+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
+Fully qualified property name X::$privC does not specify a base class of C
+--- (Reflecting on X::doesNotExist) ---
+Fully qualified property name X::$doesNotExist does not specify a base class of C
+--- (Reflecting on doesNotexist::doesNotExist) ---
+Class "doesnotexist" does not exist
diff --git a/ext/reflection/tests/ReflectionClass_getProperty_004.phpt b/ext/reflection/tests/ReflectionClass_getProperty_004.phpt
index ce2aa57871..bbc9963d8a 100644
--- a/ext/reflection/tests/ReflectionClass_getProperty_004.phpt
+++ b/ext/reflection/tests/ReflectionClass_getProperty_004.phpt
@@ -6,56 +6,56 @@ 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 $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";
+ 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 $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";
+ 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";
+ 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";
+ 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;
- }
+ 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;
+ }
}
@@ -70,7 +70,7 @@ showInfo("privB");
showInfo("pubC");
showInfo("protC");
showInfo("privC");
-showInfo("doesntExist");
+showInfo("doesNotExist");
showInfo("A::pubC");
showInfo("A::protC");
@@ -89,9 +89,9 @@ showInfo("C::privC");
showInfo("X::pubC");
showInfo("X::protC");
showInfo("X::privC");
-showInfo("X::doesntExist");
+showInfo("X::doesNotExist");
-showInfo("doesntexist::doesntExist");
+showInfo("doesNotexist::doesNotExist");
?>
--EXPECTF--
@@ -110,9 +110,9 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "A"
}
-Cannot access non-public member C::$protA
+Cannot access non-public property C::$protA
--- (Reflecting on privA) ---
-Property privA does not exist
+Property C::$privA does not exist
--- (Reflecting on pubB) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -128,9 +128,9 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "B"
}
-Cannot access non-public member C::$protB
+Cannot access non-public property C::$protB
--- (Reflecting on privB) ---
-Property privB does not exist
+Property C::$privB does not exist
--- (Reflecting on pubC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -146,7 +146,7 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "C"
}
-Cannot access non-public member C::$protC
+Cannot access non-public property C::$protC
--- (Reflecting on privC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -154,9 +154,9 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "C"
}
-Cannot access non-public member C::$privC
---- (Reflecting on doesntExist) ---
-Property doesntExist does not exist
+Cannot access non-public property C::$privC
+--- (Reflecting on doesNotExist) ---
+Property C::$doesNotExist does not exist
--- (Reflecting on A::pubC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -172,7 +172,7 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "A"
}
-Cannot access non-public member A::$protC
+Cannot access non-public property A::$protC
--- (Reflecting on A::privC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -180,7 +180,7 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "A"
}
-Cannot access non-public member A::$privC
+Cannot access non-public property A::$privC
--- (Reflecting on B::pubC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -196,7 +196,7 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "B"
}
-Cannot access non-public member B::$protC
+Cannot access non-public property B::$protC
--- (Reflecting on B::privC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -204,7 +204,7 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "B"
}
-Cannot access non-public member B::$privC
+Cannot access non-public property B::$privC
--- (Reflecting on c::pubC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -214,7 +214,7 @@ object(ReflectionProperty)#%d (2) {
}
string(9) "pubC in C"
--- (Reflecting on c::PUBC) ---
-Property PUBC does not exist
+Property C::$PUBC does not exist
--- (Reflecting on C::pubC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -230,7 +230,7 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "C"
}
-Cannot access non-public member C::$protC
+Cannot access non-public property C::$protC
--- (Reflecting on C::privC) ---
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -238,14 +238,14 @@ object(ReflectionProperty)#%d (2) {
["class"]=>
string(1) "C"
}
-Cannot access non-public member C::$privC
+Cannot access non-public property C::$privC
--- (Reflecting on X::pubC) ---
-Fully qualified property name X::pubC does not specify a base class of C
+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
+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
+Fully qualified property name X::$privC does not specify a base class of C
+--- (Reflecting on X::doesNotExist) ---
+Fully qualified property name X::$doesNotExist does not specify a base class of C
+--- (Reflecting on doesNotexist::doesNotExist) ---
+Class "doesnotexist" does not exist
diff --git a/ext/reflection/tests/ReflectionClass_getReflectionConstants_filter.phpt b/ext/reflection/tests/ReflectionClass_getReflectionConstants_filter.phpt
new file mode 100644
index 0000000000..afff6b67ce
--- /dev/null
+++ b/ext/reflection/tests/ReflectionClass_getReflectionConstants_filter.phpt
@@ -0,0 +1,83 @@
+--TEST--
+ReflectionClass::getReflectionConstants() with $filter
+--FILE--
+<?php
+class A {
+ public const PUBLIC_CONST = 'BAR';
+ public const ANOTHER_PUBLIC_CONST = 'BAZ';
+ protected const PROTECTED_CONST = 'FOO';
+ private const PRIVATE_CONST = 'QUOZ';
+}
+
+class B {
+ public const PUBLIC_CONST = 'BAR';
+ protected const ANOTHER_PROTECTED_CONST = 'BAZ';
+ protected const PROTECTED_CONST = 'FOO';
+ private const PRIVATE_CONST = 'QUOZ';
+}
+
+class C {
+ public const PUBLIC_CONST = 'BAR';
+ protected const PROTECTED_CONST = 'FOO';
+ private const PRIVATE_CONST = 'QUOZ';
+ private const ANOTHER_PRIVATE_CONST = 'BAZ';
+}
+
+$reflectionClassA = new ReflectionClass(A::class);
+var_dump($reflectionClassA->getReflectionConstants(ReflectionClassConstant::IS_PUBLIC));
+
+$reflectionClassB = new ReflectionClass(B::class);
+var_dump($reflectionClassB->getReflectionConstants(ReflectionClassConstant::IS_PROTECTED));
+
+$reflectionClassC = new ReflectionClass(C::class);
+var_dump($reflectionClassC->getReflectionConstants(ReflectionClassConstant::IS_PRIVATE));
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ object(ReflectionClassConstant)#%d (%d) {
+ ["name"]=>
+ string(%d) "PUBLIC_CONST"
+ ["class"]=>
+ string(%d) "A"
+ }
+ [1]=>
+ object(ReflectionClassConstant)#%d (%d) {
+ ["name"]=>
+ string(%d) "ANOTHER_PUBLIC_CONST"
+ ["class"]=>
+ string(%d) "A"
+ }
+}
+array(2) {
+ [0]=>
+ object(ReflectionClassConstant)#%d (%d) {
+ ["name"]=>
+ string(%d) "ANOTHER_PROTECTED_CONST"
+ ["class"]=>
+ string(%d) "B"
+ }
+ [1]=>
+ object(ReflectionClassConstant)#%d (%d) {
+ ["name"]=>
+ string(%d) "PROTECTED_CONST"
+ ["class"]=>
+ string(%d) "B"
+ }
+}
+array(2) {
+ [0]=>
+ object(ReflectionClassConstant)#%d (%d) {
+ ["name"]=>
+ string(%d) "PRIVATE_CONST"
+ ["class"]=>
+ string(%d) "C"
+ }
+ [1]=>
+ object(ReflectionClassConstant)#%d (%d) {
+ ["name"]=>
+ string(%d) "ANOTHER_PRIVATE_CONST"
+ ["class"]=>
+ string(%d) "C"
+ }
+}
diff --git a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt
index c63ee330d4..e4546bdb78 100644
--- a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt
@@ -6,15 +6,15 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class A {
- static private $privateOverridden = "original private";
- static protected $protectedOverridden = "original protected";
- static public $publicOverridden = "original public";
+ 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";
+ static private $privateOverridden = "changed private";
+ static protected $protectedOverridden = "changed protected";
+ static public $publicOverridden = "changed public";
}
echo "Retrieving static values from A:\n";
@@ -33,17 +33,17 @@ var_dump($rcB->getStaticPropertyValue("publicOverridden"));
echo "\nRetrieving non-existent values from A with no default value:\n";
try {
- var_dump($rcA->getStaticPropertyValue("protectedDoesNotExist"));
- echo "you should not see this";
+ var_dump($rcA->getStaticPropertyValue("protectedDoesNotExist"));
+ echo "you should not see this";
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rcA->getStaticPropertyValue("privateDoesNotExist"));
- echo "you should not see this";
+ var_dump($rcA->getStaticPropertyValue("privateDoesNotExist"));
+ echo "you should not see this";
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
?>
@@ -61,5 +61,5 @@ 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 protectedDoesNotExist
-Class A does not have a property named privateDoesNotExist
+Property A::$protectedDoesNotExist does not exist
+Property A::$privateDoesNotExist does not exist
diff --git a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt
index 52fa378eb6..4a5a5929d5 100644
--- a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt
+++ b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt
@@ -6,46 +6,41 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class C {
- public static $x;
+ public static $x;
}
$rc = new ReflectionClass('C');
try {
- var_dump($rc->getStaticPropertyValue("x", "default value", 'blah'));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->getStaticPropertyValue("x", "default value", 'blah'));
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getStaticPropertyValue());
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->getStaticPropertyValue());
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getStaticPropertyValue(null));
+ var_dump($rc->getStaticPropertyValue(null));
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getStaticPropertyValue(1.5, 'def'));
+ var_dump($rc->getStaticPropertyValue(1.5, 'def'));
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->getStaticPropertyValue(array(1,2,3)));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->getStaticPropertyValue(array(1,2,3)));
+} catch (TypeError $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
+--EXPECT--
+ReflectionClass::getStaticPropertyValue() expects at most 2 arguments, 3 given
+ReflectionClass::getStaticPropertyValue() expects at least 1 argument, 0 given
+Property C::$ does not exist
string(3) "def"
-
-Warning: ReflectionClass::getStaticPropertyValue() expects parameter 1 to be string, array given in %s on line 28
-NULL
+ReflectionClass::getStaticPropertyValue(): Argument #1 ($name) must be of type string, array given
diff --git a/ext/reflection/tests/ReflectionClass_hasConstant_001.phpt b/ext/reflection/tests/ReflectionClass_hasConstant_001.phpt
index 84e334ba19..5783b2b506 100644
--- a/ext/reflection/tests/ReflectionClass_hasConstant_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_hasConstant_001.phpt
@@ -6,7 +6,7 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class C {
- const myConst = 1;
+ const myConst = 1;
}
class D extends C {
@@ -19,14 +19,14 @@ 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"));
+var_dump($rc->hasConstant("doesNotExist"));
$rd = new ReflectionClass("D");
echo "Check inherited constant: ";
var_dump($rd->hasConstant("myConst"));
echo "Check absent constant: ";
-var_dump($rd->hasConstant("doesntExist"));
+var_dump($rd->hasConstant("doesNotExist"));
?>
--EXPECT--
Check existing constant: bool(true)
diff --git a/ext/reflection/tests/ReflectionClass_hasConstant_002.phpt b/ext/reflection/tests/ReflectionClass_hasConstant_002.phpt
index 14c847401d..5dcc7df173 100644
--- a/ext/reflection/tests/ReflectionClass_hasConstant_002.phpt
+++ b/ext/reflection/tests/ReflectionClass_hasConstant_002.phpt
@@ -6,35 +6,19 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class C {
- const myConst = 1;
+ 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--
+--EXPECT--
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
diff --git a/ext/reflection/tests/ReflectionClass_hasMethod_001.phpt b/ext/reflection/tests/ReflectionClass_hasMethod_001.phpt
index dec76febe1..d987897a6e 100644
--- a/ext/reflection/tests/ReflectionClass_hasMethod_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_hasMethod_001.phpt
@@ -6,39 +6,39 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class pubf {
- public function f() {}
- static public function s() {}
+ public function f() {}
+ static public function s() {}
}
class subpubf extends pubf {
}
class protf {
- protected function f() {}
- static protected function s() {}
+ protected function f() {}
+ static protected function s() {}
}
class subprotf extends protf {
}
class privf {
- private function f() {}
- static private function s() {}
+ private function f() {}
+ static private function s() {}
}
class subprivf extends privf {
}
$classes = array("pubf", "subpubf", "protf", "subprotf",
- "privf", "subprivf");
+ "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"));
+ 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 doesNotExist(): ";
+ var_dump($rc->hasMethod("doesNotExist"));
}
?>
--EXPECT--
@@ -46,30 +46,30 @@ Reflecting on class pubf:
--> Check for f(): bool(true)
--> Check for s(): bool(true)
--> Check for F(): bool(true)
- --> Check for doesntExist(): bool(false)
+ --> Check for doesNotExist(): 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)
+ --> Check for doesNotExist(): 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)
+ --> Check for doesNotExist(): 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)
+ --> Check for doesNotExist(): 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)
+ --> Check for doesNotExist(): 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)
+ --> Check for doesNotExist(): bool(false)
diff --git a/ext/reflection/tests/ReflectionClass_hasMethod_002.phpt b/ext/reflection/tests/ReflectionClass_hasMethod_002.phpt
index 63fe8791fc..2bbc84551e 100644
--- a/ext/reflection/tests/ReflectionClass_hasMethod_002.phpt
+++ b/ext/reflection/tests/ReflectionClass_hasMethod_002.phpt
@@ -6,35 +6,19 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class C {
- function f() {}
+ 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--
+--EXPECT--
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_hasProperty_001.phpt b/ext/reflection/tests/ReflectionClass_hasProperty_001.phpt
index a6c3753a78..12040658ba 100644
--- a/ext/reflection/tests/ReflectionClass_hasProperty_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_hasProperty_001.phpt
@@ -6,39 +6,39 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class pubf {
- public $a;
- static public $s;
+ public $a;
+ static public $s;
}
class subpubf extends pubf {
}
class protf {
- protected $a;
- static protected $s;
+ protected $a;
+ static protected $s;
}
class subprotf extends protf {
}
class privf {
- private $a;
- static protected $s;
+ private $a;
+ static protected $s;
}
class subprivf extends privf {
}
$classes = array("pubf", "subpubf", "protf", "subprotf",
- "privf", "subprivf");
+ "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"));
+ 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 doesNotExist: ";
+ var_dump($rc->hasProperty("doesNotExist"));
}
?>
--EXPECT--
@@ -46,29 +46,29 @@ Reflecting on class pubf:
--> Check for s: bool(true)
--> Check for a: bool(true)
--> Check for A: bool(false)
- --> Check for doesntExist: bool(false)
+ --> Check for doesNotExist: 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)
+ --> Check for doesNotExist: 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)
+ --> Check for doesNotExist: 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)
+ --> Check for doesNotExist: 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)
+ --> Check for doesNotExist: 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)
+ --> Check for doesNotExist: bool(false)
diff --git a/ext/reflection/tests/ReflectionClass_hasProperty_002.phpt b/ext/reflection/tests/ReflectionClass_hasProperty_002.phpt
index 753890394f..607fead65c 100644
--- a/ext/reflection/tests/ReflectionClass_hasProperty_002.phpt
+++ b/ext/reflection/tests/ReflectionClass_hasProperty_002.phpt
@@ -6,35 +6,19 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class C {
- public $a;
+ 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--
+--EXPECT--
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_implementsInterface_001.phpt b/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt
index d1cbc8ae47..5fb158cb8d 100644
--- a/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_implementsInterface_001.phpt
@@ -15,141 +15,137 @@ class C implements I2 {}
$classNames = array('A', 'B', 'C', 'I1', 'I2');
foreach ($classNames as $className) {
- $rcs[$className] = new ReflectionClass($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";
- }
- }
+ foreach ($rcs as $parentName => $parent) {
+ echo "Does " . $childName . " implement " . $parentName . "?\n";
+ echo " - Using object argument: ";
+ try {
+ var_dump($child->implementsInterface($parent));
+ } catch (Exception|TypeError $e) {
+ echo $e->getMessage() . "\n";
+ }
+ echo " - Using string argument: ";
+ try {
+ var_dump($child->implementsInterface($parentName));
+ } catch (Exception|TypeError $e) {
+ echo $e->getMessage() . "\n";
+ }
+ }
}
echo "\n\nTest bad arguments:\n";
try {
- var_dump($rcs['A']->implementsInterface());
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $rcs['A']->implementsInterface();
+} catch (ArgumentCountError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rcs['A']->implementsInterface('C', 'C'));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $rcs['A']->implementsInterface('C', 'C');
+} catch (ArgumentCountError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rcs['A']->implementsInterface(null));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $rcs['A']->implementsInterface(null);
+} catch (ReflectionException $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rcs['A']->implementsInterface('ThisClassDoesNotExist'));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $rcs['A']->implementsInterface('ThisClassDoesNotExist');
+} catch (ReflectionException $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rcs['A']->implementsInterface(2));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $rcs['A']->implementsInterface(2);
+} catch (ReflectionException $e) {
+ echo $e->getMessage() . "\n";
}
?>
---EXPECTF--
-Does A implement A?
+--EXPECT--
+Does A implement A?
- Using object argument: A is not an interface
- Using string argument: A is not an interface
-Does A implement B?
+Does A implement B?
- Using object argument: B is not an interface
- Using string argument: B is not an interface
-Does A implement C?
+Does A implement C?
- Using object argument: C is not an interface
- Using string argument: C is not an interface
-Does A implement I1?
+Does A implement I1?
- Using object argument: bool(true)
- Using string argument: bool(true)
-Does A implement I2?
+Does A implement I2?
- Using object argument: bool(false)
- Using string argument: bool(false)
-Does B implement A?
+Does B implement A?
- Using object argument: A is not an interface
- Using string argument: A is not an interface
-Does B implement B?
+Does B implement B?
- Using object argument: B is not an interface
- Using string argument: B is not an interface
-Does B implement C?
+Does B implement C?
- Using object argument: C is not an interface
- Using string argument: C is not an interface
-Does B implement I1?
+Does B implement I1?
- Using object argument: bool(true)
- Using string argument: bool(true)
-Does B implement I2?
+Does B implement I2?
- Using object argument: bool(false)
- Using string argument: bool(false)
-Does C implement A?
+Does C implement A?
- Using object argument: A is not an interface
- Using string argument: A is not an interface
-Does C implement B?
+Does C implement B?
- Using object argument: B is not an interface
- Using string argument: B is not an interface
-Does C implement C?
+Does C implement C?
- Using object argument: C is not an interface
- Using string argument: C is not an interface
-Does C implement I1?
+Does C implement I1?
- Using object argument: bool(true)
- Using string argument: bool(true)
-Does C implement I2?
+Does C implement I2?
- Using object argument: bool(true)
- Using string argument: bool(true)
-Does I1 implement A?
+Does I1 implement A?
- Using object argument: A is not an interface
- Using string argument: A is not an interface
-Does I1 implement B?
+Does I1 implement B?
- Using object argument: B is not an interface
- Using string argument: B is not an interface
-Does I1 implement C?
+Does I1 implement C?
- Using object argument: C is not an interface
- Using string argument: C is not an interface
-Does I1 implement I1?
+Does I1 implement I1?
- Using object argument: bool(true)
- Using string argument: bool(true)
-Does I1 implement I2?
+Does I1 implement I2?
- Using object argument: bool(false)
- Using string argument: bool(false)
-Does I2 implement A?
+Does I2 implement A?
- Using object argument: A is not an interface
- Using string argument: A is not an interface
-Does I2 implement B?
+Does I2 implement B?
- Using object argument: B is not an interface
- Using string argument: B is not an interface
-Does I2 implement C?
+Does I2 implement C?
- Using object argument: C is not an interface
- Using string argument: C is not an interface
-Does I2 implement I1?
+Does I2 implement I1?
- Using object argument: bool(true)
- Using string argument: bool(true)
-Does I2 implement I2?
+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
+ReflectionClass::implementsInterface() expects exactly 1 argument, 0 given
+ReflectionClass::implementsInterface() expects exactly 1 argument, 2 given
+Interface "" does not exist
+Interface "ThisClassDoesNotExist" does not exist
+Interface "2" does not exist
diff --git a/ext/reflection/tests/ReflectionClass_isArray.phpt b/ext/reflection/tests/ReflectionClass_isArray.phpt
index 3eec0dac54..67df4e98e7 100644
--- a/ext/reflection/tests/ReflectionClass_isArray.phpt
+++ b/ext/reflection/tests/ReflectionClass_isArray.phpt
@@ -4,7 +4,8 @@ public bool ReflectionParameter::isArray ( void );
marcosptf - <marcosptf@yahoo.com.br> - @phpsp - sao paulo - br
--FILE--
<?php
-function testReflectionIsArray($a = null, $b = 0, array $c, $d=true, array $e, $f=1.5, $g="", array $h, $i="#F989898") {}
+
+function testReflectionIsArray(array $a, ?array $b, iterable $c, array|string $d) {}
$reflection = new ReflectionFunction('testReflectionIsArray');
@@ -12,13 +13,15 @@ foreach ($reflection->getParameters() as $parameter) {
var_dump($parameter->isArray());
}
?>
---EXPECT--
-bool(false)
-bool(false)
+--EXPECTF--
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
bool(true)
-bool(false)
+
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
bool(true)
+
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
bool(false)
-bool(false)
-bool(true)
+
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
bool(false)
diff --git a/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt b/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt
index 361708a315..caf55fa648 100644
--- a/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt
@@ -17,8 +17,8 @@ var_dump($obj->isCloneable());
$h = clone $foo;
class bar {
- private function __clone() {
- }
+ private function __clone() {
+ }
}
$bar = new bar;
print "User class - private __clone\n";
diff --git a/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt b/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt
index a108718894..e34176fe51 100644
--- a/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt
@@ -13,17 +13,17 @@ class X {}
$classes = array("A", "B", "C", "I", "X");
$instances = array( "myA" => new A,
- "myB" => new B,
- "myC" => new C,
- "myX" => new X );
+ "myB" => new B,
+ "myC" => new C,
+ "myX" => new X );
foreach ($classes as $class) {
- $rc = new ReflectionClass($class);
+ $rc = new ReflectionClass($class);
- foreach ($instances as $name => $instance) {
- echo "is $name a $class? ";
- var_dump($rc->isInstance($instance));
- }
+ foreach ($instances as $name => $instance) {
+ echo "is $name a $class? ";
+ var_dump($rc->isInstance($instance));
+ }
}
diff --git a/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt b/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt
index ef179721dc..3bc79b3e79 100644
--- a/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt
@@ -6,28 +6,28 @@ class C {
}
interface iface {
- function f1();
+ function f1();
}
class ifaceImpl implements iface {
- function f1() {}
+ function f1() {}
}
abstract class abstractClass {
- function f1() {}
- abstract function f2();
+ function f1() {}
+ abstract function f2();
}
class D extends abstractClass {
- function f2() {}
+ 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());
+ $reflectionClass = new ReflectionClass($class);
+ echo "Is $class instantiable? ";
+ var_dump($reflectionClass->IsInstantiable());
}
diff --git a/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt b/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt
index 1378edd3d2..cdfaf911e4 100644
--- a/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt
+++ b/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt
@@ -6,50 +6,27 @@ class noCtor {
}
class publicCtorNew {
- public function __construct() {}
+ public function __construct() {}
}
class protectedCtorNew {
- protected function __construct() {}
+ protected function __construct() {}
}
class privateCtorNew {
- private function __construct() {}
+ 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());
+$classes = array("noCtor", "publicCtorNew", "protectedCtorNew", "privateCtorNew");
+foreach ($classes as $class) {
+ $reflectionClass = new ReflectionClass($class);
+ echo "Is $class instantiable? ";
+ var_dump($reflectionClass->IsInstantiable());
}
?>
---EXPECTF--
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; publicCtorOld has a deprecated constructor in %s on line %d
-
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; protectedCtorOld has a deprecated constructor in %s on line %d
-
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; privateCtorOld has a deprecated constructor in %s on line %d
+--EXPECT--
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_isInternal_basic.phpt b/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt
index 9c656a38b6..48f0c963ea 100644
--- a/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt
@@ -12,7 +12,7 @@ $r4 = new ReflectionClass("Exception");
$r5 = new ReflectionClass("C");
var_dump($r1->isInternal(), $r2->isInternal(), $r3->isInternal(),
- $r4->isInternal(), $r5->isInternal());
+ $r4->isInternal(), $r5->isInternal());
?>
--EXPECT--
bool(true)
diff --git a/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt b/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt
index 10a86d9136..10fa07fc06 100644
--- a/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt
@@ -10,41 +10,31 @@ 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() {}
+ public function next() {}
+ public function key() {}
+ public function rewind() {}
+ public function current() {}
+ public function valid() {}
}
-Class IterarorAggregateImpl implements IteratorAggregate {
- public function getIterator() {}
+Class IteratorAggregateImpl implements IteratorAggregate {
+ public function getIterator() {}
}
Class ExtendsIteratorImpl extends IteratorImpl {
}
-Class ExtendsIteratorAggregateImpl extends IterarorAggregateImpl {
+Class ExtendsIteratorAggregateImpl extends IteratorAggregateImpl {
}
Class A {
}
$classes = array('Traversable', 'Iterator', 'IteratorAggregate', 'ExtendsIterator', 'ExtendsIteratorAggregate',
- 'IteratorImpl', 'IterarorAggregateImpl', 'ExtendsIteratorImpl', 'ExtendsIteratorAggregateImpl', 'A');
+ 'IteratorImpl', 'IteratorAggregateImpl', 'ExtendsIteratorImpl', 'ExtendsIteratorAggregateImpl', 'A');
foreach($classes as $class) {
- $rc = new ReflectionClass($class);
- echo "Is $class iterable? ";
- var_dump($rc->isIterateable());
+ $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();
@@ -56,37 +46,14 @@ 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 IteratorAggregateImpl 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: Uncaught Error: Non-static method ReflectionClass::isIterateable() cannot be called statically in %s:43
+Fatal error: Uncaught Error: Non-static method ReflectionClass::isIterateable() cannot be called statically in %s:%d
Stack trace:
#0 {main}
- thrown in %s on line 43
+ thrown in %s on line %d
diff --git a/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt b/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt
index 8b65b9a0bd..f11433eced 100644
--- a/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt
@@ -6,25 +6,25 @@ Felix De Vliegher <felix.devliegher@gmail.com>, Marc Veldman <marc@ibuildings.nl
<?php
class IteratorClass implements Iterator {
- public function __construct() { }
- public function key() {}
- public function current() {}
- function next() {}
- function valid() {}
- function rewind() {}
+ 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());
+ $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);
+ echo "Is $class iterateable? ";
+ dump_iterateable($class);
}
?>
--EXPECT--
diff --git a/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt b/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt
index f6d0d5346a..839867893a 100644
--- a/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt
+++ b/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt
@@ -9,8 +9,8 @@ class BasicClass {}
function dump_iterateable($obj)
{
- $reflection = new ReflectionClass($obj);
- var_dump($reflection->isIterateable());
+ $reflection = new ReflectionClass($obj);
+ var_dump($reflection->isIterateable());
}
$basicClass = new BasicClass();
diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt
index 368ea7d7ec..51fc52b8ee 100644
--- a/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt
+++ b/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt
@@ -10,39 +10,35 @@ $rc = new ReflectionClass('A');
echo "\n\nTest bad arguments:\n";
try {
- var_dump($rc->isSubclassOf());
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $rc->isSubclassOf();
+} catch (ArgumentCountError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->isSubclassOf('C', 'C'));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $rc->isSubclassOf('C', 'C');
+} catch (ArgumentCountError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->isSubclassOf(null));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $rc->isSubclassOf(null);
+} catch (ReflectionException $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->isSubclassOf('ThisClassDoesNotExist'));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $rc->isSubclassOf('ThisClassDoesNotExist');
+} catch (ReflectionException $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->isSubclassOf(2));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $rc->isSubclassOf(2);
+} catch (ReflectionException $e) {
+ echo $e->getMessage() . "\n";
}
?>
---EXPECTF--
+--EXPECT--
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
+ReflectionClass::isSubclassOf() expects exactly 1 argument, 0 given
+ReflectionClass::isSubclassOf() expects exactly 1 argument, 2 given
+Class "" does not exist
+Class "ThisClassDoesNotExist" does not exist
+Class "2" does not exist
diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt
index c05ec27ccd..a52611fb21 100644
--- a/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt
@@ -12,17 +12,17 @@ class X implements I {}
$classNames = array('A', 'B', 'C', 'I', 'X');
foreach ($classNames as $className) {
- $rcs[$className] = new ReflectionClass($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));
- }
+ 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));
+ }
}
?>
--EXPECT--
diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt
index bb4f96818a..1d804641f3 100644
--- a/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt
+++ b/ext/reflection/tests/ReflectionClass_isSubclassOf_error1.phpt
@@ -9,7 +9,7 @@ var_dump($rc->isSubclassOf('X'));
?>
--EXPECTF--
-Fatal error: Uncaught ReflectionException: Class X does not exist in %s:5
+Fatal error: Uncaught ReflectionException: Class "X" does not exist in %s:%d
Stack trace:
#0 %s(5): ReflectionClass->isSubclassOf('X')
#1 {main}
diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_error2.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_error2.phpt
index 8671c2500b..df7fb42073 100644
--- a/ext/reflection/tests/ReflectionClass_isSubclassOf_error2.phpt
+++ b/ext/reflection/tests/ReflectionClass_isSubclassOf_error2.phpt
@@ -11,7 +11,7 @@ class Base {}
$check = function () {
$base = Base::class;
foreach (get_declared_classes() as $class) {
- if (strpos($class, 'class@anonymous') === false) {
+ if (strpos($class, '@anonymous') === false) {
continue;
}
echo "Checking for $class\n";
@@ -30,6 +30,6 @@ echo "Done\n";
?>
--EXPECTF--
After first check
-Checking for class@%s
+Checking for Base@%s
true
Done
diff --git a/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt b/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt
index e9537c1e8a..ee2206177d 100644
--- a/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt
@@ -12,7 +12,7 @@ $r4 = new ReflectionClass("Exception");
$r5 = new ReflectionClass("C");
var_dump($r1->isUserDefined(), $r2->isUserDefined(), $r3->isUserDefined(),
- $r4->isUserDefined(), $r5->isUserDefined());
+ $r4->isUserDefined(), $r5->isUserDefined());
?>
--EXPECT--
bool(false)
diff --git a/ext/reflection/tests/ReflectionClass_modifiers_001.phpt b/ext/reflection/tests/ReflectionClass_modifiers_001.phpt
index 1370228f04..cb2a6555f1 100644
--- a/ext/reflection/tests/ReflectionClass_modifiers_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_modifiers_001.phpt
@@ -14,11 +14,11 @@ 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());
+ $rc = new ReflectionClass($class);
+ var_dump($rc->isFinal());
+ var_dump($rc->isInterface());
+ var_dump($rc->isAbstract());
+ var_dump($rc->getModifiers());
}
?>
--EXPECT--
diff --git a/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt b/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt
index 068710311d..7dded54d3f 100644
--- a/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt
@@ -5,93 +5,66 @@ 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";
- }
+ 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";
- }
+ protected function __construct() {
+ echo "In constructor of class C\n";
+ }
}
class D {
- private function __construct() {
- echo "In constructor of class D\n";
- }
+ 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');
try {
- var_dump($rcA->newInstanceArgs());
-} catch (Throwable $e) {
- echo "Exception: " . $e->getMessage() . "\n";
-}
-try {
- var_dump($rcA->newInstanceArgs(array('x')));
+ $rcB->newInstanceArgs();
} catch (Throwable $e) {
- echo "Exception: " . $e->getMessage() . "\n";
+ echo "Exception: " . $e->getMessage() . "\n";
}
-try {
- var_dump($rcB->newInstanceArgs());
-} catch (Throwable $e) {
- echo "Exception: " . $e->getMessage() . "\n";
-}
-try {
- var_dump($rcB->newInstanceArgs(array('x', 123)));
-} catch (Throwable $e) {
- echo "Exception: " . $e->getMessage() . "\n";
-}
+var_dump($rcB->newInstanceArgs(array('x', 123)));
try {
- $rcC->newInstanceArgs();
- echo "you should not see this\n";
+ $rcC->newInstanceArgs();
+ echo "you should not see this\n";
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- $rcD->newInstanceArgs();
- echo "you should not see this\n";
+ $rcD->newInstanceArgs();
+ echo "you should not see this\n";
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
$e1 = $rcE->newInstanceArgs();
var_dump($e1);
try {
- $e2 = $rcE->newInstanceArgs(array('x'));
- echo "you should not see this\n";
+ $e2 = $rcE->newInstanceArgs(array('x'));
+ echo "you should not see this\n";
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
?>
--EXPECTF--
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d
-In constructor of class A
-object(A)#%d (0) {
-}
-In constructor of class A
-object(A)#%d (0) {
-}
Exception: Too few arguments to function B::__construct(), 0 passed and exactly 2 expected
In constructor of class B with args x, 123
object(B)#%d (0) {
diff --git a/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt b/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt
index bd27dfc173..e7256ea2cb 100644
--- a/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt
+++ b/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt
@@ -6,9 +6,9 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class A {
- public function __construct($a, $b) {
- echo "In constructor of class B with arg $a\n";
- }
+ public function __construct($a, $b) {
+ echo "In constructor of class B with arg $a\n";
+ }
}
$rc = new ReflectionClass('A');
$a = $rc->newInstanceArgs('x');
@@ -16,8 +16,8 @@ var_dump($a);
?>
--EXPECTF--
-Fatal error: Uncaught TypeError: Argument 1 passed to ReflectionClass::newInstanceArgs() must be of the type array, string given in %s:8
+Fatal error: Uncaught TypeError: ReflectionClass::newInstanceArgs(): Argument #1 ($args) must be of type array, string given in %s:%d
Stack trace:
#0 %s(%d): ReflectionClass->newInstanceArgs('x')
#1 {main}
- thrown in %s on line 8
+ thrown in %s on line %d
diff --git a/ext/reflection/tests/ReflectionClass_newInstance_001.phpt b/ext/reflection/tests/ReflectionClass_newInstance_001.phpt
index c91d2ee958..22d06e3282 100644
--- a/ext/reflection/tests/ReflectionClass_newInstance_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_newInstance_001.phpt
@@ -5,86 +5,69 @@ 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";
- }
+ 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";
- }
+ protected function __construct() {
+ echo "In constructor of class C\n";
+ }
}
class D {
- private function __construct() {
- echo "In constructor of class D\n";
- }
+ 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);
-
try {
- var_dump($rcB->newInstance());
+ var_dump($rcB->newInstance());
} catch (Throwable $e) {
- echo "Exception: " . $e->getMessage() . "\n";
+ echo "Exception: " . $e->getMessage() . "\n";
}
try {
- var_dump($rcB->newInstance('x', 123));
+ var_dump($rcB->newInstance('x', 123));
} catch (Throwable $e) {
- echo "Exception: " . $e->getMessage() . "\n";
+ echo "Exception: " . $e->getMessage() . "\n";
}
try {
- $rcC->newInstance();
- echo "you should not see this\n";
+ $rcC->newInstance();
+ echo "you should not see this\n";
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- $rcD->newInstance();
- echo "you should not see this\n";
+ $rcD->newInstance();
+ echo "you should not see this\n";
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
$e1 = $rcE->newInstance();
var_dump($e1);
try {
- $e2 = $rcE->newInstance('x');
- echo "you should not see this\n";
+ $e2 = $rcE->newInstance('x');
+ echo "you should not see this\n";
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
?>
--EXPECTF--
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d
-In constructor of class A
-In constructor of class A
-object(A)#%d (0) {
-}
-object(A)#%d (0) {
-}
Exception: Too few arguments to function B::__construct(), 0 passed and exactly 2 expected
In constructor of class B with args x, 123
object(B)#%d (0) {
diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt
index 41a6482f66..2c855a0436 100644
--- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt
@@ -6,15 +6,15 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class A {
- static private $privateOverridden = "original private";
- static protected $protectedOverridden = "original protected";
- static public $publicOverridden = "original public";
+ 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";
+ static private $privateOverridden = "changed private";
+ static protected $protectedOverridden = "changed protected";
+ static public $publicOverridden = "changed public";
}
echo "Set static values in A:\n";
@@ -35,17 +35,17 @@ print_r($rcB->getStaticProperties());
echo "\nSet non-existent values from A with no default value:\n";
try {
- var_dump($rcA->setStaticPropertyValue("protectedDoesNotExist", "new value 8"));
- echo "you should not see this";
+ var_dump($rcA->setStaticPropertyValue("protectedDoesNotExist", "new value 8"));
+ echo "you should not see this";
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rcA->setStaticPropertyValue("privateDoesNotExist", "new value 9"));
- echo "you should not see this";
+ var_dump($rcA->setStaticPropertyValue("privateDoesNotExist", "new value 9"));
+ echo "you should not see this";
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
?>
diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt
index fb472681ca..7bd2b1eecd 100644
--- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt
+++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt
@@ -6,54 +6,47 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
class C {
- public static $x;
+ public static $x;
}
$rc = new ReflectionClass('C');
try {
- var_dump($rc->setStaticPropertyValue("x", "default value", 'blah'));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->setStaticPropertyValue("x", "default value", 'blah'));
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->setStaticPropertyValue());
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->setStaticPropertyValue());
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->setStaticPropertyValue(null));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->setStaticPropertyValue(null));
+} catch (TypeError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->setStaticPropertyValue(null,null));
+ var_dump($rc->setStaticPropertyValue(null,null));
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->setStaticPropertyValue(1.5, 'def'));
+ var_dump($rc->setStaticPropertyValue(1.5, 'def'));
} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($rc->setStaticPropertyValue(array(1,2,3), 'blah'));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ var_dump($rc->setStaticPropertyValue(array(1,2,3), 'blah'));
+} catch (TypeError $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
+--EXPECT--
+ReflectionClass::setStaticPropertyValue() expects exactly 2 arguments, 3 given
+ReflectionClass::setStaticPropertyValue() expects exactly 2 arguments, 0 given
+ReflectionClass::setStaticPropertyValue() expects exactly 2 arguments, 1 given
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
+ReflectionClass::setStaticPropertyValue(): Argument #1 ($name) must be of type string, array given
diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt
index a83900a123..959cc1bea0 100644
--- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt
+++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt
@@ -11,7 +11,7 @@ class Test {
$rc = new ReflectionClass('Test');
try {
- $rc->setStaticPropertyValue("y", "foo");
+ $rc->setStaticPropertyValue("y", "foo");
} catch (TypeError $e) { echo $e->getMessage(), "\n"; }
var_dump(Test::$y);
@@ -22,7 +22,7 @@ var_dump(Test::$y);
Test::$x =& Test::$y;
try {
- $rc->setStaticPropertyValue("x", "foo");
+ $rc->setStaticPropertyValue("x", "foo");
} catch (TypeError $e) { echo $e->getMessage(), "\n"; }
var_dump(Test::$y);
@@ -31,7 +31,7 @@ var_dump(Test::$y);
?>
--EXPECT--
-Typed property Test::$y must be int, string used
+Cannot assign string to property Test::$y of type int
int(2)
int(21)
Cannot assign string to reference held by property Test::$y of type int
diff --git a/ext/reflection/tests/ReflectionClass_toString_001.phpt b/ext/reflection/tests/ReflectionClass_toString_001.phpt
index 2cfd808cb8..86d6720fe6 100644
--- a/ext/reflection/tests/ReflectionClass_toString_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_toString_001.phpt
@@ -9,7 +9,7 @@ $rc = new ReflectionClass("ReflectionClass");
echo $rc;
?>
--EXPECT--
-Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
+Class [ <internal:Reflection> class ReflectionClass implements Reflector, Stringable ] {
- Constants [3] {
Constant [ public int IS_IMPLICIT_ABSTRACT ] { 16 }
@@ -20,38 +20,33 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
- Static properties [0] {
}
- - Static methods [1] {
- Method [ <internal, deprecated:Reflection> static public method export ] {
-
- - Parameters [2] {
- Parameter #0 [ <required> $argument ]
- Parameter #1 [ <optional> $return ]
- }
- }
+ - Static methods [0] {
}
- Properties [1] {
- Property [ <default> public $name ]
+ Property [ public $name = '' ]
}
- - Methods [53] {
+ - Methods [54] {
Method [ <internal:Reflection> final private method __clone ] {
- Parameters [0] {
}
+ - Return [ void ]
}
Method [ <internal:Reflection, ctor> public method __construct ] {
- Parameters [1] {
- Parameter #0 [ <required> $argument ]
+ Parameter #0 [ <required> object|string $objectOrClass ]
}
}
- Method [ <internal:Reflection, prototype Reflector> public method __toString ] {
+ Method [ <internal:Reflection, prototype Stringable> public method __toString ] {
- Parameters [0] {
}
+ - Return [ string ]
}
Method [ <internal:Reflection> public method getName ] {
@@ -123,75 +118,77 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
Method [ <internal:Reflection> public method hasMethod ] {
- Parameters [1] {
- Parameter #0 [ <required> $name ]
+ Parameter #0 [ <required> string $name ]
}
}
Method [ <internal:Reflection> public method getMethod ] {
- Parameters [1] {
- Parameter #0 [ <required> $name ]
+ Parameter #0 [ <required> string $name ]
}
}
Method [ <internal:Reflection> public method getMethods ] {
- Parameters [1] {
- Parameter #0 [ <optional> $filter ]
+ Parameter #0 [ <optional> ?int $filter = null ]
}
}
Method [ <internal:Reflection> public method hasProperty ] {
- Parameters [1] {
- Parameter #0 [ <required> $name ]
+ Parameter #0 [ <required> string $name ]
}
}
Method [ <internal:Reflection> public method getProperty ] {
- Parameters [1] {
- Parameter #0 [ <required> $name ]
+ Parameter #0 [ <required> string $name ]
}
}
Method [ <internal:Reflection> public method getProperties ] {
- Parameters [1] {
- Parameter #0 [ <optional> $filter ]
+ Parameter #0 [ <optional> ?int $filter = null ]
}
}
Method [ <internal:Reflection> public method hasConstant ] {
- Parameters [1] {
- Parameter #0 [ <required> $name ]
+ Parameter #0 [ <required> string $name ]
}
}
Method [ <internal:Reflection> public method getConstants ] {
- - Parameters [0] {
+ - Parameters [1] {
+ Parameter #0 [ <optional> ?int $filter = null ]
}
}
Method [ <internal:Reflection> public method getReflectionConstants ] {
- - Parameters [0] {
+ - Parameters [1] {
+ Parameter #0 [ <optional> ?int $filter = null ]
}
}
Method [ <internal:Reflection> public method getConstant ] {
- Parameters [1] {
- Parameter #0 [ <required> $name ]
+ Parameter #0 [ <required> string $name ]
}
}
Method [ <internal:Reflection> public method getReflectionConstant ] {
- Parameters [1] {
- Parameter #0 [ <required> $name ]
+ Parameter #0 [ <required> string $name ]
}
}
@@ -258,14 +255,14 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
Method [ <internal:Reflection> public method isInstance ] {
- Parameters [1] {
- Parameter #0 [ <required> $object ]
+ Parameter #0 [ <required> object $object ]
}
}
Method [ <internal:Reflection> public method newInstance ] {
- Parameters [1] {
- Parameter #0 [ <required> $args ]
+ Parameter #0 [ <optional> mixed ...$args ]
}
}
@@ -278,7 +275,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
Method [ <internal:Reflection> public method newInstanceArgs ] {
- Parameters [1] {
- Parameter #0 [ <optional> array $args ]
+ Parameter #0 [ <optional> array $args = [] ]
}
}
@@ -291,7 +288,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
Method [ <internal:Reflection> public method isSubclassOf ] {
- Parameters [1] {
- Parameter #0 [ <required> $class ]
+ Parameter #0 [ <required> ReflectionClass|string $class ]
}
}
@@ -304,16 +301,16 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
Method [ <internal:Reflection> public method getStaticPropertyValue ] {
- Parameters [2] {
- Parameter #0 [ <required> $name ]
- Parameter #1 [ <optional> $default ]
+ Parameter #0 [ <required> string $name ]
+ Parameter #1 [ <optional> mixed $default = <default> ]
}
}
Method [ <internal:Reflection> public method setStaticPropertyValue ] {
- Parameters [2] {
- Parameter #0 [ <required> $name ]
- Parameter #1 [ <required> $value ]
+ Parameter #0 [ <required> string $name ]
+ Parameter #1 [ <required> mixed $value ]
}
}
@@ -338,7 +335,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
Method [ <internal:Reflection> public method implementsInterface ] {
- Parameters [1] {
- Parameter #0 [ <required> $interface ]
+ Parameter #0 [ <required> ReflectionClass|string $interface ]
}
}
@@ -371,5 +368,14 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
- Parameters [0] {
}
}
+
+ Method [ <internal:Reflection> public method getAttributes ] {
+
+ - Parameters [2] {
+ Parameter #0 [ <optional> ?string $name = null ]
+ Parameter #1 [ <optional> int $flags = 0 ]
+ }
+ - Return [ array ]
+ }
}
}
diff --git a/ext/reflection/tests/ReflectionClass_toString_002.phpt b/ext/reflection/tests/ReflectionClass_toString_002.phpt
index 5395ae66b9..a6824e540d 100644
--- a/ext/reflection/tests/ReflectionClass_toString_002.phpt
+++ b/ext/reflection/tests/ReflectionClass_toString_002.phpt
@@ -6,21 +6,21 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
Class A {
- function f() {}
+ function f() {}
}
Class B extends A {
- function f() {}
+ function f() {}
}
Class C extends B {
}
Class D extends C {
- function f() {}
+ function f() {}
}
foreach (array('A', 'B', 'C', 'D') as $class) {
- echo "\n\n----( Reflection class $class: )----\n";
- $rc = new ReflectionClass($class);
- echo $rc;
+ echo "\n\n----( Reflection class $class: )----\n";
+ $rc = new ReflectionClass($class);
+ echo $rc;
}
?>
diff --git a/ext/reflection/tests/ReflectionClass_toString_003.phpt b/ext/reflection/tests/ReflectionClass_toString_003.phpt
index 1ce1fddf91..a67d0bfac5 100644
--- a/ext/reflection/tests/ReflectionClass_toString_003.phpt
+++ b/ext/reflection/tests/ReflectionClass_toString_003.phpt
@@ -6,21 +6,21 @@ Steve Seear <stevseea@php.net>
--FILE--
<?php
Class A {
- private function f() {}
+ private function f() {}
}
Class B extends A {
- private function f() {}
+ private function f() {}
}
Class C extends B {
}
Class D extends C {
- private function f() {}
+ private function f() {}
}
foreach (array('A', 'B', 'C', 'D') as $class) {
- echo "\n\n----( Reflection class $class: )----\n";
- $rc = new ReflectionClass($class);
- echo $rc;
+ echo "\n\n----( Reflection class $class: )----\n";
+ $rc = new ReflectionClass($class);
+ echo $rc;
}
?>
diff --git a/ext/reflection/tests/ReflectionClass_toString_004.phpt b/ext/reflection/tests/ReflectionClass_toString_004.phpt
index 04b42d0792..0eecb3c8a3 100644
--- a/ext/reflection/tests/ReflectionClass_toString_004.phpt
+++ b/ext/reflection/tests/ReflectionClass_toString_004.phpt
@@ -14,4 +14,4 @@ try {
?>
--EXPECT--
-Undefined class constant 'self::UNKNOWN'
+Undefined constant self::UNKNOWN
diff --git a/ext/reflection/tests/ReflectionExtension_bug66218.phpt b/ext/reflection/tests/ReflectionExtension_bug66218.phpt
index 77f3d230b3..f42967c089 100644
--- a/ext/reflection/tests/ReflectionExtension_bug66218.phpt
+++ b/ext/reflection/tests/ReflectionExtension_bug66218.phpt
@@ -2,7 +2,6 @@
ReflectionExtension::getFunctions() ##6218 zend_register_functions breaks reflection
--SKIPIF--
<?php
-if (PHP_SAPI != "cli") die("skip CLI only test");
if (!function_exists("dl")) die("skip need dl");
?>
--FILE--
diff --git a/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt b/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt
index 72c8ac6bd8..25a4bbf4b8 100644
--- a/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt
+++ b/ext/reflection/tests/ReflectionExtension_constructor_basic.phpt
@@ -9,7 +9,5 @@ $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
index 94071de5ab..f4241bcd92 100644
--- a/ext/reflection/tests/ReflectionExtension_constructor_error.phpt
+++ b/ext/reflection/tests/ReflectionExtension_constructor_error.phpt
@@ -6,28 +6,26 @@ Leon Luijkx <leon@phpgg.nl>
--FILE--
<?php
try {
- $obj = new ReflectionExtension();
+ $obj = new ReflectionExtension();
} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
- $obj = new ReflectionExtension('foo', 'bar');
+ $obj = new ReflectionExtension('foo', 'bar');
} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
- $obj = new ReflectionExtension([]);
+ $obj = new ReflectionExtension([]);
} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
?>
-==DONE==
---EXPECTF--
-Ok - ReflectionExtension::__construct() expects exactly %d parameter, %d given
-Ok - ReflectionExtension::__construct() expects exactly %d parameter, %d given
-Ok - ReflectionExtension::__construct() expects parameter 1 to be string, array given
-==DONE==
+--EXPECT--
+Ok - ReflectionExtension::__construct() expects exactly 1 argument, 0 given
+Ok - ReflectionExtension::__construct() expects exactly 1 argument, 2 given
+Ok - ReflectionExtension::__construct(): Argument #1 ($name) must be of type string, array given
diff --git a/ext/reflection/tests/ReflectionExtension_export_basic.phpt b/ext/reflection/tests/ReflectionExtension_export_basic.phpt
deleted file mode 100644
index 4652a409a1..0000000000
--- a/ext/reflection/tests/ReflectionExtension_export_basic.phpt
+++ /dev/null
@@ -1,18 +0,0 @@
---TEST--
-ReflectionExtension::export()
---CREDITS--
-Gerrit "Remi" te Sligte <remi@wolerized.com>
-Leon Luijkx <leon@phpgg.nl>
---FILE--
-<?php
-ReflectionExtension::export("reflection", true);
-ob_start();
-ReflectionExtension::export("reflection", false);
-$test = ob_get_clean();
-var_dump(empty($test));
-?>
-==DONE==
---EXPECTF--
-Deprecated: Function ReflectionExtension::export() is deprecated in %s on line %d
-bool(false)
-==DONE==
diff --git a/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt b/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt
index 3fea08c43f..e90209ee67 100644
--- a/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt
+++ b/ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt
@@ -7,7 +7,6 @@ Felix De Vliegher <felix.devliegher@gmail.com>
$standard = new ReflectionExtension('standard');
var_dump($standard->getClassNames());
?>
-==DONE==
--EXPECTF--
array(4) {
[0]=>
@@ -19,4 +18,3 @@ array(4) {
[3]=>
%s(14) "AssertionError"
}
-==DONE==
diff --git a/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt b/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt
index 91912b9220..34f6112d98 100644
--- a/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt
+++ b/ext/reflection/tests/ReflectionExtension_getClassNames_variation1.phpt
@@ -11,8 +11,6 @@ extension_loaded('ctype') or die("skip Requires 'ctype' extension");
$extension = new ReflectionExtension('ctype');
var_dump($extension->getClassNames());
?>
-==DONE==
--EXPECT--
array(0) {
}
-==DONE==
diff --git a/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt b/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt
index 5877f88e27..81d3c8d55b 100644
--- a/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt
+++ b/ext/reflection/tests/ReflectionExtension_getClasses_basic.phpt
@@ -7,9 +7,8 @@ Thijs Lensselink <tl@lenss.nl>
$ext = new ReflectionExtension('reflection');
var_dump($ext->getClasses());
?>
-==DONE==
--EXPECT--
-array(17) {
+array(19) {
["ReflectionException"]=>
object(ReflectionClass)#2 (1) {
["name"]=>
@@ -55,45 +54,54 @@ array(17) {
["name"]=>
string(19) "ReflectionNamedType"
}
- ["ReflectionMethod"]=>
+ ["ReflectionUnionType"]=>
object(ReflectionClass)#11 (1) {
["name"]=>
+ string(19) "ReflectionUnionType"
+ }
+ ["ReflectionMethod"]=>
+ object(ReflectionClass)#12 (1) {
+ ["name"]=>
string(16) "ReflectionMethod"
}
["ReflectionClass"]=>
- object(ReflectionClass)#12 (1) {
+ object(ReflectionClass)#13 (1) {
["name"]=>
string(15) "ReflectionClass"
}
["ReflectionObject"]=>
- object(ReflectionClass)#13 (1) {
+ object(ReflectionClass)#14 (1) {
["name"]=>
string(16) "ReflectionObject"
}
["ReflectionProperty"]=>
- object(ReflectionClass)#14 (1) {
+ object(ReflectionClass)#15 (1) {
["name"]=>
string(18) "ReflectionProperty"
}
["ReflectionClassConstant"]=>
- object(ReflectionClass)#15 (1) {
+ object(ReflectionClass)#16 (1) {
["name"]=>
string(23) "ReflectionClassConstant"
}
["ReflectionExtension"]=>
- object(ReflectionClass)#16 (1) {
+ object(ReflectionClass)#17 (1) {
["name"]=>
string(19) "ReflectionExtension"
}
["ReflectionZendExtension"]=>
- object(ReflectionClass)#17 (1) {
+ object(ReflectionClass)#18 (1) {
["name"]=>
string(23) "ReflectionZendExtension"
}
["ReflectionReference"]=>
- object(ReflectionClass)#18 (1) {
+ object(ReflectionClass)#19 (1) {
["name"]=>
string(19) "ReflectionReference"
}
+ ["ReflectionAttribute"]=>
+ object(ReflectionClass)#20 (1) {
+ ["name"]=>
+ string(19) "ReflectionAttribute"
+ }
}
-==DONE==
diff --git a/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt b/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt
index 8b5293a48f..306380c9d1 100644
--- a/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt
+++ b/ext/reflection/tests/ReflectionExtension_getDependencies_basic.phpt
@@ -11,7 +11,6 @@ if (!extension_loaded("dom")) die("skip no dom extension");
$dom = new ReflectionExtension('dom');
var_dump($dom->getDependencies());
?>
-==DONE==
--EXPECTF--
array(2) {
["libxml"]=>
@@ -19,4 +18,3 @@ array(2) {
["domxml"]=>
%s(9) "Conflicts"
}
-==DONE==
diff --git a/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt b/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt
index 5b0ade5da2..be13fe27a8 100644
--- a/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt
+++ b/ext/reflection/tests/ReflectionExtension_getDependencies_variation2.phpt
@@ -7,10 +7,8 @@ Felix De Vliegher <felix.devliegher@gmail.com>
$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
index 9dae1f3a6b..c26044f710 100644
--- a/ext/reflection/tests/ReflectionExtension_getName_basic.phpt
+++ b/ext/reflection/tests/ReflectionExtension_getName_basic.phpt
@@ -8,7 +8,5 @@ Leon Luijkx <leon@phpgg.nl>
$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
index 19dee82710..1fc69c9bf9 100644
--- a/ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt
+++ b/ext/reflection/tests/ReflectionExtension_getVersion_basic.phpt
@@ -7,10 +7,7 @@ Leon Luijkx <leon@phpgg.nl>
<?php
$obj = new ReflectionExtension('reflection');
$var = $obj->getVersion() ? $obj->getVersion() : null;
-$test = floatval($var) == $var ? true : false;
-var_dump($test);
+var_dump($var);
?>
-==DONE==
---EXPECT--
-bool(true)
-==DONE==
+--EXPECTF--
+string(%d) "%d.%d.%s"
diff --git a/ext/reflection/tests/ReflectionExtension_info_basic.phpt b/ext/reflection/tests/ReflectionExtension_info_basic.phpt
index 48f6a65099..6eac5a56e7 100644
--- a/ext/reflection/tests/ReflectionExtension_info_basic.phpt
+++ b/ext/reflection/tests/ReflectionExtension_info_basic.phpt
@@ -12,8 +12,6 @@ $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
index a78a8bbc3d..642a79bd3b 100644
--- a/ext/reflection/tests/ReflectionExtension_isPersistant.phpt
+++ b/ext/reflection/tests/ReflectionExtension_isPersistant.phpt
@@ -5,7 +5,5 @@ ReflectionExtension::isPersistent()
$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
index be97641be1..791662ff13 100644
--- a/ext/reflection/tests/ReflectionExtension_isTemporary.phpt
+++ b/ext/reflection/tests/ReflectionExtension_isTemporary.phpt
@@ -5,7 +5,5 @@ ReflectionExtension::isTemporary()
$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
index 6785e5d0b1..4c0a58ca9d 100644
--- a/ext/reflection/tests/ReflectionFunction_001.phpt
+++ b/ext/reflection/tests/ReflectionFunction_001.phpt
@@ -10,10 +10,10 @@ Steve Seear <stevseea@php.net>
* my doc comment
*/
function foo () {
- static $c;
- static $a = 1;
- static $b = "hello";
- $d = 5;
+ static $c;
+ static $a = 1;
+ static $b = "hello";
+ $d = 5;
}
/***
@@ -23,13 +23,13 @@ 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());
+ $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');
diff --git a/ext/reflection/tests/ReflectionFunction_construct.001.phpt b/ext/reflection/tests/ReflectionFunction_construct.001.phpt
index eab542e005..f7020699d5 100644
--- a/ext/reflection/tests/ReflectionFunction_construct.001.phpt
+++ b/ext/reflection/tests/ReflectionFunction_construct.001.phpt
@@ -7,36 +7,36 @@ Steve Seear <stevseea@php.net>
<?php
try {
- $a = new ReflectionFunction(array(1, 2, 3));
- echo "exception not thrown.".PHP_EOL;
+ $a = new ReflectionFunction(array(1, 2, 3));
+ echo "exception not thrown.".PHP_EOL;
} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
- $a = new ReflectionFunction('nonExistentFunction');
+ $a = new ReflectionFunction('nonExistentFunction');
} catch (ReflectionException $e) {
- echo $e->getMessage().PHP_EOL;
+ echo $e->getMessage().PHP_EOL;
}
try {
- $a = new ReflectionFunction();
+ $a = new ReflectionFunction();
} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
- $a = new ReflectionFunction(1, 2);
+ $a = new ReflectionFunction(1, 2);
} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
- $a = new ReflectionFunction([]);
+ $a = new ReflectionFunction([]);
} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
?>
--EXPECT--
-Ok - ReflectionFunction::__construct() expects parameter 1 to be string, array given
+Ok - ReflectionFunction::__construct(): Argument #1 ($function) must be of type Closure|string, array given
Function nonExistentFunction() does not exist
-Ok - ReflectionFunction::__construct() expects exactly 1 parameter, 0 given
-Ok - ReflectionFunction::__construct() expects exactly 1 parameter, 2 given
-Ok - ReflectionFunction::__construct() expects parameter 1 to be string, array given
+Ok - ReflectionFunction::__construct() expects exactly 1 argument, 0 given
+Ok - ReflectionFunction::__construct() expects exactly 1 argument, 2 given
+Ok - ReflectionFunction::__construct(): Argument #1 ($function) must be of type Closure|string, array given
diff --git a/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt b/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt
index b8b969b0bc..f7cb6b36ec 100644
--- a/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt
+++ b/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt
@@ -7,9 +7,9 @@ $rf = new ReflectionFunction($closure);
var_dump($rf->getClosureScopeClass());
Class A {
- public static function getClosure() {
- return function($param) { return "this is a closure"; };
- }
+ public static function getClosure() {
+ return function($param) { return "this is a closure"; };
+ }
}
$closure = A::getClosure();
diff --git a/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt b/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt
index 4c76959aec..2d6a5b7346 100644
--- a/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt
+++ b/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt
@@ -2,22 +2,16 @@
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" );
+ var_dump( "Inside foo function" );
}
function bar( $arg )
{
- var_dump( "Arg is " . $arg );
+ var_dump( "Arg is " . $arg );
}
$func = new ReflectionFunction( 'foo' );
@@ -29,9 +23,7 @@ $closure = $func->getClosure();
$closure( 'succeeded' );
?>
-===DONE===
--EXPECT--
*** Testing ReflectionFunction::getClosure() : basic functionality ***
string(19) "Inside foo function"
string(16) "Arg is succeeded"
-===DONE===
diff --git a/ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt b/ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt
index 03cec2ee79..590f5cfa10 100644
--- a/ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt
+++ b/ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt
@@ -12,10 +12,10 @@ opcache.save_comments=1
* my doc comment
*/
function foo () {
- static $c;
- static $a = 1;
- static $b = "hello";
- $d = 5;
+ static $c;
+ static $a = 1;
+ static $b = "hello";
+ $d = 5;
}
/***
@@ -25,8 +25,8 @@ function bar () {}
function dumpFuncInfo($name) {
- $funcInfo = new ReflectionFunction($name);
- var_dump($funcInfo->getDocComment());
+ $funcInfo = new ReflectionFunction($name);
+ var_dump($funcInfo->getDocComment());
}
dumpFuncInfo('foo');
diff --git a/ext/reflection/tests/ReflectionFunction_getFileName.002.phpt b/ext/reflection/tests/ReflectionFunction_getFileName.002.phpt
index cd75418584..39fa48a3ff 100644
--- a/ext/reflection/tests/ReflectionFunction_getFileName.002.phpt
+++ b/ext/reflection/tests/ReflectionFunction_getFileName.002.phpt
@@ -10,10 +10,10 @@ Steve Seear <stevseea@php.net>
* my doc comment
*/
function foo () {
- static $c;
- static $a = 1;
- static $b = "hello";
- $d = 5;
+ static $c;
+ static $a = 1;
+ static $b = "hello";
+ $d = 5;
}
/***
@@ -23,8 +23,8 @@ function bar () {}
function dumpFuncInfo($name) {
- $funcInfo = new ReflectionFunction($name);
- var_dump($funcInfo->getFileName());
+ $funcInfo = new ReflectionFunction($name);
+ var_dump($funcInfo->getFileName());
}
dumpFuncInfo('foo');
diff --git a/ext/reflection/tests/ReflectionFunction_isDeprecated_basic.phpt b/ext/reflection/tests/ReflectionFunction_isDeprecated_basic.phpt
index 818d57e5f0..105d924f88 100644
--- a/ext/reflection/tests/ReflectionFunction_isDeprecated_basic.phpt
+++ b/ext/reflection/tests/ReflectionFunction_isDeprecated_basic.phpt
@@ -8,5 +8,6 @@ TestFest PHP|Tek
// We currently don't have any deprecated functions :/
$rc = new ReflectionFunction('var_dump');
var_dump($rc->isDeprecated());
+?>
--EXPECT--
bool(false)
diff --git a/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt b/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt
index 220c16f9cb..9cc7eaa31f 100644
--- a/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt
+++ b/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt
@@ -7,8 +7,18 @@ TestFest PHP|Tek
disable_functions=is_file
--FILE--
<?php
-$rc = new ReflectionFunction('is_file');
-var_dump($rc->isDisabled());
+try {
+ $rf = new ReflectionFunction('is_file');
+ var_dump($rf->isDisabled());
+} catch (ReflectionException $e) {
+ echo $e->getMessage(), "\n";
+}
+
+$rf = new ReflectionFunction('is_string');
+var_dump($rf->isDisabled());
?>
---EXPECT--
-bool(true)
+--EXPECTF--
+Function is_file() does not exist
+
+Deprecated: Method ReflectionFunction::isDisabled() is deprecated in %s on line %d
+bool(false)
diff --git a/ext/reflection/tests/ReflectionFunction_isGenerator_basic.phpt b/ext/reflection/tests/ReflectionFunction_isGenerator_basic.phpt
index 8bbbfa516f..b9a84d49c4 100644
--- a/ext/reflection/tests/ReflectionFunction_isGenerator_basic.phpt
+++ b/ext/reflection/tests/ReflectionFunction_isGenerator_basic.phpt
@@ -5,7 +5,7 @@ ReflectionFunction::isGenerator()
$closure1 = function() {return "this is a closure"; };
$closure2 = function($param) {
- yield $param;
+ yield $param;
};
$rf1 = new ReflectionFunction($closure1);
@@ -15,11 +15,11 @@ $rf2 = new ReflectionFunction($closure2);
var_dump($rf2->isGenerator());
function func1() {
- return 'func1';
+ return 'func1';
}
function func2() {
- yield 'func2';
+ yield 'func2';
}
$rf1 = new ReflectionFunction('func1');
@@ -30,17 +30,17 @@ var_dump($rf2->isGenerator());
class Foo {
- public function f1() {
- }
+ public function f1() {
+ }
- public function f2() {
- yield;
- }
+ public function f2() {
+ yield;
+ }
}
$rc = new ReflectionClass('Foo');
foreach($rc->getMethods() as $m) {
- var_dump($m->isGenerator());
+ var_dump($m->isGenerator());
}
?>
--EXPECT--
diff --git a/ext/reflection/tests/ReflectionGenerator_basic.phpt b/ext/reflection/tests/ReflectionGenerator_basic.phpt
index 6f35b6c244..f9ecc8e90e 100644
--- a/ext/reflection/tests/ReflectionGenerator_basic.phpt
+++ b/ext/reflection/tests/ReflectionGenerator_basic.phpt
@@ -4,33 +4,33 @@ ReflectionGenerator basic test
<?php
function foo() {
- yield;
+ yield;
}
$gens = [
- (new class() {
- function a() {
- yield from foo();
- }
- })->a(),
- (function() {
- yield;
- })(),
- foo(),
+ (new class() {
+ function a() {
+ yield from foo();
+ }
+ })->a(),
+ (function() {
+ yield;
+ })(),
+ foo(),
];
foreach ($gens as $gen) {
- var_dump($gen);
+ var_dump($gen);
- $gen->valid(); // start Generator
- $ref = new ReflectionGenerator($gen);
+ $gen->valid(); // start Generator
+ $ref = new ReflectionGenerator($gen);
- var_dump($ref->getTrace());
- var_dump($ref->getExecutingLine());
- var_dump($ref->getExecutingFile());
- var_dump($ref->getExecutingGenerator());
- var_dump($ref->getFunction());
- var_dump($ref->getThis());
+ var_dump($ref->getTrace());
+ var_dump($ref->getExecutingLine());
+ var_dump($ref->getExecutingFile());
+ var_dump($ref->getExecutingGenerator());
+ var_dump($ref->getFunction());
+ var_dump($ref->getThis());
}
?>
diff --git a/ext/reflection/tests/ReflectionGenerator_getTrace.phpt b/ext/reflection/tests/ReflectionGenerator_getTrace.phpt
index 05a46009e8..91b7160d4b 100644
--- a/ext/reflection/tests/ReflectionGenerator_getTrace.phpt
+++ b/ext/reflection/tests/ReflectionGenerator_getTrace.phpt
@@ -4,8 +4,8 @@ ReflectionGenerator::getTrace() over multiple Generators
<?php
function foo() {
- yield 1;
- yield 2;
+ yield 1;
+ yield 2;
}
function bar()
diff --git a/ext/reflection/tests/ReflectionGenerator_in_Generator.phpt b/ext/reflection/tests/ReflectionGenerator_in_Generator.phpt
index a227e1a213..a665d45c30 100644
--- a/ext/reflection/tests/ReflectionGenerator_in_Generator.phpt
+++ b/ext/reflection/tests/ReflectionGenerator_in_Generator.phpt
@@ -4,31 +4,31 @@ ReflectionGenerator while being currently executed
<?php
function call(ReflectionGenerator $ref, $method, $rec = true) {
- if ($rec) {
- call($ref, $method, false);
- return;
- }
- var_dump($ref->$method());
+ if ($rec) {
+ call($ref, $method, false);
+ return;
+ }
+ var_dump($ref->$method());
}
function doCalls(ReflectionGenerator $ref) {
- call($ref, "getTrace");
- call($ref, "getExecutingLine");
- call($ref, "getExecutingFile");
- call($ref, "getExecutingGenerator");
- call($ref, "getFunction");
- call($ref, "getThis");
+ call($ref, "getTrace");
+ call($ref, "getExecutingLine");
+ call($ref, "getExecutingFile");
+ call($ref, "getExecutingGenerator");
+ call($ref, "getFunction");
+ call($ref, "getThis");
}
($gen = (function() use (&$gen) {
- $ref = new ReflectionGenerator($gen);
+ $ref = new ReflectionGenerator($gen);
- doCalls($ref);
+ doCalls($ref);
- yield from (function() use ($ref) {
- doCalls($ref);
- yield; // Generator !
- })();
+ yield from (function() use ($ref) {
+ doCalls($ref);
+ yield; // Generator !
+ })();
})())->next();
?>
diff --git a/ext/reflection/tests/ReflectionMethod_006.phpt b/ext/reflection/tests/ReflectionMethod_006.phpt
index 627dc96f32..4f76e8c338 100644
--- a/ext/reflection/tests/ReflectionMethod_006.phpt
+++ b/ext/reflection/tests/ReflectionMethod_006.phpt
@@ -7,89 +7,17 @@ Steve Seear <stevseea@php.net>
<?php
try {
- new ReflectionMethod();
-} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ new ReflectionMethod();
+} catch (ArgumentCountError $re) {
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
- new ReflectionMethod('a', 'b', 'c');
-} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ new ReflectionMethod('a', 'b', 'c');
+} catch (ArgumentCountError $re) {
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
-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--
-Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 0 given
-Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 3 given
-
-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
+--EXPECT--
+Ok - ReflectionMethod::__construct() expects at least 1 argument, 0 given
+Ok - ReflectionMethod::__construct() expects at most 2 arguments, 3 given
diff --git a/ext/reflection/tests/ReflectionMethod_basic1.phpt b/ext/reflection/tests/ReflectionMethod_basic1.phpt
index 8eb970babb..e065d28ec6 100644
--- a/ext/reflection/tests/ReflectionMethod_basic1.phpt
+++ b/ext/reflection/tests/ReflectionMethod_basic1.phpt
@@ -49,6 +49,14 @@ class DerivedClass extends TestClass {}
interface TestInterface {
public function int();
+ public function __construct($arg);
+ public function __destruct();
+}
+
+trait TestTrait {
+ public abstract function __construct();
+ public function __destruct() {
+ }
}
reflectMethod("DerivedClass", "foo");
@@ -59,6 +67,10 @@ reflectMethod("DerivedClass", "prot");
reflectMethod("TestInterface", "int");
reflectMethod("ReflectionProperty", "__construct");
reflectMethod("TestClass", "__destruct");
+reflectMethod("TestInterface", "__construct");
+reflectMethod("TestInterface", "__destruct");
+reflectMethod("TestTrait", "__construct");
+reflectMethod("TestTrait", "__destruct");
?>
--EXPECT--
@@ -294,3 +306,119 @@ isDestructor():
bool(true)
**********************************
+**********************************
+Reflecting on method TestInterface::__construct()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(true)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(true)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestInterface::__destruct()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(true)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method TestTrait::__construct()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(true)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(true)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestTrait::__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
index 71ef9e95d9..45cea3960a 100644
--- a/ext/reflection/tests/ReflectionMethod_basic2.phpt
+++ b/ext/reflection/tests/ReflectionMethod_basic2.phpt
@@ -1,5 +1,5 @@
--TEST--
-ReflectionMethod class __toString() and export() methods
+ReflectionMethod class __toString() method
--FILE--
<?php
@@ -9,8 +9,6 @@ function reflectMethod($class, $method) {
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";
}
@@ -55,15 +53,7 @@ Reflecting on method DerivedClass::foo()
__toString():
string(%d) "Method [ <user, inherits TestClass> public method foo ] {
- @@ %s 16 - 18
-}
-"
-
-export():
-
-Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
-string(%d) "Method [ <user, inherits TestClass> public method foo ] {
- @@ %s 16 - 18
+ @@ %s 14 - 16
}
"
@@ -73,15 +63,7 @@ Reflecting on method TestClass::stat()
__toString():
string(%d) "Method [ <user> static public method stat ] {
- @@ %s 20 - 22
-}
-"
-
-export():
-
-Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
-string(%d) "Method [ <user> static public method stat ] {
- @@ %s 20 - 22
+ @@ %s 18 - 20
}
"
@@ -91,15 +73,7 @@ Reflecting on method TestClass::priv()
__toString():
string(%d) "Method [ <user> private method priv ] {
- @@ %s 24 - 26
-}
-"
-
-export():
-
-Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
-string(%d) "Method [ <user> private method priv ] {
- @@ %s 24 - 26
+ @@ %s 22 - 24
}
"
@@ -109,15 +83,7 @@ Reflecting on method TestClass::prot()
__toString():
string(%d) "Method [ <user> protected method prot ] {
- @@ %s 28 - 28
-}
-"
-
-export():
-
-Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
-string(%d) "Method [ <user> protected method prot ] {
- @@ %s 28 - 28
+ @@ %s 26 - 26
}
"
@@ -127,15 +93,7 @@ Reflecting on method DerivedClass::prot()
__toString():
string(%d) "Method [ <user, inherits TestClass> protected method prot ] {
- @@ %s 28 - 28
-}
-"
-
-export():
-
-Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
-string(%d) "Method [ <user, inherits TestClass> protected method prot ] {
- @@ %s 28 - 28
+ @@ %s 26 - 26
}
"
@@ -145,15 +103,7 @@ Reflecting on method TestInterface::int()
__toString():
string(%d) "Method [ <user> abstract public method int ] {
- @@ %s 36 - 36
-}
-"
-
-export():
-
-Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
-string(%d) "Method [ <user> abstract public method int ] {
- @@ %s 36 - 36
+ @@ %s 34 - 34
}
"
@@ -165,20 +115,8 @@ __toString():
string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
- Parameters [2] {
- Parameter #0 [ <required> $class ]
- Parameter #1 [ <required> $name ]
- }
-}
-"
-
-export():
-
-Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
-string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
-
- - Parameters [2] {
- Parameter #0 [ <required> $class ]
- Parameter #1 [ <required> $name ]
+ Parameter #0 [ <required> object|string $class ]
+ Parameter #1 [ <required> string $property ]
}
}
"
@@ -188,16 +126,8 @@ string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
Reflecting on method TestClass::__destruct()
__toString():
-string(%d) "Method [ <user, dtor> public method __destruct ] {
- @@ %s 30 - 30
-}
-"
-
-export():
-
-Deprecated: Function ReflectionMethod::export() is deprecated in %s on line %d
-string(%d) "Method [ <user, dtor> public method __destruct ] {
- @@ %s 30 - 30
+string(%d) "Method [ <user> public method __destruct ] {
+ @@ %s 28 - 28
}
"
diff --git a/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt b/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt
index 243c59504b..da108d258d 100644
--- a/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt
+++ b/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt
@@ -19,21 +19,6 @@ 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";
@@ -49,69 +34,16 @@ 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--
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; OldCtor has a deprecated constructor in %s on line %d
+--EXPECT--
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
index 5c980536b9..8c5bd7139c 100644
--- a/ext/reflection/tests/ReflectionMethod_constructor_error1.phpt
+++ b/ext/reflection/tests/ReflectionMethod_constructor_error1.phpt
@@ -14,88 +14,88 @@ class TestClass
try {
- echo "\nWrong type of argument (bool):\n";
- $methodInfo = new ReflectionMethod(true);
+ echo "\nWrong type of argument (bool):\n";
+ $methodInfo = new ReflectionMethod(true);
} catch (Exception $e) {
- print $e->__toString();
+ print $e->__toString();
}
try {
- echo "\nWrong type of argument (int):\n";
- $methodInfo = new ReflectionMethod(3);
+ echo "\nWrong type of argument (int):\n";
+ $methodInfo = new ReflectionMethod(3);
} catch (Exception $e) {
- print $e->__toString();
+ print $e->__toString();
}
try {
- echo "\nWrong type of argument (bool, string):\n";
- $methodInfo = new ReflectionMethod(true, "foo");
+ echo "\nWrong type of argument (bool, string):\n";
+ $methodInfo = new ReflectionMethod(true, "foo");
} catch (Exception $e) {
- print $e->__toString();
+ print $e->__toString();
}
try {
- echo "\nWrong type of argument (string, bool):\n";
- $methodInfo = new ReflectionMethod('TestClass', true);
+ echo "\nWrong type of argument (string, bool):\n";
+ $methodInfo = new ReflectionMethod('TestClass', true);
} catch (Exception $e) {
- print $e->__toString();
+ print $e->__toString();
}
try {
- echo "\nNo method given:\n";
- $methodInfo = new ReflectionMethod("TestClass");
+ echo "\nNo method given:\n";
+ $methodInfo = new ReflectionMethod("TestClass");
} catch (Exception $e) {
- print $e->__toString();
+ print $e->__toString();
}
try {
- echo "\nClass and Method in same string, bad method name:\n";
- $methodInfo = new ReflectionMethod("TestClass::foop::dedoop");
+ echo "\nClass and Method in same string, bad method name:\n";
+ $methodInfo = new ReflectionMethod("TestClass::foop::dedoop");
} catch (Exception $e) {
- print $e->__toString();
+ print $e->__toString();
}
try {
- echo "\nClass and Method in same string, bad class name:\n";
- $methodInfo = new ReflectionMethod("TestCla::foo");
+ echo "\nClass and Method in same string, bad class name:\n";
+ $methodInfo = new ReflectionMethod("TestCla::foo");
} catch (Exception $e) {
- print $e->__toString();
+ print $e->__toString();
}
try {
- echo "\nClass and Method in same string (ok):\n";
- $methodInfo = new ReflectionMethod("TestClass::foo");
+ echo "\nClass and Method in same string (ok):\n";
+ $methodInfo = new ReflectionMethod("TestClass::foo");
} catch (Exception $e) {
- print $e->__toString();
+ print $e->__toString();
}
?>
--EXPECTF--
Wrong type of argument (bool):
-ReflectionException: Invalid method name 1 in %s
+ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d
Stack trace:
#0 %s ReflectionMethod->__construct('1')
#1 {main}
Wrong type of argument (int):
-ReflectionException: Invalid method name 3 in %s
+ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d
Stack trace:
#0 %s ReflectionMethod->__construct('3')
#1 {main}
Wrong type of argument (bool, string):
-ReflectionException: The parameter class is expected to be either a string or an object in %s
+ReflectionException: Class "1" does not exist in %s:%d
Stack trace:
-#0 %s ReflectionMethod->__construct(true, 'foo')
+#0 %s ReflectionMethod->__construct('1', 'foo')
#1 {main}
Wrong type of argument (string, bool):
-ReflectionException: Method TestClass::1() does not exist in %s
+ReflectionException: Method TestClass::1() does not exist in %s:%d
Stack trace:
#0 %s ReflectionMethod->__construct('TestClass', '1')
#1 {main}
No method given:
-ReflectionException: Invalid method name TestClass in %s
+ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d
Stack trace:
#0 %s ReflectionMethod->__construct('TestClass')
#1 {main}
Class and Method in same string, bad method name:
-ReflectionException: Method TestClass::foop::dedoop() does not exist in %s
+ReflectionException: Method TestClass::foop::dedoop() does not exist in %s:%d
Stack trace:
#0 %s ReflectionMethod->__construct('TestClass::foop...')
#1 {main}
Class and Method in same string, bad class name:
-ReflectionException: Class TestCla does not exist in %s
+ReflectionException: Class "TestCla" does not exist in %s:%d
Stack trace:
#0 %s ReflectionMethod->__construct('TestCla::foo')
#1 {main}
diff --git a/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt b/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt
index 723ab00f84..a7115893a5 100644
--- a/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt
+++ b/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt
@@ -14,48 +14,48 @@ class TestClass
try {
- echo "Too few arguments:\n";
- $methodInfo = new ReflectionMethod();
-} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Too few arguments:\n";
+ $methodInfo = new ReflectionMethod();
+} catch (ArgumentCountError $re) {
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
- echo "\nToo many arguments:\n";
- $methodInfo = new ReflectionMethod("TestClass", "foo", true);
-} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "\nToo many arguments:\n";
+ $methodInfo = new ReflectionMethod("TestClass", "foo", true);
+} catch (ArgumentCountError $re) {
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
- //invalid class
- $methodInfo = new ReflectionMethod("InvalidClassName", "foo");
+ //invalid class
+ $methodInfo = new ReflectionMethod("InvalidClassName", "foo");
} catch (ReflectionException $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
- //invalid 1st param
- $methodInfo = new ReflectionMethod([], "foo");
-} catch (ReflectionException $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ //invalid 1st param
+ $methodInfo = new ReflectionMethod([], "foo");
+} catch (TypeError $re) {
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
try{
- //invalid 2nd param
- $methodInfo = new ReflectionMethod("TestClass", []);
+ //invalid 2nd param
+ $methodInfo = new ReflectionMethod("TestClass", []);
} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
?>
--EXPECT--
Too few arguments:
-Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 0 given
+Ok - ReflectionMethod::__construct() expects at least 1 argument, 0 given
Too many arguments:
-Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 3 given
-Ok - Class InvalidClassName does not exist
-Ok - The parameter class is expected to be either a string or an object
-Ok - ReflectionMethod::__construct() expects exactly 1 parameter, 2 given
+Ok - ReflectionMethod::__construct() expects at most 2 arguments, 3 given
+Ok - Class "InvalidClassName" does not exist
+Ok - ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be of type object|string, array given
+Ok - ReflectionMethod::__construct(): Argument #2 ($method) must be of type ?string, array given
diff --git a/ext/reflection/tests/ReflectionMethod_defaultArg.phpt b/ext/reflection/tests/ReflectionMethod_defaultArg.phpt
index 1c04cade5f..521f29da58 100644
--- a/ext/reflection/tests/ReflectionMethod_defaultArg.phpt
+++ b/ext/reflection/tests/ReflectionMethod_defaultArg.phpt
@@ -3,17 +3,17 @@ ReflectionMethod and RECV_INIT (bug #70957 and #70958)
--FILE--
<?php
Abstract class F {
- private function bar($a = self::class) {}
+ private function bar($a = self::class) {}
}
Trait T
{
- private function bar($a = self::class) {}
+ private function bar($a = self::class) {}
}
class B {
- use T;
+ use T;
}
echo new \ReflectionMethod('F', 'bar');
diff --git a/ext/reflection/tests/ReflectionMethod_getClosureThis.phpt b/ext/reflection/tests/ReflectionMethod_getClosureThis.phpt
index 3a931172f1..656fde814d 100644
--- a/ext/reflection/tests/ReflectionMethod_getClosureThis.phpt
+++ b/ext/reflection/tests/ReflectionMethod_getClosureThis.phpt
@@ -4,19 +4,19 @@ Reflection::getClosureThis()
<?php
class StaticExample
{
- static function foo()
- {
- var_dump( "Static Example class, Hello World!" );
- }
+ 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 );
- }
+ public $bar = 42;
+ public function foo()
+ {
+ var_dump( "Example class, bar: " . $this->bar );
+ }
}
// Initialize classes
diff --git a/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt b/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt
index bf1bcf3603..75810c0105 100644
--- a/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt
+++ b/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt
@@ -2,29 +2,23 @@
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!" );
- }
+ 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 );
- }
+ public $bar = 42;
+ public function foo()
+ {
+ var_dump( "Example class, bar: " . $this->bar );
+ }
}
// Initialize classes
@@ -46,10 +40,8 @@ $object->bar = 34;
$closure();
?>
-===DONE===
--EXPECT--
*** 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
index d3b9ca3c81..0dc24897a3 100644
--- a/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt
+++ b/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt
@@ -2,29 +2,23 @@
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!" );
- }
+ 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 );
- }
+ public $bar = 42;
+ public function foo()
+ {
+ var_dump( "Example class, bar: " . $this->bar );
+ }
}
// Initialize classes
@@ -35,15 +29,7 @@ $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";
+echo "\n-- Testing ReflectionMethod::getClosure() function with invalid object --\n";
try {
var_dump( $method->getClosure( $fakeobj ) );
} catch( Exception $e ) {
@@ -51,23 +37,8 @@ try {
}
?>
-===DONE===
---EXPECTF--
+--EXPECT--
*** 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 --
+-- Testing ReflectionMethod::getClosure() function with invalid object --
string(72) "Given object is not an instance of the class this method was declared in"
-===DONE===
diff --git a/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt b/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt
index f999b72812..7cda871c18 100644
--- a/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt
+++ b/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt
@@ -25,7 +25,7 @@ class A {
* My Doc Comment for A::finalStatPubf
*/
- final static public function finalStatPubf() {}
+ final static public function finalStatPubf() {}
}
diff --git a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt
index d1a19c7116..c5fe6aa41a 100644
--- a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt
+++ b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt
@@ -32,10 +32,14 @@ class TestClass
public final function fin() {}
+ public function __construct() {}
+
public function __destruct() {}
public function __call($a, $b) {}
+ public static function __callStatic($a, $b) {}
+
public function __clone() {}
public function __get($a) {}
@@ -44,6 +48,8 @@ class TestClass
public function __unset($a) {}
+ public function __invoke() {}
+
public function __isset($a) {}
public function __tostring() {}
@@ -52,20 +58,26 @@ class TestClass
public function __wakeup() {}
- public function __set_state() {}
+ public static function __set_state($a) {}
public function __autoload() {}
+
+ public function __serialize() {}
+
+ public function __unserialize($data) {}
+
+ public function __debugInfo() {}
}
class DerivedClass extends TestClass {}
interface TestInterface {
- public function int();
- public function __clone();
+ public function int();
+ public function __clone();
}
abstract class AbstractClass {
- public abstract function foo();
+ public abstract function foo();
}
@@ -75,17 +87,13 @@ 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";
+echo "ReflectionMethod::getModifiers() modifiers:\n";
printf("0x%08x\n", $a->getModifiers());
?>
---EXPECTF--
+--EXPECT--
Modifiers for method TestClass::foo():
0x00000001
@@ -106,6 +114,10 @@ Modifiers for method TestClass::fin():
0x00000021
+Modifiers for method TestClass::__construct():
+0x00000001
+
+
Modifiers for method TestClass::__destruct():
0x00000001
@@ -114,6 +126,10 @@ Modifiers for method TestClass::__call():
0x00000001
+Modifiers for method TestClass::__callStatic():
+0x00000011
+
+
Modifiers for method TestClass::__clone():
0x00000001
@@ -130,6 +146,10 @@ Modifiers for method TestClass::__unset():
0x00000001
+Modifiers for method TestClass::__invoke():
+0x00000001
+
+
Modifiers for method TestClass::__isset():
0x00000001
@@ -147,13 +167,25 @@ Modifiers for method TestClass::__wakeup():
Modifiers for method TestClass::__set_state():
-0x00000001
+0x00000011
Modifiers for method TestClass::__autoload():
0x00000001
+Modifiers for method TestClass::__serialize():
+0x00000001
+
+
+Modifiers for method TestClass::__unserialize():
+0x00000001
+
+
+Modifiers for method TestClass::__debugInfo():
+0x00000001
+
+
Modifiers for method TestClass::foo():
0x00000001
@@ -162,10 +194,6 @@ Modifiers for method TestClass::stat():
0x00000011
-Modifiers for method TestClass::priv():
-0x00000004
-
-
Modifiers for method TestClass::prot():
0x00000002
@@ -174,6 +202,10 @@ Modifiers for method TestClass::fin():
0x00000021
+Modifiers for method TestClass::__construct():
+0x00000001
+
+
Modifiers for method TestClass::__destruct():
0x00000001
@@ -182,6 +214,10 @@ Modifiers for method TestClass::__call():
0x00000001
+Modifiers for method TestClass::__callStatic():
+0x00000011
+
+
Modifiers for method TestClass::__clone():
0x00000001
@@ -198,6 +234,10 @@ Modifiers for method TestClass::__unset():
0x00000001
+Modifiers for method TestClass::__invoke():
+0x00000001
+
+
Modifiers for method TestClass::__isset():
0x00000001
@@ -215,13 +255,25 @@ Modifiers for method TestClass::__wakeup():
Modifiers for method TestClass::__set_state():
-0x00000001
+0x00000011
Modifiers for method TestClass::__autoload():
0x00000001
+Modifiers for method TestClass::__serialize():
+0x00000001
+
+
+Modifiers for method TestClass::__unserialize():
+0x00000001
+
+
+Modifiers for method TestClass::__debugInfo():
+0x00000001
+
+
Modifiers for method TestInterface::int():
0x00000041
@@ -234,9 +286,5 @@ Modifiers for method AbstractClass::foo():
0x00000041
-Wrong number of params:
-
-Warning: ReflectionMethod::getModifiers() expects exactly 0 parameters, 1 given in %s on line %d
-
ReflectionMethod::getModifiers() modifiers:
0x00000001
diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt
index 6c81728f91..869682ccdd 100644
--- a/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt
+++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt
@@ -24,4 +24,4 @@ try {
?>
--EXPECT--
-string(89) "Argument 2 passed to ReflectionMethod::invokeArgs() must be of the type array, bool given"
+string(85) "ReflectionMethod::invokeArgs(): Argument #2 ($args) must be of type array, bool given"
diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt
index 0c87a66153..c3bab48d6f 100644
--- a/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt
+++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt
@@ -15,10 +15,10 @@ class TestClass {
public static function staticMethod() {
echo "Called staticMethod()\n";
try {
- var_dump($this);
- } catch (Throwable $e) {
- echo "Exception: " . $e->getMessage() . "\n";
- }
+ var_dump($this);
+ } catch (Throwable $e) {
+ echo "Exception: " . $e->getMessage() . "\n";
+ }
}
private static function privateMethod() {
@@ -37,10 +37,6 @@ $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()));
@@ -48,14 +44,8 @@ try {
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";
@@ -79,33 +69,11 @@ try {
}
?>
---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
-
+--EXPECT--
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, bool 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, bool given in %s on line %d
-NULL
Called staticMethod()
Exception: Using $this when not in object context
NULL
diff --git a/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt b/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt
index 0a2b15fb83..92bd054338 100644
--- a/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt
+++ b/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt
@@ -23,10 +23,10 @@ class TestClass {
public static function staticMethod() {
echo "Called staticMethod()\n";
try {
- var_dump($this);
- } catch (Throwable $e) {
- echo "Exception: " . $e->getMessage() . "\n";
- }
+ var_dump($this);
+ } catch (Throwable $e) {
+ echo "Exception: " . $e->getMessage() . "\n";
+ }
}
private static function privateMethod() {
@@ -60,15 +60,23 @@ var_dump($methodWithArgs->invoke($testClassInstance, 1, "arg2", 3));
echo "\nStatic method:\n";
-var_dump($staticMethod->invoke());
-var_dump($staticMethod->invoke(true));
+try {
+ var_dump($staticMethod->invoke());
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ var_dump($staticMethod->invoke(true));
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
var_dump($staticMethod->invoke(new stdClass()));
echo "\nMethod that throws an exception:\n";
try {
- var_dump($methodThatThrows->invoke($testClassInstance));
+ var_dump($methodThatThrows->invoke($testClassInstance));
} catch (Exception $exc) {
- var_dump($exc->getMessage());
+ var_dump($exc->getMessage());
}
?>
@@ -94,12 +102,8 @@ Called methodWithArgs(1, arg2)
NULL
Static method:
-
-Warning: ReflectionMethod::invoke() expects at least 1 parameter, 0 given in %s on line %d
-NULL
-
-Warning: ReflectionMethod::invoke() expects parameter 1 to be object, bool given in %s on line %d
-NULL
+ReflectionMethod::invoke() expects at least 1 argument, 0 given
+ReflectionMethod::invoke(): Argument #1 ($object) must be of type ?object, bool given
Called staticMethod()
Exception: Using $this when not in object context
NULL
diff --git a/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt b/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt
index 411299f0c7..64a38e18a1 100644
--- a/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt
+++ b/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt
@@ -30,7 +30,7 @@ $testClassInstance->prop = "Hello";
echo "invoke() on a non-object:\n";
try {
var_dump($foo->invoke(true));
-} catch (ReflectionException $e) {
+} catch (TypeError $e) {
var_dump($e->getMessage());
}
@@ -57,11 +57,9 @@ try {
}
?>
---EXPECTF--
+--EXPECT--
invoke() on a non-object:
-
-Warning: ReflectionMethod::invoke() expects parameter 1 to be object, bool given in %s%eReflectionMethod_invoke_error1.php on line %d
-NULL
+string(85) "ReflectionMethod::invoke(): Argument #1 ($object) must be of type ?object, bool given"
invoke() on a non-instance:
string(72) "Given object is not an instance of the class this method was declared in"
diff --git a/ext/reflection/tests/ReflectionNamedType.phpt b/ext/reflection/tests/ReflectionNamedType.phpt
index afb592127c..5677d22cf2 100644
--- a/ext/reflection/tests/ReflectionNamedType.phpt
+++ b/ext/reflection/tests/ReflectionNamedType.phpt
@@ -4,11 +4,11 @@ ReflectionNamedType::getName() and ReflectionNamedType::__toString()
<?php
function testInternalTypes(?Traversable $traversable): ?string {
- return 'test';
+ return 'test';
}
function testUserDefinedTypes(?Test $traversable): ?Test {
- return new Test;
+ return new Test;
}
$function = new ReflectionFunction('testInternalTypes');
@@ -30,20 +30,12 @@ var_dump($return->getName());
var_dump((string) $return);
?>
---EXPECTF--
+--EXPECT--
string(11) "Traversable"
-
-Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d
-string(11) "Traversable"
-string(6) "string"
-
-Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d
+string(12) "?Traversable"
string(6) "string"
+string(7) "?string"
string(4) "Test"
-
-Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d
-string(4) "Test"
-string(4) "Test"
-
-Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d
+string(5) "?Test"
string(4) "Test"
+string(5) "?Test"
diff --git a/ext/reflection/tests/ReflectionObject___toString_basic1.phpt b/ext/reflection/tests/ReflectionObject___toString_basic1.phpt
index 43210ea686..9da648f3a2 100644
--- a/ext/reflection/tests/ReflectionObject___toString_basic1.phpt
+++ b/ext/reflection/tests/ReflectionObject___toString_basic1.phpt
@@ -4,7 +4,7 @@ ReflectionObject::__toString() : very basic test with no dynamic properties
<?php
class Foo {
- public $bar = 1;
+ public $bar = 1;
}
$f = new foo;
@@ -25,7 +25,7 @@ Object of class [ <user> class Foo ] {
}
- Properties [1] {
- Property [ <default> public $bar ]
+ Property [ public $bar = 1 ]
}
- Dynamic properties [0] {
diff --git a/ext/reflection/tests/ReflectionObject___toString_basic2.phpt b/ext/reflection/tests/ReflectionObject___toString_basic2.phpt
index 970d07b432..e93dd9b331 100644
--- a/ext/reflection/tests/ReflectionObject___toString_basic2.phpt
+++ b/ext/reflection/tests/ReflectionObject___toString_basic2.phpt
@@ -4,7 +4,7 @@ ReflectionObject::__toString() : very basic test with dynamic properties
<?php
class Foo {
- public $bar = 1;
+ public $bar = 1;
}
$f = new foo;
$f->dynProp = 'hello';
@@ -26,7 +26,7 @@ Object of class [ <user> class Foo ] {
}
- Properties [1] {
- Property [ <default> public $bar ]
+ Property [ public $bar = 1 ]
}
- Dynamic properties [2] {
diff --git a/ext/reflection/tests/ReflectionObject_export_basic1.phpt b/ext/reflection/tests/ReflectionObject_export_basic1.phpt
deleted file mode 100644
index 43210ea686..0000000000
--- a/ext/reflection/tests/ReflectionObject_export_basic1.phpt
+++ /dev/null
@@ -1,36 +0,0 @@
---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] {
- }
-}
diff --git a/ext/reflection/tests/ReflectionObject_export_basic2.phpt b/ext/reflection/tests/ReflectionObject_export_basic2.phpt
deleted file mode 100644
index 970d07b432..0000000000
--- a/ext/reflection/tests/ReflectionObject_export_basic2.phpt
+++ /dev/null
@@ -1,39 +0,0 @@
---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] {
- }
-}
diff --git a/ext/reflection/tests/ReflectionObject_export_basic3.phpt b/ext/reflection/tests/ReflectionObject_export_basic3.phpt
index a92c2d4921..612bfa5916 100644
--- a/ext/reflection/tests/ReflectionObject_export_basic3.phpt
+++ b/ext/reflection/tests/ReflectionObject_export_basic3.phpt
@@ -3,7 +3,7 @@ ReflectionObject::__toString() - ensure dynamic property with same name as inher
--FILE--
<?php
class C {
- private $p = 1;
+ private $p = 1;
}
class D extends C{
diff --git a/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt b/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt
index 7f9bc1f35c..c132f1121a 100644
--- a/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt
+++ b/ext/reflection/tests/ReflectionObject_getConstant_basic.phpt
@@ -3,24 +3,24 @@ ReflectionObject::getConstant() basic function test
--FILE--
<?php
class C {
- const a = 'hello from C';
+ const a = 'hello from C';
}
class D extends C {
}
class E extends D {
}
class F extends E {
- const a = 'hello from F';
+ 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'));
+ echo "Reflecting on instance of class $class: \n";
+ $rc = new ReflectionObject(new $class);
+ var_dump($rc->getConstant('a'));
+ var_dump($rc->getConstant('doesNotexist'));
}
?>
--EXPECT--
diff --git a/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt b/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt
index 0ecbde7991..f5acde8be4 100644
--- a/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt
+++ b/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt
@@ -3,23 +3,23 @@ ReflectionObject::getConstants() - basic function test
--FILE--
<?php
class C {
- const a = 'hello from C';
+ const a = 'hello from C';
}
class D extends C {
}
class E extends D {
}
class F extends E {
- const a = 'hello from F';
+ 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());
+ echo "Reflecting on instance of class $class: \n";
+ $rc = new ReflectionObject(new $class);
+ var_dump($rc->getConstants());
}
?>
diff --git a/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt b/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt
index aecc9b97d2..0401ed1e0c 100644
--- a/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt
+++ b/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt
@@ -3,81 +3,55 @@ ReflectionObject::getConstructor() - basic function test
--FILE--
<?php
class NewCtor {
- function __construct() {}
+ function __construct() {}
}
class ExtendsNewCtor extends NewCtor {
}
-class OldCtor {
- function OldCtor() {}
-}
-
-class ExtendsOldCtor extends OldCtor {
-}
-
-
class X {
- function Y() {}
+ function Y() {}
}
class Y extends X {
}
-class OldAndNewCtor {
- function OldAndNewCtor() {}
- function __construct() {}
-}
-
-class NewAndOldCtor {
- function __construct() {}
- function NewAndOldCtor() {}
-}
class B {
- function B() {}
+ function B() {}
}
class C extends B {
- function C() {}
+ function C() {}
}
class D1 extends C {
- function __construct() {}
+ function __construct() {}
}
class D2 extends C {
}
-$classes = array('NewCtor', 'ExtendsNewCtor', 'OldCtor', 'ExtendsOldCtor',
- 'OldAndNewCtor', 'NewAndOldCtor', 'B', 'C', 'D1', 'D2', 'X', 'Y');
+$classes = array('NewCtor', 'ExtendsNewCtor',
+ '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";
- }
+ $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--
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; OldCtor has a deprecated constructor in %s on line %d
-
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in %s on line %d
-
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; C has a deprecated constructor in %s on line %d
+--EXPECT--
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
+No constructor for B
+No constructor for C
Constructor of D1: __construct
-Constructor of D2: C
+No constructor for D2
No constructor for X
No constructor for Y
diff --git a/ext/reflection/tests/ReflectionObject_getName_basic.phpt b/ext/reflection/tests/ReflectionObject_getName_basic.phpt
index 68cea6a1cd..94ad1e2c7b 100644
--- a/ext/reflection/tests/ReflectionObject_getName_basic.phpt
+++ b/ext/reflection/tests/ReflectionObject_getName_basic.phpt
@@ -2,8 +2,6 @@
ReflectionObject::getName() - basic function test
--FILE--
<?php
-$r0 = new ReflectionObject();
-var_dump($r0->getName());
$r1 = new ReflectionObject(new stdClass);
var_dump($r1->getName());
@@ -17,9 +15,7 @@ $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) ""
+--EXPECT--
string(8) "stdClass"
string(1) "C"
string(16) "ReflectionObject"
diff --git a/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt b/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt
index ff310df09b..146ac5ccd9 100644
--- a/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt
+++ b/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt
@@ -9,15 +9,15 @@ class X {}
$classes = array("A", "B", "X");
$instances = array( "myA" => new A,
- "myB" => new B,
- "myX" => new X );
+ "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));
- }
+ $ro = new ReflectionObject(new $class);
+ foreach ($instances as $name => $instance) {
+ echo "is $name a $class? ";
+ var_dump($ro->isInstance($instance));
+ }
}
?>
diff --git a/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt b/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt
index 982580fc56..1b30debc9d 100644
--- a/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt
+++ b/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt
@@ -6,28 +6,28 @@ class C {
}
interface iface {
- function f1();
+ function f1();
}
class ifaceImpl implements iface {
- function f1() {}
+ function f1() {}
}
abstract class abstractClass {
- function f1() {}
- abstract function f2();
+ function f1() {}
+ abstract function f2();
}
class D extends abstractClass {
- function f2() {}
+ function f2() {}
}
$classes = array("C", "ifaceImpl", "D");
foreach($classes as $class ) {
- $ro = new ReflectionObject(new $class);
- echo "Is $class instantiable? ";
- var_dump($ro->IsInstantiable());
+ $ro = new ReflectionObject(new $class);
+ echo "Is $class instantiable? ";
+ var_dump($ro->IsInstantiable());
}
?>
--EXPECT--
diff --git a/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt b/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt
index 675bbdde8d..dada6ffc78 100644
--- a/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt
+++ b/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt
@@ -4,80 +4,47 @@ ReflectionObject::IsInstantiable() - variation - constructors
<?php
class noCtor {
- public static function reflectionObjectFactory() {
- return new ReflectionObject(new self);
- }
+ public static function reflectionObjectFactory() {
+ return new ReflectionObject(new self);
+ }
}
class publicCtorNew {
- public function __construct() {}
- public static function reflectionObjectFactory() {
- return new ReflectionObject(new self);
- }
+ 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);
- }
+ 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);
- }
+ 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()
- );
+ noCtor::reflectionObjectFactory(),
+ publicCtorNew::reflectionObjectFactory(),
+ protectedCtorNew::reflectionObjectFactory(),
+ privateCtorNew::reflectionObjectFactory(),
+ );
-foreach($reflectionObjects as $reflectionObject ) {
- $name = $reflectionObject->getName();
- echo "Is $name instantiable? ";
- var_dump($reflectionObject->IsInstantiable());
+foreach ($reflectionObjects as $reflectionObject) {
+ $name = $reflectionObject->getName();
+ echo "Is $name instantiable? ";
+ var_dump($reflectionObject->IsInstantiable());
}
?>
---EXPECTF--
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; publicCtorOld has a deprecated constructor in %s on line %d
-
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; protectedCtorOld has a deprecated constructor in %s on line %d
-
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; privateCtorOld has a deprecated constructor in %s on line %d
+--EXPECT--
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
index 234b8eb27e..8f1c6fc841 100644
--- a/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt
+++ b/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt
@@ -12,7 +12,7 @@ $r4 = new ReflectionObject(new Exception);
$r5 = new ReflectionObject(new C);
var_dump($r1->isInternal(), $r2->isInternal(), $r3->isInternal(),
- $r4->isInternal(), $r5->isInternal());
+ $r4->isInternal(), $r5->isInternal());
?>
--EXPECT--
diff --git a/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt b/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt
index f05197ebaf..ceedc7d4f0 100644
--- a/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt
+++ b/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt
@@ -10,39 +10,35 @@ $ro = new ReflectionObject(new C);
echo "\n\nTest bad arguments:\n";
try {
- var_dump($ro->isSubclassOf());
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $ro->isSubclassOf();
+} catch (ArgumentCountError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($ro->isSubclassOf('C', 'C'));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $ro->isSubclassOf('C', 'C');
+} catch (ArgumentCountError $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($ro->isSubclassOf(null));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $ro->isSubclassOf(null);
+} catch (ReflectionException $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($ro->isSubclassOf('ThisClassDoesNotExist'));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $ro->isSubclassOf('ThisClassDoesNotExist');
+} catch (ReflectionException $e) {
+ echo $e->getMessage() . "\n";
}
try {
- var_dump($ro->isSubclassOf(2));
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
+ $ro->isSubclassOf(2);
+} catch (ReflectionException $e) {
+ echo $e->getMessage() . "\n";
}
?>
---EXPECTF--
+--EXPECT--
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
+ReflectionClass::isSubclassOf() expects exactly 1 argument, 0 given
+ReflectionClass::isSubclassOf() expects exactly 1 argument, 2 given
+Class "" does not exist
+Class "ThisClassDoesNotExist" does not exist
+Class "2" does not exist
diff --git a/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt b/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt
index 25c29c7534..095c59fa34 100644
--- a/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt
+++ b/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt
@@ -13,28 +13,28 @@ $classNames = array('A', 'B', 'C', 'I', 'X');
//Create ReflectionClasses
foreach ($classNames as $className) {
- $rcs[$className] = new ReflectionClass($className);
+ $rcs[$className] = new ReflectionClass($className);
}
//Create ReflectionObjects
foreach ($classNames as $className) {
- if ($rcs[$className]->isInstantiable()) {
- $ros[$className] = new ReflectionObject(new $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));
- }
+ 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));
+ }
}
?>
--EXPECT--
diff --git a/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt b/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt
index 11994ed705..71079650fe 100644
--- a/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt
+++ b/ext/reflection/tests/ReflectionObject_isSubclassOf_error.phpt
@@ -5,20 +5,12 @@ ReflectionObject::isSubclassOf() - invalid params
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 ReflectionException: Class X does not exist in %s:7
+Fatal error: Uncaught ReflectionException: Class "X" does not exist in %s:%d
Stack trace:
-#0 %s(7): ReflectionClass->isSubclassOf('X')
+#0 %s(%d): ReflectionClass->isSubclassOf('X')
#1 {main}
- thrown in %s on line 7
+ thrown in %s on line %d
diff --git a/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt b/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt
index 1a9dea3aba..f561b909e4 100644
--- a/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt
+++ b/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt
@@ -12,7 +12,7 @@ $r4 = new ReflectionObject(new Exception);
$r5 = new ReflectionObject(new C);
var_dump($r1->isUserDefined(), $r2->isUserDefined(), $r3->isUserDefined(),
- $r4->isUserDefined(), $r5->isUserDefined());
+ $r4->isUserDefined(), $r5->isUserDefined());
?>
--EXPECT--
diff --git a/ext/reflection/tests/ReflectionParameter_001.phpt b/ext/reflection/tests/ReflectionParameter_001.phpt
index 822da2fe9a..b2b5218724 100644
--- a/ext/reflection/tests/ReflectionParameter_001.phpt
+++ b/ext/reflection/tests/ReflectionParameter_001.phpt
@@ -11,11 +11,11 @@ class ReflectTestClass {
}
public function oneArgNonStatic($theParam) {
- $theParam--;
+ $theParam--;
}
public function noArgs() {
- echo "No arg function\n";
+ echo "No arg function\n";
}
}
@@ -25,18 +25,18 @@ $method = new ReflectionMethod('ReflectTestClass', 'twoArgFunction');
$parameters = $method->getParameters();
echo "Parameters from twoArgMethod:\n\n";
foreach($parameters as $parameter) {
- var_dump($parameter);
- $name = $parameter->getName();
- echo "\n";
+ 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";
+ var_dump($parameter);
+ $name = $parameter->getName();
+ echo "\n";
}
@@ -45,9 +45,9 @@ $parameters = $method->getParameters();
echo "Parameters from noArgs:\n\n";
var_dump($parameters);
foreach($parameters as $parameter) {
- var_dump($parameter);
- $name = $parameter->getName();
- echo "\n";
+ var_dump($parameter);
+ $name = $parameter->getName();
+ echo "\n";
}
echo "done\n";
diff --git a/ext/reflection/tests/ReflectionParameter_002.phpt b/ext/reflection/tests/ReflectionParameter_002.phpt
index 571edac7a9..7ff12c2d33 100644
--- a/ext/reflection/tests/ReflectionParameter_002.phpt
+++ b/ext/reflection/tests/ReflectionParameter_002.phpt
@@ -21,11 +21,11 @@ $method = new ReflectionMethod('ReflectTestClass', 'staticMethod');
$parameters = $method->getParameters();
echo "Parameters from staticMethod:\n\n";
foreach($parameters as $parameter) {
- var_dump($parameter);
+ var_dump($parameter);
if($parameter->isPassedByReference()) {
- echo "This param is passed by reference\n";
+ echo "This param is passed by reference\n";
} else {
- echo "This param is not passed by reference\n";
+ echo "This param is not passed by reference\n";
}
echo "\n";
}
@@ -36,11 +36,11 @@ $method = new ReflectionMethod('ReflectTestClass', 'instanceMethod');
$parameters = $method->getParameters();
echo "Parameters from instanceMethod:\n\n";
foreach($parameters as $parameter) {
- var_dump($parameter);
+ var_dump($parameter);
if($parameter->isPassedByReference()) {
- echo "This param is passed by reference\n";
+ echo "This param is passed by reference\n";
} else {
- echo "This param is not passed by reference\n";
+ echo "This param is not passed by reference\n";
}
echo "\n";
}
diff --git a/ext/reflection/tests/ReflectionParameter_003.phpt b/ext/reflection/tests/ReflectionParameter_003.phpt
index cc092bffcc..16a422caa4 100644
--- a/ext/reflection/tests/ReflectionParameter_003.phpt
+++ b/ext/reflection/tests/ReflectionParameter_003.phpt
@@ -24,31 +24,31 @@ $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";
- }
+ 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";
- }
+ 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";
- }
- */
+ /*
+ $val = 0;
+ try {
+ $val = $parameter->getDefaultValue();
+ var_dump($val);
+ } catch (ReflectionException $e) {
+ print $e->getMessage();
+ echo "\n";
+ }
+ */
- echo "\n";
+ echo "\n";
}
?>
@@ -56,7 +56,7 @@ foreach($refParameters as $parameter) {
hello from test
third is jack
-Notice: Undefined variable: theIncrement in %s on line 8
+Warning: Undefined variable $theIncrement in %s on line %d
parameter names from staticMethod method:
object(ReflectionParameter)#%d (1) {
diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt
index 20f4c95dc7..98fcf5afac 100644
--- a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt
+++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt
@@ -6,42 +6,41 @@ ReflectionParameter::isDefaultValueConstant() && getDefaultValueConstantName()
define("CONST_TEST_1", "const1");
function ReflectionParameterTest($test1=array(), $test2 = CONST_TEST_1, $test3 = CASE_LOWER) {
- echo $test;
+ 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());
- }
+ 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';
+ const bar = 'Foo2::bar';
}
class Foo {
- const bar = 'Foo::bar';
+ const bar = 'Foo::bar';
- public function baz($param1 = self::bar, $param2=Foo2::bar, $param3=CONST_TEST_1) {
- }
+ 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());
+ if (@$param->isDefaultValueConstant()) {
+ var_dump(@$param->getDefaultValueConstantName());
}
}
?>
-==DONE==
--EXPECT--
bool(false)
bool(true)
@@ -50,4 +49,3 @@ string(10) "CASE_LOWER"
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
index 1ee9e93735..e3d3b9dd96 100644
--- a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt
+++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt
@@ -4,27 +4,25 @@ ReflectionParameter::isDefaultValueConstant() && getDefaultValueConstantName() f
<?php
namespace ReflectionTestNamespace {
- CONST TEST_CONST_1 = "Test Const 1";
+ CONST TEST_CONST_1 = "Test Const 1";
- class TestClass {
- const TEST_CONST_2 = "Test Const 2 in class";
- }
+ 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==";
+ 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";
+ }
+ }
}
?>
--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
index a2c2d24582..9555152404 100644
--- a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt
+++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt
@@ -6,16 +6,15 @@ ReflectionParameter::getDefaultValueConstant() should raise exception on non opt
define("CONST_TEST_1", "const1");
function ReflectionParameterTest($test, $test2 = CONST_TEST_1) {
- echo $test;
+ echo $test;
}
$reflect = new ReflectionFunction('ReflectionParameterTest');
foreach($reflect->getParameters() as $param) {
- try {
- echo $param->getDefaultValueConstantName() . "\n";
- }
- catch(ReflectionException $e) {
- echo $e->getMessage() . "\n";
- }
+ try {
+ echo $param->getDefaultValueConstantName() . "\n";
+ } catch(ReflectionException $e) {
+ echo $e->getMessage() . "\n";
+ }
}
?>
--EXPECT--
diff --git a/ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt b/ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt
index da08cc6288..849ade4063 100644
--- a/ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt
+++ b/ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt
@@ -27,7 +27,7 @@ aux('sort');
echo "=> user function:\n\n";
-function ufunc(&$arg1, $arg2) {}
+function ufunc(&$array1, $array2) {}
aux('ufunc');
@@ -37,39 +37,31 @@ echo "Done.\n";
--EXPECT--
=> array_multisort:
-Name: arr1
+Name: array
Is passed by reference: yes
Can be passed by value: yes
-Name: sort_order
-Is passed by reference: yes
-Can be passed by value: yes
-
-Name: sort_flags
-Is passed by reference: yes
-Can be passed by value: yes
-
-Name: arr2
+Name: rest
Is passed by reference: yes
Can be passed by value: yes
=> sort:
-Name: arg
+Name: array
Is passed by reference: yes
Can be passed by value: no
-Name: sort_flags
+Name: flags
Is passed by reference: no
Can be passed by value: yes
=> user function:
-Name: arg1
+Name: array1
Is passed by reference: yes
Can be passed by value: no
-Name: arg2
+Name: array2
Is passed by reference: no
Can be passed by value: yes
diff --git a/ext/reflection/tests/ReflectionParameter_export_basic.phpt b/ext/reflection/tests/ReflectionParameter_export_basic.phpt
index 6f3d16a5ff..68a43610ef 100644
--- a/ext/reflection/tests/ReflectionParameter_export_basic.phpt
+++ b/ext/reflection/tests/ReflectionParameter_export_basic.phpt
@@ -5,15 +5,13 @@ Stefan Koopmanschap <stefan@stefankoopmanschap.nl>
--FILE--
<?php
function ReflectionParameterTest($test, $test2 = null) {
- echo $test;
+ echo $test;
}
$reflect = new ReflectionFunction('ReflectionParameterTest');
foreach($reflect->getParameters() as $key => $value) {
- echo new ReflectionParameter('ReflectionParameterTest', $key), "\n";
+ echo new ReflectionParameter('ReflectionParameterTest', $key), "\n";
}
?>
-==DONE==
---EXPECTF--
+--EXPECT--
Parameter #0 [ <required> $test ]
Parameter #1 [ <optional> $test2 = NULL ]
-==DONE==
diff --git a/ext/reflection/tests/ReflectionParameter_export_error2.phpt b/ext/reflection/tests/ReflectionParameter_export_error2.phpt
deleted file mode 100644
index 38cd99171b..0000000000
--- a/ext/reflection/tests/ReflectionParameter_export_error2.phpt
+++ /dev/null
@@ -1,34 +0,0 @@
---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--
-Deprecated: Function ReflectionParameter::export() is deprecated in %s on line %d
-Method ReflectionFunction::__invoke() does not exist
-
-Deprecated: Function ReflectionParameter::export() is deprecated in %s on line %d
-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
deleted file mode 100644
index b098a9251d..0000000000
--- a/ext/reflection/tests/ReflectionParameter_export_error3.phpt
+++ /dev/null
@@ -1,23 +0,0 @@
---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--
-Deprecated: Function ReflectionParameter::export() is deprecated in %s on line %d
-
-Fatal error: Uncaught ReflectionException: The parameter specified by its name could not be found in %s:%d
-Stack trace:
-#0 [internal function]: ReflectionParameter->__construct('ReflectionParam...', 'incorrect_param...')
-#1 %s(%d): ReflectionParameter::export('ReflectionParam...', 'incorrect_param...')
-#2 {main}
- thrown in %s on line %d
diff --git a/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt b/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt
index 59e15a7054..dee0196880 100644
--- a/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt
+++ b/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt
@@ -6,15 +6,14 @@ Stefan Koopmanschap <stefan@stefankoopmanschap.nl>
--FILE--
<?php
function ReflectionParameterTest($test, $test2 = null) {
- echo $test;
+ echo $test;
}
$reflect = new ReflectionFunction('ReflectionParameterTest');
$params = $reflect->getParameters();
foreach($params as $key => $value) {
- echo $value->getDeclaringFunction() . "\n";
+ echo $value->getDeclaringFunction() . "\n";
}
?>
-==DONE==
--EXPECTF--
Function [ <user> function ReflectionParameterTest ] {
@@ %s.php %d - %d
@@ -33,5 +32,3 @@ Function [ <user> function ReflectionParameterTest ] {
Parameter #1 [ <optional> $test2 = NULL ]
}
}
-
-==DONE==
diff --git a/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt b/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt
index 2807bdf66d..485ca37a2b 100644
--- a/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt
+++ b/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt
@@ -6,16 +6,14 @@ Stefan Koopmanschap <stefan@stefankoopmanschap.nl>
--FILE--
<?php
function ReflectionParameterTest($test, $test2 = null) {
- echo $test;
+ echo $test;
}
$reflect = new ReflectionFunction('ReflectionParameterTest');
$params = $reflect->getParameters();
foreach($params as $key => $value) {
- var_dump($value->getPosition());
+ 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
index eb6d4644a0..aa88c45449 100644
--- a/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt
+++ b/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt
@@ -5,17 +5,17 @@ ReflectionParameter::__construct(): Invalid method as constructor
// Invalid class name
try {
- new ReflectionParameter (array ('A', 'b'), 0);
+ new ReflectionParameter (array ('A', 'b'), 0);
} catch (ReflectionException $e) { echo $e->getMessage()."\n"; }
// Invalid class method
try {
- new ReflectionParameter (array ('C', 'b'), 0);
+ new ReflectionParameter (array ('C', 'b'), 0);
} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; }
// Invalid object method
try {
- new ReflectionParameter (array (new C, 'b'), 0);
+ new ReflectionParameter (array (new C, 'b'), 0);
} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; }
@@ -23,26 +23,26 @@ class C {
}
try {
- new ReflectionParameter(array ('A', 'b'));
+ new ReflectionParameter(array ('A', 'b'));
}
catch(TypeError $e) {
- printf( "Ok - %s\n", $e->getMessage());
+ printf( "Ok - %s\n", $e->getMessage());
}
try {
- new ReflectionParameter(0, 0);
+ new ReflectionParameter(0, 0);
}
catch(ReflectionException $e) {
- printf( "Ok - %s\n", $e->getMessage());
+ printf( "Ok - %s\n", $e->getMessage());
}
echo "Done.\n";
?>
--EXPECT--
-Class A does not exist
+Class "A" does not exist
Method C::b() does not exist
Method C::b() does not exist
-Ok - ReflectionParameter::__construct() expects exactly 2 parameters, 1 given
-Ok - The parameter class is expected to be either a string, an array(class, method) or a callable object
+Ok - ReflectionParameter::__construct() expects exactly 2 arguments, 1 given
+Ok - ReflectionParameter::__construct(): Argument #1 ($function) must be a string, an array(class, method), or a callable object, int given
Done.
diff --git a/ext/reflection/tests/ReflectionParameter_isDefault.phpt b/ext/reflection/tests/ReflectionParameter_isDefault.phpt
index d8b4f0edc0..ea95878170 100644
--- a/ext/reflection/tests/ReflectionParameter_isDefault.phpt
+++ b/ext/reflection/tests/ReflectionParameter_isDefault.phpt
@@ -23,7 +23,6 @@ $prop2 = new ReflectionProperty($a, 'myprop');
var_dump($prop1->isDefault());
var_dump($prop2->isDefault());
?>
-==DONE==
--EXPECT--
bool(true)
bool(false)
@@ -31,4 +30,3 @@ 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
index d1a23c758d..053c3918db 100644
--- a/ext/reflection/tests/ReflectionParameter_toString_basic.phpt
+++ b/ext/reflection/tests/ReflectionParameter_toString_basic.phpt
@@ -5,17 +5,15 @@ Stefan Koopmanschap <stefan@stefankoopmanschap.nl>
--FILE--
<?php
function ReflectionParameterTest($test, $test2 = null, ...$test3) {
- echo $test;
+ echo $test;
}
$reflect = new ReflectionFunction('ReflectionParameterTest');
$params = $reflect->getParameters();
foreach($params as $key => $value) {
- echo $value->__toString() . "\n";
+ echo $value->__toString() . "\n";
}
?>
-==DONE==
--EXPECT--
Parameter #0 [ <required> $test ]
Parameter #1 [ <optional> $test2 = NULL ]
Parameter #2 [ <optional> ...$test3 ]
-==DONE==
diff --git a/ext/reflection/tests/ReflectionProperty_basic1.phpt b/ext/reflection/tests/ReflectionProperty_basic1.phpt
index 1748ebfca9..cef672ecde 100644
--- a/ext/reflection/tests/ReflectionProperty_basic1.phpt
+++ b/ext/reflection/tests/ReflectionProperty_basic1.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test usage of ReflectionProperty methods __toString(), export(), getName(), isPublic(), isPrivate(), isProtected(), isStatic(), getValue() and setValue().
+Test usage of ReflectionProperty methods __toString(), getName(), isPublic(), isPrivate(), isProtected(), isStatic(), getValue() and setValue().
--FILE--
<?php
@@ -9,10 +9,6 @@ function reflectProperty($class, $property) {
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";
@@ -47,24 +43,13 @@ reflectProperty("TestClass", "prot");
reflectProperty("TestClass", "priv");
?>
---EXPECTF--
+--EXPECT--
**********************************
Reflecting on property TestClass::pub
__toString():
-string(35) "Property [ <default> public $pub ]
+string(32) "Property [ public $pub = NULL ]
"
-export():
-
-Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d
-string(35) "Property [ <default> public $pub ]
-"
-export():
-
-Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d
-Property [ <default> public $pub ]
-
-NULL
getName():
string(3) "pub"
isPublic():
@@ -85,19 +70,8 @@ string(8) "NewValue"
Reflecting on property TestClass::stat
__toString():
-string(33) "Property [ public static $stat ]
+string(53) "Property [ public static $stat = 'static property' ]
"
-export():
-
-Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d
-string(33) "Property [ public static $stat ]
-"
-export():
-
-Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d
-Property [ public static $stat ]
-
-NULL
getName():
string(4) "stat"
isPublic():
@@ -118,19 +92,8 @@ string(8) "NewValue"
Reflecting on property TestClass::prot
__toString():
-string(39) "Property [ <default> protected $prot ]
+string(33) "Property [ protected $prot = 4 ]
"
-export():
-
-Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d
-string(39) "Property [ <default> protected $prot ]
-"
-export():
-
-Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d
-Property [ <default> protected $prot ]
-
-NULL
getName():
string(4) "prot"
isPublic():
@@ -147,19 +110,8 @@ bool(false)
Reflecting on property TestClass::priv
__toString():
-string(37) "Property [ <default> private $priv ]
+string(39) "Property [ private $priv = 'keepOut' ]
"
-export():
-
-Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d
-string(37) "Property [ <default> private $priv ]
-"
-export():
-
-Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d
-Property [ <default> private $priv ]
-
-NULL
getName():
string(4) "priv"
isPublic():
diff --git a/ext/reflection/tests/ReflectionProperty_constructor_error.phpt b/ext/reflection/tests/ReflectionProperty_constructor_error.phpt
index 38a34681db..e7a850dd97 100644
--- a/ext/reflection/tests/ReflectionProperty_constructor_error.phpt
+++ b/ext/reflection/tests/ReflectionProperty_constructor_error.phpt
@@ -10,15 +10,14 @@ $a = 5;
echo "Non-existent class:\n";
try {
- $propInfo = new ReflectionProperty("NonExistentClass", "prop");
-}
-catch(Exception $e) {
+ new ReflectionProperty("NonExistentClass", "prop");
+} catch (ReflectionException $e) {
echo $e->getMessage();
}
echo "\n\nWrong property parameter type:\n";
try {
- $propInfo = new ReflectionProperty($a, 'TestClass');
+ new ReflectionProperty($a, 'TestClass');
}
catch(ReflectionException $e) {
echo $e->getMessage();
@@ -26,19 +25,19 @@ catch(ReflectionException $e) {
echo "\n\nNon-existent property:\n";
try {
- $propInfo = new ReflectionProperty('TestClass', "nonExistentProperty");
+ new ReflectionProperty('TestClass', "nonExistentProperty");
}
-catch(Exception $e) {
+catch(ReflectionException $e) {
echo $e->getMessage();
}
?>
--EXPECT--
Non-existent class:
-Class NonExistentClass does not exist
+Class "NonExistentClass" does not exist
Wrong property parameter type:
-The parameter class is expected to be either a string or an object
+Class "5" does not exist
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
index 6f39f9db6c..4456960dc7 100644
--- a/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt
+++ b/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt
@@ -4,27 +4,27 @@ ReflectionProperty::__construct(): ensure inherited private props can't be acces
<?php
class C {
- private $p = 1;
-
- static function testFromC() {
- try {
- $rp = new ReflectionProperty("D", "p");
- var_dump($rp);
- } catch (Exception $e) {
- echo $e->getMessage();
- }
- }
+ 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();
- }
- }
+ 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";
@@ -32,7 +32,7 @@ try {
$rp = new ReflectionProperty("D", "p");
var_dump($rp);
} catch (Exception $e) {
- echo $e->getMessage();
+ echo $e->getMessage();
}
echo "\n\n--> Reflect inherited private from declaring scope:\n";
diff --git a/ext/reflection/tests/ReflectionProperty_error.phpt b/ext/reflection/tests/ReflectionProperty_error.phpt
index c8a2f11ee1..bb53599ce6 100644
--- a/ext/reflection/tests/ReflectionProperty_error.phpt
+++ b/ext/reflection/tests/ReflectionProperty_error.phpt
@@ -8,55 +8,24 @@ class C {
}
try {
- new ReflectionProperty();
+ new ReflectionProperty();
} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
- new ReflectionProperty('C::p');
+ new ReflectionProperty('C::p');
} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
try {
- new ReflectionProperty('C', 'p', 'x');
+ new ReflectionProperty('C', 'p', 'x');
} catch (TypeError $re) {
- echo "Ok - ".$re->getMessage().PHP_EOL;
+ echo "Ok - ".$re->getMessage().PHP_EOL;
}
-
-$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--
-Ok - ReflectionProperty::__construct() expects exactly 2 parameters, 0 given
-Ok - ReflectionProperty::__construct() expects exactly 2 parameters, 1 given
-Ok - ReflectionProperty::__construct() expects exactly 2 parameters, 3 given
-
-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
+--EXPECT--
+Ok - ReflectionProperty::__construct() expects exactly 2 arguments, 0 given
+Ok - ReflectionProperty::__construct() expects exactly 2 arguments, 1 given
+Ok - ReflectionProperty::__construct() expects exactly 2 arguments, 3 given
diff --git a/ext/reflection/tests/ReflectionProperty_export_basic.phpt b/ext/reflection/tests/ReflectionProperty_export_basic.phpt
deleted file mode 100644
index 28f1f6b988..0000000000
--- a/ext/reflection/tests/ReflectionProperty_export_basic.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-Test ReflectionProperty::__toString() usage.
---FILE--
-<?php
-
-class TestClass {
- public $proper = 5;
-}
-
-echo new ReflectionProperty('TestClass', 'proper');
-
-?>
---EXPECT--
-Property [ <default> public $proper ]
diff --git a/ext/reflection/tests/ReflectionProperty_export_error.phpt b/ext/reflection/tests/ReflectionProperty_export_error.phpt
deleted file mode 100644
index 114b4c0ac8..0000000000
--- a/ext/reflection/tests/ReflectionProperty_export_error.phpt
+++ /dev/null
@@ -1,64 +0,0 @@
---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:
-
-Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d
-Class NonExistentClass does not exist
-
-Wrong property parameter type:
-
-Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d
-The parameter class is expected to be either a string or an object
-
-Non-existent property:
-
-Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d
-Property TestClass::$nonExistentProperty does not exist
-
-Incorrect number of args:
-
-Deprecated: Function ReflectionProperty::export() is deprecated in %s on line %d
-
-Warning: ReflectionProperty::export() expects at least 2 parameters, 0 given in %s on line %d
-
-Deprecated: Function ReflectionProperty::export() is deprecated 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
index c7c9366471..7ee787a348 100644
--- a/ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt
+++ b/ext/reflection/tests/ReflectionProperty_getDeclaringClass_variation1.phpt
@@ -13,15 +13,9 @@ 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_getDefaultValue.phpt b/ext/reflection/tests/ReflectionProperty_getDefaultValue.phpt
new file mode 100644
index 0000000000..26614f5c60
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_getDefaultValue.phpt
@@ -0,0 +1,73 @@
+--TEST--
+reflection: ReflectionProperty::getDefaultValue
+--FILE--
+<?php
+
+define('FOO', 42);
+
+class TestClass
+{
+ public $foo;
+ public $bar = 'baz';
+
+ public static $static1;
+ public static $static2 = 1234;
+
+ public int $val1;
+ public int $val2 = 1234;
+
+ public ?int $nullable;
+ public ?int $nullable2 = null;
+
+ public $constantAst = 2 * 2;
+ public $constantRuntimeAst = FOO;
+}
+
+$property = new ReflectionProperty(TestClass::class, 'foo');
+var_dump($property->getDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'bar');
+var_dump($property->getDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'static1');
+var_dump($property->getDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'static2');
+var_dump($property->getDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'val1');
+var_dump($property->getDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'val2');
+var_dump($property->getDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'nullable');
+var_dump($property->getDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'nullable2');
+var_dump($property->getDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'constantAst');
+var_dump($property->getDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'constantRuntimeAst');
+var_dump($property->getDefaultValue());
+
+$test = new TestClass;
+$test->dynamic = null;
+$property = new ReflectionProperty($test, 'dynamic');
+var_dump($property->getDefaultValue());
+
+?>
+--EXPECT--
+NULL
+string(3) "baz"
+NULL
+int(1234)
+NULL
+int(1234)
+NULL
+NULL
+int(4)
+int(42)
+NULL
diff --git a/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt b/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt
index a297a10436..da6cf71b9c 100644
--- a/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt
+++ b/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt
@@ -7,15 +7,15 @@ Steve Seear <stevseea@php.net>
<?php
function reflectProperty($class, $property) {
- $propInfo = new ReflectionProperty($class, $property);
+ $propInfo = new ReflectionProperty($class, $property);
- echo "**********************************\n";
- echo "Reflecting on property $class::$property\n\n";
+ echo "**********************************\n";
+ echo "Reflecting on property $class::$property\n\n";
- echo "getModifiers():\n";
- var_dump($propInfo->getModifiers());
+ echo "getModifiers():\n";
+ var_dump($propInfo->getModifiers());
- echo "\n**********************************\n";
+ echo "\n**********************************\n";
}
class TestClass
@@ -23,8 +23,8 @@ class TestClass
public $pub;
static public $stat = "static property";
/**
- * This property has a comment.
- */
+ * This property has a comment.
+ */
protected $prot = 4;
private $priv = "keepOut";
}
diff --git a/ext/reflection/tests/ReflectionProperty_getValue_error.phpt b/ext/reflection/tests/ReflectionProperty_getValue_error.phpt
index 3bca85e4b6..544c1d6b25 100644
--- a/ext/reflection/tests/ReflectionProperty_getValue_error.phpt
+++ b/ext/reflection/tests/ReflectionProperty_getValue_error.phpt
@@ -18,23 +18,15 @@ $instance = new TestClass();
$invalidInstance = 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));
+try {
+ var_dump($propInfo->getValue($instance, true));
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
echo "\nProtected property:\n";
try {
@@ -47,40 +39,31 @@ catch(Exception $exc) {
echo "\n\nInvalid instance:\n";
$propInfo = new ReflectionProperty('TestClass', 'pub2');
-var_dump($propInfo->getValue($invalidInstance));
-
-?>
---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:
+try {
+ var_dump($propInfo->getValue($invalidInstance));
+} catch (ReflectionException $e) {
+ echo $e->getMessage();
+}
-Warning: ReflectionProperty::getValue() expects parameter 1 to be object, bool given in %s on line %d
-NULL
+echo "\n\nMissing instance:\n";
+try {
+ var_dump($propInfo->getValue());
+} catch (TypeError $e) {
+ echo $e->getMessage();
+}
+?>
+--EXPECT--
Instance without property:
Static property / too many args:
-string(15) "static property"
-
-Static property / wrong type of arg:
-string(15) "static property"
+ReflectionProperty::getValue() expects at most 1 argument, 2 given
Protected property:
-Cannot access non-public member TestClass::$prot
+Cannot access non-public property TestClass::$prot
Invalid instance:
+Given object is not an instance of the class this property was declared in
-Fatal error: Uncaught ReflectionException: Given object is not an instance of the class this property was declared in in %s:47
-Stack trace:
-#0 %s(47): ReflectionProperty->getValue(Object(AnotherClass))
-#1 {main}
- thrown in %s on line 47
+Missing instance:
+ReflectionProperty::getValue(): Argument #1 ($object) must be provided for instance properties
diff --git a/ext/reflection/tests/ReflectionProperty_hasDefaultValue.phpt b/ext/reflection/tests/ReflectionProperty_hasDefaultValue.phpt
new file mode 100644
index 0000000000..5709000370
--- /dev/null
+++ b/ext/reflection/tests/ReflectionProperty_hasDefaultValue.phpt
@@ -0,0 +1,60 @@
+--TEST--
+reflection: ReflectionProperty::hasDefaultValue
+--FILE--
+<?php
+
+class TestClass
+{
+ public $foo;
+ public $bar = 'baz';
+
+ public static $static1;
+ public static $static2 = 1234;
+
+ public int $val1;
+ public int $val2 = 1234;
+
+ public ?int $nullable;
+ public ?int $nullable2 = null;
+}
+
+$property = new ReflectionProperty(TestClass::class, 'foo');
+var_dump($property->hasDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'bar');
+var_dump($property->hasDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'static1');
+var_dump($property->hasDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'static2');
+var_dump($property->hasDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'val1');
+var_dump($property->hasDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'val2');
+var_dump($property->hasDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'nullable');
+var_dump($property->hasDefaultValue());
+
+$property = new ReflectionProperty(TestClass::class, 'nullable2');
+var_dump($property->hasDefaultValue());
+
+$test = new TestClass;
+$test->dynamic = null;
+$property = new ReflectionProperty($test, 'dynamic');
+var_dump($property->hasDefaultValue());
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
diff --git a/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt b/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt
index 2aa630d9d0..7defcb76e0 100644
--- a/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt
+++ b/ext/reflection/tests/ReflectionProperty_isDefault_basic.phpt
@@ -24,12 +24,8 @@ reflectProperty("TestClass", "stat");
reflectProperty("TestClass", "prot");
reflectProperty("TestClass", "priv");
-echo "Wrong number of params:\n";
-$propInfo = new ReflectionProperty('TestClass', 'pub');
-$propInfo->isDefault(1);
-
?>
---EXPECTF--
+--EXPECT--
**********************************
Reflecting on property TestClass::pub
@@ -58,6 +54,3 @@ 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_isInitialized.phpt b/ext/reflection/tests/ReflectionProperty_isInitialized.phpt
index f1f6e53ebd..74e25252d1 100644
--- a/ext/reflection/tests/ReflectionProperty_isInitialized.phpt
+++ b/ext/reflection/tests/ReflectionProperty_isInitialized.phpt
@@ -4,12 +4,12 @@ Test ReflectionProperty::isInitialized()
<?php
class A {
- public static ?string $ssv = null;
- public static ?string $ss;
- public static $s;
- public ?int $iv = null;
- public ?int $i;
- public $n;
+ public static ?string $ssv = null;
+ public static ?string $ss;
+ public static $s;
+ public ?int $iv = null;
+ public ?int $i;
+ public $n;
private int $p;
}
@@ -62,6 +62,12 @@ try {
echo $e->getMessage(), "\n";
}
+try {
+ var_dump($rp->isInitialized());
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
+
class WithMagic {
public $prop;
public int $intProp;
@@ -103,11 +109,12 @@ Dynamic properties:
bool(true)
bool(false)
Visibility handling:
-Cannot access non-public member A::$p
+Cannot access non-public property A::$p
bool(false)
Object type:
bool(false)
Given object is not an instance of the class this property was declared in
+ReflectionProperty::isInitialized(): Argument #1 ($object) must be provided for instance properties
Class with __isset:
bool(false)
bool(false)
diff --git a/ext/reflection/tests/ReflectionProperty_setAccessible.phpt b/ext/reflection/tests/ReflectionProperty_setAccessible.phpt
index fd82a47198..f0d49a56cb 100644
--- a/ext/reflection/tests/ReflectionProperty_setAccessible.phpt
+++ b/ext/reflection/tests/ReflectionProperty_setAccessible.phpt
@@ -116,10 +116,10 @@ var_dump($protectedStatic->getValue());
var_dump($private->getValue($b));
?>
--EXPECT--
-string(45) "Cannot access non-public member A::$protected"
-string(51) "Cannot access non-public member A::$protectedStatic"
-string(43) "Cannot access non-public member A::$private"
-string(49) "Cannot access non-public member A::$privateStatic"
+string(47) "Cannot access non-public property A::$protected"
+string(53) "Cannot access non-public property A::$protectedStatic"
+string(45) "Cannot access non-public property A::$private"
+string(51) "Cannot access non-public property A::$privateStatic"
string(1) "a"
string(1) "b"
string(1) "c"
@@ -128,9 +128,9 @@ string(1) "e"
string(1) "f"
string(1) "g"
string(1) "h"
-string(45) "Cannot access non-public member B::$protected"
-string(51) "Cannot access non-public member B::$protectedStatic"
-string(43) "Cannot access non-public member A::$private"
+string(47) "Cannot access non-public property B::$protected"
+string(53) "Cannot access non-public property B::$protectedStatic"
+string(45) "Cannot access non-public property A::$private"
string(1) "a"
string(1) "f"
string(1) "c"
diff --git a/ext/reflection/tests/ReflectionProperty_setValue_error.phpt b/ext/reflection/tests/ReflectionProperty_setValue_error.phpt
index 0bf223daa7..4b29be8f73 100644
--- a/ext/reflection/tests/ReflectionProperty_setValue_error.phpt
+++ b/ext/reflection/tests/ReflectionProperty_setValue_error.phpt
@@ -18,30 +18,6 @@ $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');
@@ -56,44 +32,9 @@ $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, bool 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"
-
+--EXPECT--
Protected property:
-Cannot access non-public member TestClass::$prot
+Cannot access non-public property TestClass::$prot
Instance without property:
NULL
diff --git a/ext/reflection/tests/ReflectionProperty_typed_static.phpt b/ext/reflection/tests/ReflectionProperty_typed_static.phpt
index 77f95d77ef..eaf4209644 100644
--- a/ext/reflection/tests/ReflectionProperty_typed_static.phpt
+++ b/ext/reflection/tests/ReflectionProperty_typed_static.phpt
@@ -45,7 +45,7 @@ var_dump($rp->getValue());
int(42)
Typed static property Test::$y must not be accessed before initialization
int(24)
-Typed property Test::$y must be int, string used
+Cannot assign string to property Test::$y of type int
int(24)
Cannot assign string to reference held by property Test::$y of type int
int(24)
diff --git a/ext/reflection/tests/ReflectionReference_errors.phpt b/ext/reflection/tests/ReflectionReference_errors.phpt
index 8e52a1d223..c9d75d0467 100644
--- a/ext/reflection/tests/ReflectionReference_errors.phpt
+++ b/ext/reflection/tests/ReflectionReference_errors.phpt
@@ -16,7 +16,7 @@ try {
}
try {
- ReflectionReference::fromArrayElement([], 1.5);
+ ReflectionReference::fromArrayElement([], []);
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
@@ -40,9 +40,9 @@ var_dump(unserialize('O:19:"ReflectionReference":0:{}'));
?>
--EXPECTF--
-Call to private ReflectionReference::__construct() from invalid context
-ReflectionReference::fromArrayElement() expects parameter 1 to be array, object given
-Key must be array or string
+Call to private ReflectionReference::__construct() from global scope
+ReflectionReference::fromArrayElement(): Argument #1 ($array) must be of type array, stdClass given
+ReflectionReference::fromArrayElement(): Argument #2 ($key) must be of type string|int, array given
Array key not found
Serialization of 'ReflectionReference' is not allowed
diff --git a/ext/reflection/tests/ReflectionType_001.phpt b/ext/reflection/tests/ReflectionType_001.phpt
index 1eb521317c..d0f327d046 100644
--- a/ext/reflection/tests/ReflectionType_001.phpt
+++ b/ext/reflection/tests/ReflectionType_001.phpt
@@ -2,7 +2,7 @@
ReflectionParameter::get/hasType and ReflectionType tests
--FILE--
<?php
-function foo(stdClass $a, array $b, callable $c, stdClass $d = null, $e = null, string $f, bool $g, int $h, float $i, NotExisting $j) { }
+function foo(stdClass $a, array $b, callable $c, string $f, bool $g, int $h, float $i, NotExisting $j, stdClass $d = null, $e = null) { }
function bar(): stdClass { return new stdClass; }
@@ -77,22 +77,22 @@ foreach ([
echo "\n*** property types\n";
class PropTypeTest {
- public int $int;
- public string $string;
- public array $arr;
- public iterable $iterable;
- public stdClass $std;
- public OtherThing $other;
- public $mixed;
+ public int $int;
+ public string $string;
+ public array $arr;
+ public iterable $iterable;
+ public stdClass $std;
+ public OtherThing $other;
+ public $mixed;
}
$reflector = new ReflectionClass(PropTypeTest::class);
foreach ($reflector->getProperties() as $name => $property) {
- if ($property->hasType()) {
- printf("public %s $%s;\n",
- $property->getType()->getName(), $property->getName());
- } else printf("public $%s;\n", $property->getName());
+ if ($property->hasType()) {
+ printf("public %s $%s;\n",
+ $property->getType()->getName(), $property->getName());
+ } else printf("public $%s;\n", $property->getName());
}
echo "*** resolved property types\n";
@@ -120,36 +120,36 @@ bool(true)
string(8) "callable"
** Function 0 - Parameter 3
bool(true)
-bool(true)
-bool(false)
-string(8) "stdClass"
-** Function 0 - Parameter 4
-bool(false)
-** Function 0 - Parameter 5
-bool(true)
bool(false)
bool(true)
string(6) "string"
-** Function 0 - Parameter 6
+** Function 0 - Parameter 4
bool(true)
bool(false)
bool(true)
string(4) "bool"
-** Function 0 - Parameter 7
+** Function 0 - Parameter 5
bool(true)
bool(false)
bool(true)
string(3) "int"
-** Function 0 - Parameter 8
+** Function 0 - Parameter 6
bool(true)
bool(false)
bool(true)
string(5) "float"
-** Function 0 - Parameter 9
+** Function 0 - Parameter 7
bool(true)
bool(false)
bool(false)
string(11) "NotExisting"
+** Function 0 - Parameter 8
+bool(true)
+bool(true)
+bool(false)
+string(8) "stdClass"
+** Function 0 - Parameter 9
+bool(false)
** Function 1 - Parameter 0
bool(true)
bool(false)
diff --git a/ext/reflection/tests/ReflectionType_002.phpt b/ext/reflection/tests/ReflectionType_002.phpt
index 31d396f773..fba766e5e9 100644
--- a/ext/reflection/tests/ReflectionType_002.phpt
+++ b/ext/reflection/tests/ReflectionType_002.phpt
@@ -10,6 +10,7 @@ $rt = $rp->getType();
$rrt = $rm->getReturnType();
unset($rm, $rp);
var_dump($rt->getName(), $rrt->getName());
+?>
--EXPECT--
string(4) "Test"
string(5) "Test2"
diff --git a/ext/reflection/tests/ReflectionZendExtension.phpt b/ext/reflection/tests/ReflectionZendExtension.phpt
index bce34f5a2c..67595a1e06 100644
--- a/ext/reflection/tests/ReflectionZendExtension.phpt
+++ b/ext/reflection/tests/ReflectionZendExtension.phpt
@@ -12,14 +12,10 @@ var_dump($reflection->getCopyright());
var_dump($reflection->getName());
var_dump($reflection->getURL());
var_dump($reflection->getVersion() === PHP_VERSION);
-var_dump(gettype($reflection->export('Zend OPcache', true)) === 'string');
?>
---EXPECTF--
+--EXPECT--
string(17) "Zend Technologies"
string(13) "Copyright (c)"
string(12) "Zend OPcache"
string(20) "http://www.zend.com/"
bool(true)
-
-Deprecated: Function ReflectionZendExtension::export() is deprecated in %s on line %d
-bool(true)
diff --git a/ext/reflection/tests/ReflectionZendExtension_error.phpt b/ext/reflection/tests/ReflectionZendExtension_error.phpt
index efce02640b..9941d91e2e 100644
--- a/ext/reflection/tests/ReflectionZendExtension_error.phpt
+++ b/ext/reflection/tests/ReflectionZendExtension_error.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test ReflectionZendExtension class erros
+Test ReflectionZendExtension class errors
--CREDITS--
Gabriel Caruso (carusogabriel34@gmail.com)
--SKIPIF--
@@ -14,4 +14,4 @@ try {
?>
--EXPECT--
-Zend Extension zend_opcache does not exist
+Zend Extension "zend_opcache" does not exist
diff --git a/ext/reflection/tests/bug26640.phpt b/ext/reflection/tests/bug26640.phpt
index 8a93d72247..203785f1dc 100644
--- a/ext/reflection/tests/bug26640.phpt
+++ b/ext/reflection/tests/bug26640.phpt
@@ -4,19 +4,19 @@ Reflection Bug #26640 (__autoload() not invoked by Reflection classes)
<?php
spl_autoload_register(function ($c) {
- class autoload_class
- {
- public function __construct()
- {
- print "autoload success\n";
- }
- }
+ class autoload_class
+ {
+ public function __construct()
+ {
+ print "autoload success\n";
+ }
+ }
});
$a = new ReflectionClass('autoload_class');
if (is_object($a)) {
- echo "OK\n";
+ echo "OK\n";
}
?>
diff --git a/ext/reflection/tests/bug26695.phpt b/ext/reflection/tests/bug26695.phpt
index e429f766e9..2f50e2151c 100644
--- a/ext/reflection/tests/bug26695.phpt
+++ b/ext/reflection/tests/bug26695.phpt
@@ -19,7 +19,6 @@ $class = $params[0]->getClass();
var_dump($class->getName());
?>
-===DONE===
---EXPECT--
+--EXPECTF--
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
string(3) "Foo"
-===DONE===
diff --git a/ext/reflection/tests/bug29268.phpt b/ext/reflection/tests/bug29268.phpt
index 9166bd3aa9..4bb12819bc 100644
--- a/ext/reflection/tests/bug29268.phpt
+++ b/ext/reflection/tests/bug29268.phpt
@@ -3,25 +3,26 @@ Reflection Bug #29268 (__autoload() not called with reflectionProperty->getClass
--FILE--
<?php
spl_autoload_register(function ($classname) {
- echo "__autoload($classname)\n";
- eval("class $classname {}");
+ echo "__autoload($classname)\n";
+ eval("class $classname {}");
});
class B{
- public function doit(A $a){
- }
+ public function doit(A $a){
+ }
}
$ref = new reflectionMethod('B','doit');
$parameters = $ref->getParameters();
foreach($parameters as $parameter)
{
- $class = $parameter->getClass();
- echo $class->name."\n";
+ $class = $parameter->getClass();
+ echo $class->name."\n";
}
echo "ok\n";
?>
---EXPECT--
+--EXPECTF--
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
__autoload(A)
A
ok
diff --git a/ext/reflection/tests/bug29523.phpt b/ext/reflection/tests/bug29523.phpt
index fafc93ef40..a85612935e 100644
--- a/ext/reflection/tests/bug29523.phpt
+++ b/ext/reflection/tests/bug29523.phpt
@@ -16,15 +16,15 @@ $numberOfNotOptionalParameters = 0;
$numberOfOptionalParameters = 0;
foreach($function->getParameters() as $parameter)
{
- var_dump($parameter->isOptional());
- if ($parameter->isOptional())
- {
- ++$numberOfOptionalParameters;
- }
- else
- {
- ++$numberOfNotOptionalParameters;
- }
+ var_dump($parameter->isOptional());
+ if ($parameter->isOptional())
+ {
+ ++$numberOfOptionalParameters;
+ }
+ else
+ {
+ ++$numberOfNotOptionalParameters;
+ }
}
var_dump($function->getNumberOfRequiredParameters());
var_dump($numberOfNotOptionalParameters);
diff --git a/ext/reflection/tests/bug29828.phpt b/ext/reflection/tests/bug29828.phpt
index 43e32d2116..15c1229cc0 100644
--- a/ext/reflection/tests/bug29828.phpt
+++ b/ext/reflection/tests/bug29828.phpt
@@ -5,15 +5,15 @@ Reflection Bug #29828 (Interfaces no longer work)
interface Bla
{
- function bla();
+ function bla();
}
class BlaMore implements Bla
{
- function bla()
- {
- echo "Hello\n";
- }
+ function bla()
+ {
+ echo "Hello\n";
+ }
}
$r = new ReflectionClass('BlaMore');
@@ -26,10 +26,8 @@ $o=new BlaMore;
$o->bla();
?>
-===DONE===
--EXPECT--
int(1)
bool(false)
bool(false)
Hello
-===DONE===
diff --git a/ext/reflection/tests/bug30146.phpt b/ext/reflection/tests/bug30146.phpt
index 3f621414f1..d2e54324a7 100644
--- a/ext/reflection/tests/bug30146.phpt
+++ b/ext/reflection/tests/bug30146.phpt
@@ -15,9 +15,7 @@ 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
deleted file mode 100644
index 27c31ca6ae..0000000000
--- a/ext/reflection/tests/bug30148.phpt
+++ /dev/null
@@ -1,36 +0,0 @@
---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===
---EXPECTF--
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Root has a deprecated constructor in %s on line %d
-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
index bc1f6c7e86..0dc453e6c0 100644
--- a/ext/reflection/tests/bug30209.phpt
+++ b/ext/reflection/tests/bug30209.phpt
@@ -5,27 +5,25 @@ Reflection Bug #30209 (ReflectionClass::getMethod() lowercases attribute)
class Foo
{
- private $name = 'testBAR';
+ private $name = 'testBAR';
- public function testBAR()
- {
- try
- {
- $class = new ReflectionClass($this);
- var_dump($this->name);
- $method = $class->getMethod($this->name);
- var_dump($this->name);
- }
+ public function testBAR()
+ {
+ try
+ {
+ $class = new ReflectionClass($this);
+ var_dump($this->name);
+ $method = $class->getMethod($this->name);
+ var_dump($this->name);
+ }
- catch (Exception $e) {}
- }
+ catch (Exception $e) {}
+ }
}
$foo = new Foo;
$foo->testBAR();
?>
-===DONE===
--EXPECT--
string(7) "testBAR"
string(7) "testBAR"
-===DONE===
diff --git a/ext/reflection/tests/bug30856.phpt b/ext/reflection/tests/bug30856.phpt
index 39fc1104ab..23d50b17a7 100644
--- a/ext/reflection/tests/bug30856.phpt
+++ b/ext/reflection/tests/bug30856.phpt
@@ -11,10 +11,8 @@ $class = new ReflectionClass('bogus');
var_dump($class->getStaticProperties());
?>
-===DONE===
--EXPECT--
array(1) {
["a"]=>
string(4) "test"
}
-===DONE===
diff --git a/ext/reflection/tests/bug31651.phpt b/ext/reflection/tests/bug31651.phpt
index 59f19eae5d..e356baf148 100644
--- a/ext/reflection/tests/bug31651.phpt
+++ b/ext/reflection/tests/bug31651.phpt
@@ -5,7 +5,7 @@ Reflection Bug #31651 (ReflectionClass::getDefaultProperties segfaults with arra
class Test
{
- public $a = array('a' => 1);
+ public $a = array('a' => 1);
}
$ref = new ReflectionClass('Test');
diff --git a/ext/reflection/tests/bug32981.phpt b/ext/reflection/tests/bug32981.phpt
index 5735674585..fc6960866f 100644
--- a/ext/reflection/tests/bug32981.phpt
+++ b/ext/reflection/tests/bug32981.phpt
@@ -5,23 +5,22 @@ Reflection Bug #32981 (ReflectionMethod::getStaticVariables() causes apache2.0.5
class TestClass
{
- static function test()
- {
- static $enabled = true;
- }
+ 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($method->getName());
+ $arr_static_vars[] = $method->getStaticVariables();
}
var_dump($arr_static_vars);
?>
-===DONE===
--EXPECT--
string(4) "test"
array(1) {
@@ -31,4 +30,3 @@ array(1) {
bool(true)
}
}
-===DONE===
diff --git a/ext/reflection/tests/bug33389.phpt b/ext/reflection/tests/bug33389.phpt
index fb166c16ba..e394b1f296 100644
--- a/ext/reflection/tests/bug33389.phpt
+++ b/ext/reflection/tests/bug33389.phpt
@@ -20,6 +20,7 @@ class Test {
}
}
echo new ReflectionClass('Test');
+?>
--EXPECTF--
Class [ <user> class Test ] {
@@ %sbug33389.php 3-18
diff --git a/ext/reflection/tests/bug36434.phpt b/ext/reflection/tests/bug36434.phpt
index 502ac741a9..04cdcbf01d 100644
--- a/ext/reflection/tests/bug36434.phpt
+++ b/ext/reflection/tests/bug36434.phpt
@@ -5,24 +5,24 @@ Reflection Bug #36434 (Properties from parent class fail to indetify their true
class ancester
{
public $ancester = 0;
- function __construct()
- {
- return $this->ancester;
- }
+ function __construct()
+ {
+ return $this->ancester;
+ }
}
class foo extends ancester
{
public $bar = "1";
- function __construct()
- {
- return $this->bar;
- }
+ function __construct()
+ {
+ return $this->bar;
+ }
}
$r = new ReflectionClass('foo');
foreach ($r->GetProperties() as $p)
{
- echo $p->getName(). " ". $p->getDeclaringClass()->getName()."\n";
+ echo $p->getName(). " ". $p->getDeclaringClass()->getName()."\n";
}
?>
diff --git a/ext/reflection/tests/bug37816.phpt b/ext/reflection/tests/bug37816.phpt
index 89ca3238b6..42be0e6ede 100644
--- a/ext/reflection/tests/bug37816.phpt
+++ b/ext/reflection/tests/bug37816.phpt
@@ -5,7 +5,7 @@ Bug #37816 (ReflectionProperty does not throw exception when accessing protected
class TestClass
{
- protected $p = 2;
+ protected $p = 2;
}
$o = new TestClass;
@@ -14,15 +14,13 @@ $r = new ReflectionProperty($o, 'p');
try
{
- $x = $r->getValue($o);
+ $x = $r->getValue($o);
}
catch (Exception $e)
{
- echo 'Caught: ' . $e->getMessage() . "\n";
+ echo 'Caught: ' . $e->getMessage() . "\n";
}
?>
-===DONE===
--EXPECT--
-Caught: Cannot access non-public member TestClass::$p
-===DONE===
+Caught: Cannot access non-public property TestClass::$p
diff --git a/ext/reflection/tests/bug37964.phpt b/ext/reflection/tests/bug37964.phpt
index f3ebe9f72a..59b5f85590 100644
--- a/ext/reflection/tests/bug37964.phpt
+++ b/ext/reflection/tests/bug37964.phpt
@@ -4,19 +4,19 @@ Reflection Bug #37964 (Reflection shows private methods of parent class)
<?php
abstract class foobar {
- private function test2() {
- }
+ private function test2() {
+ }
}
class foo extends foobar {
- private $foo = 1;
- private function test() {
- }
- protected function test3() {
- }
+ private $foo = 1;
+ private function test() {
+ }
+ protected function test3() {
+ }
}
class bar extends foo {
- private function foobar() {
- }
+ private function foobar() {
+ }
}
echo new ReflectionClass(new bar);
diff --git a/ext/reflection/tests/bug38132.phpt b/ext/reflection/tests/bug38132.phpt
index 16e56411f2..e500616604 100644
--- a/ext/reflection/tests/bug38132.phpt
+++ b/ext/reflection/tests/bug38132.phpt
@@ -3,8 +3,8 @@ Reflection Bug #38132 (ReflectionClass::getStaticProperties() retains \0 in key
--FILE--
<?php
class foo {
- static protected $bar = 'baz';
- static public $a = 'a';
+ static protected $bar = 'baz';
+ static public $a = 'a';
}
$class = new ReflectionClass('foo');
diff --git a/ext/reflection/tests/bug38217.phpt b/ext/reflection/tests/bug38217.phpt
index 46f2dc3e0e..cc7525c813 100644
--- a/ext/reflection/tests/bug38217.phpt
+++ b/ext/reflection/tests/bug38217.phpt
@@ -4,24 +4,24 @@ Bug #38217 (ReflectionClass::newInstanceArgs() tries to allocate too much memory
<?php
class ObjectOne {
- public function __construct() {
- }
+ public function __construct() {
+ }
}
$class= new ReflectionClass('ObjectOne');
var_dump($class->newInstanceArgs());
class ObjectTwo {
- public function __construct($var) {
- var_dump($var);
- }
+ public function __construct($var) {
+ var_dump($var);
+ }
}
$class= new ReflectionClass('ObjectTwo');
try {
- var_dump($class->newInstanceArgs());
+ var_dump($class->newInstanceArgs());
} catch (Throwable $e) {
- echo "Exception: " . $e->getMessage() . "\n";
+ echo "Exception: " . $e->getMessage() . "\n";
}
var_dump($class->newInstanceArgs(array('test')));
diff --git a/ext/reflection/tests/bug38653.phpt b/ext/reflection/tests/bug38653.phpt
index 64b1aad15b..36504e7c7b 100644
--- a/ext/reflection/tests/bug38653.phpt
+++ b/ext/reflection/tests/bug38653.phpt
@@ -4,9 +4,9 @@ Bug #38653 (memory leak in ReflectionClass::getConstant())
<?php
class foo {
- const cons = 10;
- const cons1 = "";
- const cons2 = "test";
+ const cons = 10;
+ const cons1 = "";
+ const cons2 = "test";
}
class bar extends foo {
diff --git a/ext/reflection/tests/bug38942.phpt b/ext/reflection/tests/bug38942.phpt
deleted file mode 100644
index 6dbe396ae6..0000000000
--- a/ext/reflection/tests/bug38942.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---TEST--
-Bug #38942 (Double old-style-ctor inheritance)
---FILE--
-<?php
-class foo {
- public function foo() {}
-}
-
-class bar extends foo {
-}
-echo new ReflectionClass("bar");
-?>
---EXPECTF--
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; foo has a deprecated constructor in %s on line %d
-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
index ec4b7a5d1b..1e390341e7 100644
--- a/ext/reflection/tests/bug39001.phpt
+++ b/ext/reflection/tests/bug39001.phpt
@@ -7,8 +7,8 @@ class Meta {
}
class CParent extends Meta {
- public $publicVar;
- protected $protectedVar;
+ public $publicVar;
+ protected $protectedVar;
}
class Child extends CParent {
diff --git a/ext/reflection/tests/bug39067.phpt b/ext/reflection/tests/bug39067.phpt
index f549f794e0..05ce90be46 100644
--- a/ext/reflection/tests/bug39067.phpt
+++ b/ext/reflection/tests/bug39067.phpt
@@ -4,15 +4,15 @@ Bug #39067 (getDeclaringClass() and private properties)
<?php
class A {
- private $x;
+ private $x;
}
class B extends A {
- private $x;
+ private $x;
}
class C extends B {
- private $x;
+ private $x;
}
$rc = new ReflectionClass('C');
@@ -25,11 +25,11 @@ $rc = new ReflectionClass('A');
var_dump($rc->getProperty('x')->getDeclaringClass()->getName());
class Test {
- private $x;
+ private $x;
}
class Test2 extends Test {
- public $x;
+ public $x;
}
$rc = new ReflectionClass('Test2');
diff --git a/ext/reflection/tests/bug39884.phpt b/ext/reflection/tests/bug39884.phpt
index 1d0e04b0b9..4049493028 100644
--- a/ext/reflection/tests/bug39884.phpt
+++ b/ext/reflection/tests/bug39884.phpt
@@ -15,7 +15,8 @@ $test1->paramTest($test2);
$refParam = new ReflectionParameter(array('stubParamTest', 'paramTest'), 'param');
var_dump($refParam->getClass());
?>
---EXPECT--
+--EXPECTF--
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
object(ReflectionClass)#4 (1) {
["name"]=>
string(13) "stubParamTest"
diff --git a/ext/reflection/tests/bug40431.phpt b/ext/reflection/tests/bug40431.phpt
index 637b1457cd..41620a3926 100644
--- a/ext/reflection/tests/bug40431.phpt
+++ b/ext/reflection/tests/bug40431.phpt
@@ -56,7 +56,7 @@ var_dump($props[0]->isProtected());
echo "=== 4th test ===\n";
class test5 {
- private $value = 1;
+ private $value = 1;
}
class test4 extends test5{
diff --git a/ext/reflection/tests/bug40794.phpt b/ext/reflection/tests/bug40794.phpt
index c1830ddcd2..1f1bb61c58 100644
--- a/ext/reflection/tests/bug40794.phpt
+++ b/ext/reflection/tests/bug40794.phpt
@@ -13,7 +13,7 @@ $reflect = new ReflectionObject($obj);
$array = array();
foreach($reflect->getProperties() as $prop)
{
- $array[$prop->getName()] = $prop->getValue($obj);
+ $array[$prop->getName()] = $prop->getValue($obj);
}
var_dump($array);
diff --git a/ext/reflection/tests/bug41061.phpt b/ext/reflection/tests/bug41061.phpt
index 027b872be9..df807566db 100644
--- a/ext/reflection/tests/bug41061.phpt
+++ b/ext/reflection/tests/bug41061.phpt
@@ -14,8 +14,6 @@ class bar {
echo new ReflectionFunction('foo'), "\n";
echo new ReflectionMethod('bar', 'foo'), "\n";
?>
-===DONE===
-<?php exit(0); ?>
--EXPECTF--
Function [ <user> function foo ] {
@@ %sbug41061.php 3 - 4
@@ -25,4 +23,3 @@ Method [ <user> private method foo ] {
@@ %sbug41061.php 7 - 8
}
-===DONE===
diff --git a/ext/reflection/tests/bug41884.phpt b/ext/reflection/tests/bug41884.phpt
index 25d2b7cb74..ae9655765e 100644
--- a/ext/reflection/tests/bug41884.phpt
+++ b/ext/reflection/tests/bug41884.phpt
@@ -5,8 +5,8 @@ Bug #41884 (ReflectionClass::getDefaultProperties() does not handle static attri
class Foo
{
- protected static $fooStatic = 'foo';
- protected $foo = 'foo';
+ protected static $fooStatic = 'foo';
+ protected $foo = 'foo';
}
$class = new ReflectionClass('Foo');
diff --git a/ext/reflection/tests/bug42976.phpt b/ext/reflection/tests/bug42976.phpt
index 0b147aa811..5e5c3c5be5 100644
--- a/ext/reflection/tests/bug42976.phpt
+++ b/ext/reflection/tests/bug42976.phpt
@@ -4,9 +4,9 @@ Bug #42976 (Crash when constructor for newInstance() or newInstanceArgs() fails)
<?php
Class C {
- function __construct(&$x) {
- $x = "x.changed";
- }
+ function __construct(&$x) {
+ $x = "x.changed";
+ }
}
$x = "x.original";
@@ -26,9 +26,9 @@ 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: C::__construct(): Argument #1 ($x) must be passed by reference, value given in %s on line %d
string(10) "x.original"
-Warning: Parameter 1 to C::__construct() expected to be a reference, value given in %sbug42976.php on line 18
+Warning: C::__construct(): Argument #1 ($x) must be passed by reference, value given in %s on line %d
string(10) "x.original"
Done
diff --git a/ext/reflection/tests/bug45139.phpt b/ext/reflection/tests/bug45139.phpt
index 6aa84263c6..5a8f62d0cd 100644
--- a/ext/reflection/tests/bug45139.phpt
+++ b/ext/reflection/tests/bug45139.phpt
@@ -4,19 +4,19 @@ Bug #45139 (ReflectionProperty returns incorrect declaring class)
<?php
class A {
- private $foo;
+ private $foo;
}
class B extends A {
- protected $bar;
- private $baz;
- private $quux;
+ protected $bar;
+ private $baz;
+ private $quux;
}
class C extends B {
- public $foo;
- private $baz;
- protected $quux;
+ public $foo;
+ private $baz;
+ protected $quux;
}
$rc = new ReflectionClass('C');
diff --git a/ext/reflection/tests/bug45571.phpt b/ext/reflection/tests/bug45571.phpt
index 74245fc24c..7b48859564 100644
--- a/ext/reflection/tests/bug45571.phpt
+++ b/ext/reflection/tests/bug45571.phpt
@@ -4,12 +4,12 @@ Bug #45571 (ReflectionClass::__toString() shows superclasses' private static met
<?php
Class A {
- static private $a = 0;
- static protected $b = 1;
- static public $c = 2;
+ static private $a = 0;
+ static protected $b = 1;
+ static public $c = 2;
- private function f() {}
- private static function sf() {}
+ private function f() {}
+ private static function sf() {}
}
Class C extends A { }
@@ -25,8 +25,8 @@ Class [ <user> class C extends A ] {
}
- Static properties [2] {
- Property [ protected static $b ]
- Property [ public static $c ]
+ Property [ protected static $b = 1 ]
+ Property [ public static $c = 2 ]
}
- Static methods [0] {
diff --git a/ext/reflection/tests/bug45765.phpt b/ext/reflection/tests/bug45765.phpt
index 5c33faca2b..af8dd9b47a 100644
--- a/ext/reflection/tests/bug45765.phpt
+++ b/ext/reflection/tests/bug45765.phpt
@@ -4,23 +4,23 @@ Fixed bug #45765 (ReflectionObject with default parameters of self::xxx cause an
<?php
class foo2 {
- const BAR = 'foobar';
+ const BAR = 'foobar';
}
class foo extends foo2 {
- const BAR = "foo's bar";
+ const BAR = "foo's bar";
- function test($a = self::BAR) {
- }
+ function test($a = self::BAR) {
+ }
- function test2($a = parent::BAR) {
- }
+ function test2($a = parent::BAR) {
+ }
- function test3($a = foo::BAR) {
- }
+ function test3($a = foo::BAR) {
+ }
- function test4($a = foo2::BAR) {
- }
+ function test4($a = foo2::BAR) {
+ }
}
echo new ReflectionObject(new foo);
diff --git a/ext/reflection/tests/bug46064.phpt b/ext/reflection/tests/bug46064.phpt
index d8ee411905..4a97b3b22a 100644
--- a/ext/reflection/tests/bug46064.phpt
+++ b/ext/reflection/tests/bug46064.phpt
@@ -4,7 +4,7 @@ Bug #46064 (Exception when creating ReflectionProperty object on dynamicly creat
<?php
class x {
- public $zzz = 2;
+ public $zzz = 2;
}
$o = new x;
@@ -21,31 +21,30 @@ var_dump($h->getValue($o));
print "---------------------------\n";
try {
- var_dump(new reflectionproperty($o, 'zz'));
+ var_dump(new reflectionproperty($o, 'zz'));
} catch (Exception $e) {
- var_dump($e->getMessage());
+ var_dump($e->getMessage());
}
var_dump(new reflectionproperty($o, 'zzz'));
class test {
- protected $a = 1;
+ protected $a = 1;
}
class bar extends test {
- public function __construct() {
- $this->foobar = 2;
- $this->a = 200;
+ public function __construct() {
+ $this->foobar = 2;
+ $this->a = 200;
- $p = new reflectionproperty($this, 'foobar');
- var_dump($p->getValue($this), $p->isDefault(), $p->isPublic());
- }
+ $p = new reflectionproperty($this, 'foobar');
+ var_dump($p->getValue($this), $p->isDefault(), $p->isPublic());
+ }
}
new bar;
?>
-===DONE===
--EXPECTF--
object(ReflectionProperty)#%d (2) {
["name"]=>
@@ -73,4 +72,3 @@ object(ReflectionProperty)#%d (2) {
int(2)
bool(false)
bool(true)
-===DONE===
diff --git a/ext/reflection/tests/bug46064_2.phpt b/ext/reflection/tests/bug46064_2.phpt
index 65afa836b7..f1aac5b5c0 100644
--- a/ext/reflection/tests/bug46064_2.phpt
+++ b/ext/reflection/tests/bug46064_2.phpt
@@ -15,28 +15,27 @@ var_dump($p->getProperty('test'));
class bar {
- public function __construct() {
- $this->a = 1;
- }
+ public function __construct() {
+ $this->a = 1;
+ }
}
class test extends bar {
- private $b = 2;
+ private $b = 2;
- public function __construct() {
- parent::__construct();
+ 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());
- }
+ $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"]=>
@@ -71,4 +70,3 @@ array(2) {
string(4) "test"
}
}
-===DONE===
diff --git a/ext/reflection/tests/bug46205.phpt b/ext/reflection/tests/bug46205.phpt
deleted file mode 100644
index 5ca8ac1cd0..0000000000
--- a/ext/reflection/tests/bug46205.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---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
---EXPECTF--
-Deprecated: Function ReflectionParameter::export() is deprecated in %s on line %d
-ok
diff --git a/ext/reflection/tests/bug47254.phpt b/ext/reflection/tests/bug47254.phpt
index e3ce114c9c..6330d6603f 100644
--- a/ext/reflection/tests/bug47254.phpt
+++ b/ext/reflection/tests/bug47254.phpt
@@ -8,13 +8,13 @@ Testfest 2009 Munich
<?php
class A
{
- protected function a() {}
+ protected function a() {}
}
class B extends A
{
- public function b() {}
+ public function b() {}
}
$B = new B();
@@ -23,10 +23,7 @@ $m = $R->getMethods();
print_r($m);
?>
---EXPECTF--
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d
-
-Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in %s on line %d
+--EXPECT--
Array
(
[0] => ReflectionMethod Object
diff --git a/ext/reflection/tests/bug48757.phpt b/ext/reflection/tests/bug48757.phpt
index a5ced91d3a..45393470d3 100644
--- a/ext/reflection/tests/bug48757.phpt
+++ b/ext/reflection/tests/bug48757.phpt
@@ -3,11 +3,11 @@ Bug #48757 (ReflectionFunction::invoke() parameter issues)
--FILE--
<?php
function test() {
- echo "Hello World\n";
+ echo "Hello World\n";
}
function another_test($parameter) {
- var_dump($parameter);
+ var_dump($parameter);
}
$func = new ReflectionFunction('test');
diff --git a/ext/reflection/tests/bug49074.phpt b/ext/reflection/tests/bug49074.phpt
index 7ce23b41e4..b39814cdf6 100644
--- a/ext/reflection/tests/bug49074.phpt
+++ b/ext/reflection/tests/bug49074.phpt
@@ -3,13 +3,13 @@ Bug #49074 (private class static fields can be modified by using reflection)
--FILE--
<?php
class Test {
- private static $data1 = 1;
- private static $data4 = 4;
+ private static $data1 = 1;
+ private static $data4 = 4;
}
class Test2 extends Test {
- private static $data2 = 2;
- public static $data3 = 3;
+ private static $data2 = 2;
+ public static $data3 = 3;
}
$r = new ReflectionClass('Test2');
diff --git a/ext/reflection/tests/bug49719.phpt b/ext/reflection/tests/bug49719.phpt
index 6211b6b543..b39ca3481c 100644
--- a/ext/reflection/tests/bug49719.phpt
+++ b/ext/reflection/tests/bug49719.phpt
@@ -4,30 +4,30 @@ Bug #49719 (ReflectionClass::hasProperty returns true for a private property in
<?php
class A {
- private $a;
+ private $a;
}
class B extends A {
- private $b;
+ private $b;
}
try {
- $b = new B;
- $ref = new ReflectionClass($b);
+ $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'));
+ 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());
+ var_dump($e->getMessage());
}
class A2 {
- private $a = 1;
+ private $a = 1;
}
class B2 extends A2 {
- private $a = 2;
+ private $a = 2;
}
$b2 = new ReflectionClass('B2');
@@ -40,5 +40,5 @@ var_dump($prop->getValue(new b2));
bool(false)
bool(false)
bool(false)
-string(25) "Property a does not exist"
+string(29) "Property B::$a does not exist"
int(2)
diff --git a/ext/reflection/tests/bug51905.phpt b/ext/reflection/tests/bug51905.phpt
index 8969924e45..2d956386a5 100644
--- a/ext/reflection/tests/bug51905.phpt
+++ b/ext/reflection/tests/bug51905.phpt
@@ -4,12 +4,12 @@ Bug #51905 (ReflectionParameter fails if default value is an array with an acces
<?php
class Bar {
- const Y = 20;
+ const Y = 20;
}
class Foo extends Bar {
- const X = 12;
- public function x($x = 1, $y = array(self::X), $z = parent::Y) {}
+ const X = 12;
+ public function x($x = 1, $y = array(self::X), $z = parent::Y) {}
}
$clazz = new ReflectionClass('Foo');
diff --git a/ext/reflection/tests/bug52854.phpt b/ext/reflection/tests/bug52854.phpt
index 255522de5d..2d174bc11e 100644
--- a/ext/reflection/tests/bug52854.phpt
+++ b/ext/reflection/tests/bug52854.phpt
@@ -11,9 +11,9 @@ var_dump($c->newInstance());
var_dump($c->newInstanceArgs(array()));
try {
- var_dump($c->newInstanceArgs(array(1)));
+ var_dump($c->newInstanceArgs(array(1)));
} catch(ReflectionException $e) {
- echo $e->getMessage()."\n";
+ echo $e->getMessage()."\n";
}
?>
--EXPECTF--
diff --git a/ext/reflection/tests/bug53366.phpt b/ext/reflection/tests/bug53366.phpt
index 5fb119d820..61493d5302 100644
--- a/ext/reflection/tests/bug53366.phpt
+++ b/ext/reflection/tests/bug53366.phpt
@@ -1,5 +1,5 @@
--TEST--
-Bug #53366 (Reflection doesnt get dynamic property value from getProperty())
+Bug #53366 (Reflection doesn't get dynamic property value from getProperty())
--FILE--
<?php
diff --git a/ext/reflection/tests/bug53915.phpt b/ext/reflection/tests/bug53915.phpt
index f2f2ae5675..633e82817b 100644
--- a/ext/reflection/tests/bug53915.phpt
+++ b/ext/reflection/tests/bug53915.phpt
@@ -4,8 +4,8 @@ Bug #53915 - ReflectionClass::getConstant(s) emits fatal error on selfreferencin
<?php
Class Foo
{
- const A = 1;
- const B = self::A;
+ const A = 1;
+ const B = self::A;
}
$rc = new ReflectionClass('Foo');
@@ -19,6 +19,7 @@ Class Foo2
$rc = new ReflectionClass('Foo2');
print_r($rc->getConstant('B'));
+?>
--EXPECT--
Array
(
diff --git a/ext/reflection/tests/bug60367.phpt b/ext/reflection/tests/bug60367.phpt
index 3834445733..3cd5fd07a0 100644
--- a/ext/reflection/tests/bug60367.phpt
+++ b/ext/reflection/tests/bug60367.phpt
@@ -4,17 +4,17 @@ Bug #60367 (Reflection and Late Static Binding)
<?php
abstract class A {
- const WHAT = 'A';
+ const WHAT = 'A';
- public static function call() {
- echo static::WHAT;
- }
+ public static function call() {
+ echo static::WHAT;
+ }
}
class B extends A {
- const WHAT = 'B';
+ const WHAT = 'B';
}
@@ -24,5 +24,6 @@ $method->invokeArgs(null, array());
$method = new ReflectionMethod("A::call");
$method->invoke(null);
$method->invokeArgs(null, array());
+?>
--EXPECT--
BBAA
diff --git a/ext/reflection/tests/bug61388.phpt b/ext/reflection/tests/bug61388.phpt
index b9fe6bfaaa..f8eb797a79 100644
--- a/ext/reflection/tests/bug61388.phpt
+++ b/ext/reflection/tests/bug61388.phpt
@@ -11,6 +11,7 @@ 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
(
diff --git a/ext/reflection/tests/bug62715.phpt b/ext/reflection/tests/bug62715.phpt
index feb67f614b..63339cddc1 100644
--- a/ext/reflection/tests/bug62715.phpt
+++ b/ext/reflection/tests/bug62715.phpt
@@ -16,7 +16,8 @@ foreach ($r->getParameters() as $p) {
}
}
?>
---EXPECT--
+--EXPECTF--
+Deprecated: Required parameter $c follows optional parameter $b in %s on line %d
bool(true)
bool(true)
bool(false)
diff --git a/ext/reflection/tests/bug64239.phpt b/ext/reflection/tests/bug64239.phpt
index 9acdc1987b..100c09d2eb 100644
--- a/ext/reflection/tests/bug64239.phpt
+++ b/ext/reflection/tests/bug64239.phpt
@@ -3,11 +3,11 @@ Bug #64239 (ReflectionClass::getMethods() changed behavior)
--FILE--
<?php
class A {
- use T2 { t2method as Bmethod; }
+ use T2 { t2method as Bmethod; }
}
trait T2 {
- public function t2method() {
- }
+ public function t2method() {
+ }
}
class B extends A{
diff --git a/ext/reflection/tests/bug64936.phpt b/ext/reflection/tests/bug64936.phpt
index c3e781805e..ae63d43008 100644
--- a/ext/reflection/tests/bug64936.phpt
+++ b/ext/reflection/tests/bug64936.phpt
@@ -9,8 +9,8 @@ opcache.save_comments=1
function strip_doc_comment($c)
{
- if (!strlen($c) || $c === false) return $c;
- return trim(substr($c, 3, -2));
+ if (!strlen($c) || $c === false) return $c;
+ return trim(substr($c, 3, -2));
}
token_get_all("<?php\n/**\n * Foo\n */"); // doc_comment compiler global now contains this Foo comment
@@ -28,8 +28,6 @@ $rb = new ReflectionClass('B');
var_dump(strip_doc_comment($rb->getDocComment()));
?>
-===DONE===
--EXPECT--
bool(false)
bool(false)
-===DONE===
diff --git a/ext/reflection/tests/bug66430.phpt b/ext/reflection/tests/bug66430.phpt
index 921e2c99d8..bd3100b47b 100644
--- a/ext/reflection/tests/bug66430.phpt
+++ b/ext/reflection/tests/bug66430.phpt
@@ -4,11 +4,11 @@ Bug #66430: ReflectionFunction::invoke does not invoke closure with object scope
<?php
class Alpha {
- public $message = "Valid representation";
+ public $message = "Valid representation";
- public function bravo() {
- return $this->message;
- }
+ public function bravo() {
+ return $this->message;
+ }
}
$alpha = new Alpha();
diff --git a/ext/reflection/tests/bug69180.phpt b/ext/reflection/tests/bug69180.phpt
new file mode 100644
index 0000000000..80d69dcd5c
--- /dev/null
+++ b/ext/reflection/tests/bug69180.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Bug #69180: Reflection does not honor trait conflict resolution / method aliasing
+--FILE--
+<?php
+
+trait T1
+{
+ public function foo()
+ {
+ }
+}
+
+trait T2
+{
+ use T1 { foo as bar; }
+
+ public function foo()
+ {
+ }
+}
+
+
+class C
+{
+ use T2;
+}
+
+$class = new ReflectionClass('C');
+
+foreach ($class->getMethods() as $method) {
+ var_dump($method->getName());
+}
+
+?>
+--EXPECT--
+string(3) "foo"
+string(3) "bar"
diff --git a/ext/reflection/tests/bug69802.phpt b/ext/reflection/tests/bug69802.phpt
index 0a58d0b2ac..bf60ea0143 100644
--- a/ext/reflection/tests/bug69802.phpt
+++ b/ext/reflection/tests/bug69802.phpt
@@ -10,8 +10,10 @@ echo $r->getParameters()[0], "\n";
echo $r->getReturnType()->getName(), "\n";
echo $r,"\n";
?>
---EXPECT--
+--EXPECTF--
string(1) "x"
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
object(ReflectionClass)#4 (1) {
["name"]=>
string(8) "stdClass"
diff --git a/ext/reflection/tests/bug70982.phpt b/ext/reflection/tests/bug70982.phpt
index d530846f64..644531e373 100644
--- a/ext/reflection/tests/bug70982.phpt
+++ b/ext/reflection/tests/bug70982.phpt
@@ -3,11 +3,11 @@ Bug #70982 (setStaticPropertyValue behaviors inconsistently with 5.6)
--FILE--
<?php
class Foo {
- static $abc;
- function __construct()
- {
- var_dump(self::$abc);
- }
+ static $abc;
+ function __construct()
+ {
+ var_dump(self::$abc);
+ }
}
class Bar extends Foo {
diff --git a/ext/reflection/tests/bug71767.phpt b/ext/reflection/tests/bug71767.phpt
index c20073c67a..95094290bf 100644
--- a/ext/reflection/tests/bug71767.phpt
+++ b/ext/reflection/tests/bug71767.phpt
@@ -27,13 +27,21 @@ $func = function(
) {
};
+/** Correct docblock */
+$func2 = fn(
+ /** wrong docblock */
+ $arg
+) => null;
+
$reflectionFunction = new ReflectionFunction('foo');
$reflectionClass = new ReflectionClass(Foo::class);
$reflectionClosure = new ReflectionFunction($func);
+$reflectionArrowFn = new ReflectionFunction($func2);
echo $reflectionFunction->getDocComment() . PHP_EOL;
echo $reflectionClass->getMethod('bar')->getDocComment() . PHP_EOL;
echo $reflectionClosure->getDocComment() . PHP_EOL;
+echo $reflectionArrowFn->getDocComment() . PHP_EOL;
echo "Done\n";
?>
@@ -41,4 +49,5 @@ echo "Done\n";
/** Correct docblock */
/** Correct docblock */
/** Correct docblock */
+/** Correct docblock */
Done
diff --git a/ext/reflection/tests/bug72661.phpt b/ext/reflection/tests/bug72661.phpt
index 46ba048078..b1cb764beb 100644
--- a/ext/reflection/tests/bug72661.phpt
+++ b/ext/reflection/tests/bug72661.phpt
@@ -6,6 +6,5 @@ function test(iterable $arg) { }
var_dump((string)(new ReflectionParameter("test", 0))->getType());
?>
---EXPECTF--
-Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d
+--EXPECT--
string(8) "iterable"
diff --git a/ext/reflection/tests/bug74454.inc b/ext/reflection/tests/bug74454.inc
index 5136591367..e668e88643 100644
--- a/ext/reflection/tests/bug74454.inc
+++ b/ext/reflection/tests/bug74454.inc
@@ -1,4 +1,4 @@
<?php
class A {
- if (wrongsyntax)
+ if (wrongsyntax)
}
diff --git a/ext/reflection/tests/bug74454.phpt b/ext/reflection/tests/bug74454.phpt
index 9e0332d893..2a61ff7cc0 100644
--- a/ext/reflection/tests/bug74454.phpt
+++ b/ext/reflection/tests/bug74454.phpt
@@ -4,16 +4,14 @@ Bug #74454 (Wrong exception being thrown when using ReflectionMethod)
<?php
spl_autoload_register('load_file');
try {
- $x = new ReflectionMethod('A', 'b');
+ $x = new ReflectionMethod('A', 'b');
} catch (\Throwable $e) {
- echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
+ echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
}
function load_file() {
- require __DIR__ . '/bug74454.inc';
+ require __DIR__ . '/bug74454.inc';
}
?>
-===DONE===
--EXPECT--
-ParseError: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) or const (T_CONST)
-===DONE===
+ParseError: syntax error, unexpected token "if", expecting "function" or "const"
diff --git a/ext/reflection/tests/bug74673.phpt b/ext/reflection/tests/bug74673.phpt
index 47f7604e8b..a8b9d998ca 100644
--- a/ext/reflection/tests/bug74673.phpt
+++ b/ext/reflection/tests/bug74673.phpt
@@ -3,15 +3,11 @@ Bug #74673 (Segfault when cast Reflection object to string with undefined consta
--FILE--
<?php
-set_error_handler(function() {
- throw new Exception();
-});
-
class A
{
- public function method($test = PHP_SELF + 1)
- {
- }
+ public function method($test = PHP_SELF + 1)
+ {
+ }
}
$class = new ReflectionClass('A');
@@ -19,9 +15,8 @@ $class = new ReflectionClass('A');
echo $class;
?>
--EXPECTF--
-Fatal error: Uncaught Exception in %s:%d
+Fatal error: Uncaught Error: Undefined constant "PHP_SELF" in %s:%d
Stack trace:
-#0 [internal function]: {closure}(2, 'Use of undefine...', %s, %d, Array)
-#1 %s(%d): ReflectionClass->__toString()
-#2 {main}
+#0 %s(%d): ReflectionClass->__toString()
+#1 {main}
thrown in %s on line %d
diff --git a/ext/reflection/tests/bug74949.phpt b/ext/reflection/tests/bug74949.phpt
index 2970c5911f..20e0fc00e1 100644
--- a/ext/reflection/tests/bug74949.phpt
+++ b/ext/reflection/tests/bug74949.phpt
@@ -12,9 +12,9 @@ unset($f);
echo $r, "\n";
try {
- echo $r->getPrototype();
+ echo $r->getPrototype();
} catch (Exception $e) {
- echo $e->getMessage(), "\n";
+ echo $e->getMessage(), "\n";
}
?>
--EXPECT--
diff --git a/ext/reflection/tests/bug76536.phpt b/ext/reflection/tests/bug76536.phpt
index 9f3b3fdb31..d6b22ada21 100644
--- a/ext/reflection/tests/bug76536.phpt
+++ b/ext/reflection/tests/bug76536.phpt
@@ -2,7 +2,7 @@
Bug #76536 (PHP crashes with core dump when throwing exception in error handler)
--FILE--
<?php
-class SomeConstants {const SOME_CONSTANT = SOME_NONSENSE;}
+class SomeConstants {const SOME_CONSTANT = "0foo" % 5; }
function handleError() {throw new ErrorException();}
diff --git a/ext/reflection/tests/bug77325.phpt b/ext/reflection/tests/bug77325.phpt
new file mode 100644
index 0000000000..f451b21ac9
--- /dev/null
+++ b/ext/reflection/tests/bug77325.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #77325: ReflectionClassConstant::$class returns wrong class when extending
+--FILE--
+<?php
+
+class Foo {
+ const FOO = 'foo';
+}
+
+class Bar extends Foo {
+}
+
+$barClassReflection = new ReflectionClass(Bar::class);
+$constants = $barClassReflection->getReflectionConstants();
+foreach ($constants as $constant) {
+ var_dump($constant->class);
+ var_dump($constant->getDeclaringClass()->getName());
+}
+
+$constant = new ReflectionClassConstant(Bar::class, 'FOO');
+var_dump($constant->class);
+var_dump($constant->getDeclaringClass()->getName());
+
+?>
+--EXPECT--
+string(3) "Foo"
+string(3) "Foo"
+string(3) "Foo"
+string(3) "Foo"
diff --git a/ext/reflection/tests/bug77882.phpt b/ext/reflection/tests/bug77882.phpt
index ff1d212861..71e430d178 100644
--- a/ext/reflection/tests/bug77882.phpt
+++ b/ext/reflection/tests/bug77882.phpt
@@ -7,7 +7,7 @@ class Test {
public function __construct() {
throw new Exception();
}
-
+
public function __destruct() {
echo "__destruct\n";
}
diff --git a/ext/reflection/tests/bug78774.phpt b/ext/reflection/tests/bug78774.phpt
index 1e419b1138..7f72039e07 100644
--- a/ext/reflection/tests/bug78774.phpt
+++ b/ext/reflection/tests/bug78774.phpt
@@ -5,18 +5,24 @@ Bug #78774: ReflectionNamedType on Typed Properties Crash
class Test {
public stdClass $prop;
+ public stdClass|Foo $prop2;
}
$rc = new ReflectionClass(Test::class);
$rp = $rc->getProperty('prop');
$rt = $rp->getType();
+$rp2 = $rc->getProperty('prop2');
+$rt2 = $rp2->getType();
// Force a resolution of the property type
$test = new Test;
$test->prop = new stdClass;
+$test->prop2 = new stdClass;
var_dump($rt->getName());
+var_dump((string) $rt2);
?>
--EXPECT--
string(8) "stdClass"
+string(12) "stdClass|Foo"
diff --git a/ext/reflection/tests/bug78895.phpt b/ext/reflection/tests/bug78895.phpt
index 7e616c4456..b5f84e2d02 100644
--- a/ext/reflection/tests/bug78895.phpt
+++ b/ext/reflection/tests/bug78895.phpt
@@ -3,18 +3,18 @@ Fixed bug #78895 (Reflection detects abstract non-static class as abstract stati
--FILE--
<?php
abstract class Foo {
- abstract public function f1();
+ abstract public function f1();
}
interface I {
- public function f2();
+ public function f2();
}
trait T {
- abstract public function f2();
+ abstract public function f2();
}
class Bar extends Foo implements I {
- use T;
- function f1() {}
- function f2() {}
+ use T;
+ function f1() {}
+ function f2() {}
}
$ref = new ReflectionClass(Foo::class);
var_dump(Reflection::getModifierNames($ref->getModifiers()));
diff --git a/ext/reflection/tests/bug80190.phpt b/ext/reflection/tests/bug80190.phpt
new file mode 100644
index 0000000000..16f2fbba42
--- /dev/null
+++ b/ext/reflection/tests/bug80190.phpt
@@ -0,0 +1,67 @@
+--TEST--
+Bug #80190: ReflectionMethod::getReturnType() does not handle static as part of union type
+--FILE--
+<?php
+
+class C
+{
+ public function a(): self
+ {
+ }
+
+ public function b(): stdClass|self
+ {
+ }
+
+ public function c(): static
+ {
+ }
+
+ public function d(): stdClass|static
+ {
+ }
+}
+
+foreach ((new ReflectionClass(C::class))->getMethods() as $method) {
+ print $method->getDeclaringClass()->getName() . '::' . $method->getName() . '()' . PHP_EOL;
+ print ' $method->getReturnType() returns ' . get_class($method->getReturnType()) . PHP_EOL;
+ print ' $method->getReturnType()->__toString() returns ' . $method->getReturnType() . PHP_EOL;
+
+ if ($method->getReturnType() instanceof ReflectionUnionType) {
+ print ' $method->getReturnType()->getTypes() returns an array with ' . count($method->getReturnType()->getTypes()) . ' element(s)' . PHP_EOL;
+
+ print ' type(s) in union: ';
+
+ $types = [];
+
+ foreach ($method->getReturnType()->getTypes() as $type) {
+ $types[] = get_class($type) . "($type)";
+ }
+
+ print join(', ', $types) . PHP_EOL;
+ }
+
+ print PHP_EOL;
+}
+
+?>
+--EXPECT--
+C::a()
+ $method->getReturnType() returns ReflectionNamedType
+ $method->getReturnType()->__toString() returns self
+
+C::b()
+ $method->getReturnType() returns ReflectionUnionType
+ $method->getReturnType()->__toString() returns stdClass|self
+ $method->getReturnType()->getTypes() returns an array with 2 element(s)
+ type(s) in union: ReflectionNamedType(stdClass), ReflectionNamedType(self)
+
+C::c()
+ $method->getReturnType() returns ReflectionNamedType
+ $method->getReturnType()->__toString() returns static
+
+C::d()
+ $method->getReturnType() returns ReflectionUnionType
+ $method->getReturnType()->__toString() returns stdClass|static
+ $method->getReturnType()->getTypes() returns an array with 2 element(s)
+ type(s) in union: ReflectionNamedType(stdClass), ReflectionNamedType(static)
diff --git a/ext/reflection/tests/bug80299.phpt b/ext/reflection/tests/bug80299.phpt
new file mode 100644
index 0000000000..61aec5b1ce
--- /dev/null
+++ b/ext/reflection/tests/bug80299.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #80299: ReflectionFunction->invokeArgs confused in arguments
+--FILE--
+<?php
+
+$bar = new DateTime();
+$args = [1, &$bar];
+
+$function = function (int &$foo, DateTimeInterface &$bar) {};
+
+(new ReflectionFunction($function))->invokeArgs($args);
+
+?>
+--EXPECTF--
+Warning: {closure}(): Argument #1 ($foo) must be passed by reference, value given in %s on line %d
diff --git a/ext/reflection/tests/bug80370.phpt b/ext/reflection/tests/bug80370.phpt
new file mode 100644
index 0000000000..41d01c2e7e
--- /dev/null
+++ b/ext/reflection/tests/bug80370.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #80370: Segfault on ReflectionProperty::getAttributes of dynamic property
+--FILE--
+<?php
+class Foobar {
+
+}
+
+$foobar = new Foobar();
+$foobar->bar = 42;
+
+$reflectionObject = new ReflectionObject($foobar);
+$reflectionProperty = $reflectionObject->getProperty('bar');
+var_dump($reflectionProperty->getAttributes());
+--EXPECT--
+array(0) {
+}
diff --git a/ext/reflection/tests/closures_001.phpt b/ext/reflection/tests/closures_001.phpt
index 57c1b4e3f6..56581c05b8 100644
--- a/ext/reflection/tests/closures_001.phpt
+++ b/ext/reflection/tests/closures_001.phpt
@@ -11,10 +11,10 @@ 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());
- }
+ if ($rm->getName() == '__invoke') {
+ var_dump($rm->getNumberOfParameters());
+ var_dump($rm->getNumberOfRequiredParameters());
+ }
}
echo "---\n";
@@ -47,7 +47,6 @@ $rp = new ReflectionParameter($closure, 'b');
var_dump($rp->isOptional());
?>
-===DONE===
--EXPECT--
int(2)
int(1)
@@ -67,4 +66,3 @@ 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
index ed973b56c1..9e606857b6 100644
--- a/ext/reflection/tests/closures_002.phpt
+++ b/ext/reflection/tests/closures_002.phpt
@@ -1,10 +1,10 @@
--TEST--
-Reflection on invokable objects
+Reflection on invocable objects
--FILE--
<?php
class Test {
- function __invoke($a, $b = 0) { }
+ function __invoke($a, $b = 0) { }
}
$rm = new ReflectionMethod(new Test, '__invoke');
@@ -19,11 +19,9 @@ $rp = new ReflectionParameter(array(new Test, '__invoke'), 1);
var_dump($rp->isOptional());
?>
-===DONE===
--EXPECT--
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
index 57245cacde..e50d9c466f 100644
--- a/ext/reflection/tests/closures_003.phpt
+++ b/ext/reflection/tests/closures_003.phpt
@@ -18,8 +18,6 @@ unset ($parameter);
echo $method->getName ()."\n";
?>
-===DONE===
--EXPECT--
__invoke
__invoke
-===DONE===
diff --git a/ext/reflection/tests/closures_003_v1.phpt b/ext/reflection/tests/closures_003_v1.phpt
index cf853a00fd..1ae5502a39 100644
--- a/ext/reflection/tests/closures_003_v1.phpt
+++ b/ext/reflection/tests/closures_003_v1.phpt
@@ -18,8 +18,6 @@ unset ($parameter);
echo $method->getName ()."\n";
?>
-===DONE===
--EXPECT--
{closure}
{closure}
-===DONE===
diff --git a/ext/reflection/tests/closures_004.phpt b/ext/reflection/tests/closures_004.phpt
index e2b52c5429..479c7c3e67 100644
--- a/ext/reflection/tests/closures_004.phpt
+++ b/ext/reflection/tests/closures_004.phpt
@@ -30,7 +30,6 @@ $closure2 ();
$closure2->__invoke ();
?>
-===DONE===
--EXPECT--
Invoked!
Invoked!
@@ -40,4 +39,3 @@ Invoked!
Invoked!
Invoked!
Invoked!
-===DONE===
diff --git a/ext/reflection/tests/constructor_promotion.phpt b/ext/reflection/tests/constructor_promotion.phpt
new file mode 100644
index 0000000000..d0a09aaee0
--- /dev/null
+++ b/ext/reflection/tests/constructor_promotion.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Using Reflection on promoted properties
+--FILE--
+<?php
+
+class Test {
+ public $z;
+ public function __construct(
+ public int $x,
+ /** @SomeAnnotation() */
+ public string $y = "123",
+ string $z = "abc",
+ ) {}
+}
+
+$rc = new ReflectionClass(Test::class);
+echo $rc, "\n";
+
+$y = $rc->getProperty('y');
+var_dump($y->isPromoted());
+var_dump($y->getDocComment());
+$z = $rc->getProperty('z');
+var_dump($z->isPromoted());
+
+echo "\n";
+
+$rp = new ReflectionParameter([Test::class, '__construct'], 'y');
+var_dump($rp->isPromoted());
+$rp = new ReflectionParameter([Test::class, '__construct'], 'z');
+var_dump($rp->isPromoted());
+
+?>
+--EXPECTF--
+Class [ <user> class Test ] {
+ @@ %s 3-11
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [3] {
+ Property [ public $z = NULL ]
+ Property [ public int $x ]
+ Property [ public string $y ]
+ }
+
+ - Methods [1] {
+ Method [ <user, ctor> public method __construct ] {
+ @@ %s 5 - 10
+
+ - Parameters [3] {
+ Parameter #0 [ <required> int $x ]
+ Parameter #1 [ <optional> string $y = '123' ]
+ Parameter #2 [ <optional> string $z = 'abc' ]
+ }
+ }
+ }
+}
+
+bool(true)
+string(24) "/** @SomeAnnotation() */"
+bool(false)
+
+bool(true)
+bool(false)
diff --git a/ext/reflection/tests/default_value_internal_userland_arginfo.phpt b/ext/reflection/tests/default_value_internal_userland_arginfo.phpt
new file mode 100644
index 0000000000..b55a946379
--- /dev/null
+++ b/ext/reflection/tests/default_value_internal_userland_arginfo.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Fetching default value of an internal trampoline function with userland arginfo
+--FILE--
+<?php
+$closure = function ($b = 0) {};
+$ro = new ReflectionObject($closure);
+$rm = $ro->getMethod('__invoke');
+echo $rm, "\n";
+
+$rp = $rm->getParameters()[0];
+var_dump($rp->isDefaultValueAvailable());
+try {
+ var_dump($rp->getDefaultValue());
+} catch (ReflectionException $e) {
+ echo $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Method [ <internal> public method __invoke ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $b = <default> ]
+ }
+}
+
+bool(false)
+Internal error: Failed to retrieve the default value
diff --git a/ext/reflection/tests/default_value_leak.phpt b/ext/reflection/tests/default_value_leak.phpt
new file mode 100644
index 0000000000..85b6382935
--- /dev/null
+++ b/ext/reflection/tests/default_value_leak.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Check that isDefaultValueConstant() does not leak
+--FILE--
+<?php
+
+class Test {
+ public function method($param = [123]) {}
+}
+
+$rp = new ReflectionParameter(['Test', 'method'], 'param');
+var_dump($rp->isDefaultValueAvailable());
+var_dump($rp->isDefaultValueConstant());
+var_dump($rp->getDefaultValue());
+
+?>
+--EXPECT--
+bool(true)
+bool(false)
+array(1) {
+ [0]=>
+ int(123)
+}
diff --git a/ext/reflection/tests/included4.inc b/ext/reflection/tests/included4.inc
index 313fc5feca..7b64eb29cf 100644
--- a/ext/reflection/tests/included4.inc
+++ b/ext/reflection/tests/included4.inc
@@ -3,7 +3,7 @@ echo __FILE__ . "\n";
echo __LINE__ . "\n";
function g() {
- echo __FILE__ . "\n";
- echo __LINE__ . "\n";
+ echo __FILE__ . "\n";
+ echo __LINE__ . "\n";
}
?>
diff --git a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValueConstantName_Internal.phpt b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValueConstantName_Internal.phpt
new file mode 100644
index 0000000000..b013c9db66
--- /dev/null
+++ b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValueConstantName_Internal.phpt
@@ -0,0 +1,53 @@
+--TEST--
+ReflectionParameter::getDefaultValueConstantName() should also work for parameters of internal functions.
+--FILE--
+<?php
+$class = new ReflectionClass('DateTime');
+$method = $class->getMethod('setTime');
+
+foreach ($method->getParameters() as $parameter) {
+ try {
+ var_dump($parameter->getDefaultValueConstantName());
+ } catch (ReflectionException $exception) {
+ echo $exception->getMessage() . "\n";
+ }
+}
+
+echo "----------\n";
+
+$class = new ReflectionClass('DateTimeZone');
+$method = $class->getMethod('getTransitions');
+
+foreach ($method->getParameters() as $parameter) {
+ try {
+ var_dump($parameter->getDefaultValueConstantName());
+ } catch (ReflectionException $exception) {
+ echo $exception->getMessage() . "\n";
+ }
+}
+
+echo "----------\n";
+
+$class = new ReflectionClass('DateTimeZone');
+$method = $class->getMethod('listIdentifiers');
+
+foreach ($method->getParameters() as $parameter) {
+ try {
+ var_dump($parameter->getDefaultValueConstantName());
+ } catch (ReflectionException $exception) {
+ echo $exception->getMessage() . "\n";
+ }
+}
+
+?>
+--EXPECT--
+Internal error: Failed to retrieve the default value
+Internal error: Failed to retrieve the default value
+NULL
+NULL
+----------
+string(11) "PHP_INT_MIN"
+string(11) "PHP_INT_MAX"
+----------
+string(17) "DateTimeZone::ALL"
+NULL
diff --git a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValue_Internal.phpt b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValue_Internal.phpt
new file mode 100644
index 0000000000..c1e1a14b27
--- /dev/null
+++ b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_getDefaultValue_Internal.phpt
@@ -0,0 +1,37 @@
+--TEST--
+ReflectionParameter::getDefaultValue() should also work for parameters of internal functions.
+--FILE--
+<?php
+$class = new ReflectionClass('DateTime');
+$method = $class->getMethod('setTime');
+
+foreach ($method->getParameters() as $k => $parameter) {
+ try {
+ var_dump($parameter->getDefaultValue());
+ } catch (ReflectionException $exception) {
+ echo $exception->getMessage() . "\n";
+ }
+}
+
+echo "----------\n";
+
+$class = new ReflectionClass('DateTimeZone');
+$method = $class->getMethod('listIdentifiers');
+
+foreach ($method->getParameters() as $parameter) {
+ try {
+ var_dump($parameter->getDefaultValue());
+ } catch (ReflectionException $exception) {
+ echo $exception->getMessage() . "\n";
+ }
+}
+
+?>
+--EXPECT--
+Internal error: Failed to retrieve the default value
+Internal error: Failed to retrieve the default value
+int(0)
+int(0)
+----------
+int(2047)
+NULL
diff --git a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_isDefaultValueAvailable_Internal.phpt b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_isDefaultValueAvailable_Internal.phpt
new file mode 100644
index 0000000000..bcdcb68f19
--- /dev/null
+++ b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_isDefaultValueAvailable_Internal.phpt
@@ -0,0 +1,28 @@
+--TEST--
+ReflectionParameter::isDefaultValueAvailable() should also work for parameters of internal functions
+--FILE--
+<?php
+$class = new ReflectionClass('DateTime');
+$method = $class->getMethod('setTime');
+
+foreach ($method->getParameters() as $parameter) {
+ var_dump($parameter->isDefaultValueAvailable());
+}
+
+echo "----------\n";
+
+$class = new ReflectionClass('DateTimeZone');
+$method = $class->getMethod('listIdentifiers');
+
+foreach ($method->getParameters() as $parameter) {
+ var_dump($parameter->isDefaultValueAvailable());
+}
+?>
+--EXPECT--
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+----------
+bool(true)
+bool(true)
diff --git a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_isDefaultValueConstant_Internal.phpt b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_isDefaultValueConstant_Internal.phpt
new file mode 100644
index 0000000000..35c5548074
--- /dev/null
+++ b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_isDefaultValueConstant_Internal.phpt
@@ -0,0 +1,36 @@
+--TEST--
+ReflectionParameter::isDefaultValueConstant() should also work for parameters of internal functions
+--FILE--
+<?php
+$class = new ReflectionClass('DateTime');
+$method = $class->getMethod('setTime');
+
+foreach ($method->getParameters() as $parameter) {
+ try {
+ var_dump($parameter->isDefaultValueConstant());
+ } catch (ReflectionException $exception) {
+ echo $exception->getMessage() . "\n";
+ }
+}
+
+echo "----------\n";
+
+$class = new ReflectionClass('DateTimeZone');
+$method = $class->getMethod('listIdentifiers');
+
+foreach ($method->getParameters() as $parameter) {
+ try {
+ var_dump($parameter->isDefaultValueConstant());
+ } catch (ReflectionException $exception) {
+ echo $exception->getMessage() . "\n";
+ }
+}
+?>
+--EXPECT--
+Internal error: Failed to retrieve the default value
+Internal error: Failed to retrieve the default value
+bool(false)
+bool(false)
+----------
+bool(true)
+bool(false)
diff --git a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_toString_Internal.phpt b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_toString_Internal.phpt
new file mode 100644
index 0000000000..5999d7f652
--- /dev/null
+++ b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_toString_Internal.phpt
@@ -0,0 +1,28 @@
+--TEST--
+ReflectionParameter::__toString() should display default values for internal functions as well
+--FILE--
+<?php
+$class = new ReflectionClass('DateTime');
+$method = $class->getMethod('setTime');
+
+foreach ($method->getParameters() as $k => $parameter) {
+ echo $parameter . "\n";
+}
+
+echo "----------\n";
+
+$class = new ReflectionClass('DateTimeZone');
+$method = $class->getMethod('listIdentifiers');
+
+foreach ($method->getParameters() as $parameter) {
+ echo $parameter . "\n";
+}
+?>
+--EXPECT--
+Parameter #0 [ <required> int $hour ]
+Parameter #1 [ <required> int $minute ]
+Parameter #2 [ <optional> int $second = 0 ]
+Parameter #3 [ <optional> int $microsecond = 0 ]
+----------
+Parameter #0 [ <optional> int $timezoneGroup = DateTimeZone::ALL ]
+Parameter #1 [ <optional> ?string $countryCode = null ]
diff --git a/ext/reflection/tests/internal_parameter_default_value/check_all.phpt b/ext/reflection/tests/internal_parameter_default_value/check_all.phpt
new file mode 100644
index 0000000000..7bfe08bc56
--- /dev/null
+++ b/ext/reflection/tests/internal_parameter_default_value/check_all.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Check that all internal parameter defaults evaluate without error
+--FILE--
+<?php
+
+function checkDefaults(ReflectionFunctionAbstract $rf) {
+ foreach ($rf->getParameters() as $param) {
+ if ($param->isDefaultValueAvailable()) {
+ try {
+ $param->getDefaultValue();
+ } catch (Error $e) {
+ echo "{$rf->getName()}: {$e->getMessage()}\n";
+ }
+ }
+ }
+}
+
+foreach (get_defined_functions()["internal"] as $func) {
+ $rf = new ReflectionFunction($func);
+ checkDefaults($rf);
+}
+
+foreach (get_declared_classes() as $class) {
+ $rc = new ReflectionClass($class);
+ foreach ($rc->getMethods() as $method) {
+ checkDefaults($method);
+ }
+}
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/ext/reflection/tests/mixed_type.phpt b/ext/reflection/tests/mixed_type.phpt
new file mode 100644
index 0000000000..2860e603c1
--- /dev/null
+++ b/ext/reflection/tests/mixed_type.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Test that the mixed type is reflectable
+--FILE--
+<?php
+class A
+{
+ public mixed $a;
+
+ public function test(mixed ...$a): mixed {}
+}
+
+$a = new A();
+
+$object = new ReflectionObject($a);
+$method = new ReflectionMethod($a, "test");
+
+var_dump($object->getProperty("a")->getType()->getName());
+var_dump($method->getParameters()[0]->getType()->getName());
+var_dump($method->getReturnType()->getName());
+
+var_dump((string) $object->getProperty("a")->getType());
+var_dump((string) $method->getParameters()[0]->getType());
+var_dump((string) $method->getReturnType());
+
+?>
+--EXPECT--
+string(5) "mixed"
+string(5) "mixed"
+string(5) "mixed"
+string(5) "mixed"
+string(5) "mixed"
+string(5) "mixed"
diff --git a/ext/reflection/tests/parameters_001.phpt b/ext/reflection/tests/parameters_001.phpt
index 972b97c1c7..d50d1a1e72 100644
--- a/ext/reflection/tests/parameters_001.phpt
+++ b/ext/reflection/tests/parameters_001.phpt
@@ -4,8 +4,8 @@ ReflectionParameter Check for parameter being optional
<?php
class Test {
- function func($x, $y = NULL){
- }
+ function func($x, $y = NULL){
+ }
}
@@ -20,19 +20,23 @@ $p = new ReflectionParameter(array('Test', 'func'), 'y');
var_dump($p->isOptional());
try {
- $p = new ReflectionParameter(array('Test', 'func'), 'z');
- var_dump($p->isOptional());
+ $p = new ReflectionParameter(array('Test', 'func'), 'z');
+ var_dump($p->isOptional());
+} catch (Exception $e) {
+ var_dump($e->getMessage());
}
-catch (Exception $e) {
- var_dump($e->getMessage());
+try {
+ $p = new ReflectionParameter(array('Test', 'func'), -1);
+ var_dump($p->isOptional());
+} catch (\ValueError $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===
+string(91) "ReflectionParameter::__construct(): Argument #2 ($param) must be greater than or equal to 0"
diff --git a/ext/reflection/tests/parameters_002.phpt b/ext/reflection/tests/parameters_002.phpt
index ae924323a0..f27f4ab6fd 100644
--- a/ext/reflection/tests/parameters_002.phpt
+++ b/ext/reflection/tests/parameters_002.phpt
@@ -10,61 +10,61 @@ function test($nix, Array $ar, &$ref, stdClass $std,
class test
{
- function method($nix, Array $ar, &$ref, stdClass $std,
+ function method($nix, Array $ar, &$ref, stdClass $std,
NonExistingClass $na, stdClass $opt = NULL, $def = "FooBar")
- {
- }
+ {
+ }
}
function check_params_decl_func($r, $f)
{
- $c = $r->$f();
+ $c = $r->$f();
$sep = $c instanceof ReflectionMethod ? $c->class . '::' : '';
- echo $f . ': ' . ($c ? $sep . $c->name : 'NULL') . "()\n";
+ echo $f . ': ' . ($c ? $sep . $c->name : 'NULL') . "()\n";
}
function check_params_decl_class($r, $f)
{
- $c = $r->$f();
- echo $f . ': ' . ($c ? $c->name : 'NULL') . "\n";
+ $c = $r->$f();
+ echo $f . ': ' . ($c ? $c->name : 'NULL') . "\n";
}
function check_params_func($r, $f)
{
- echo $f . ': ';
- $v = $r->$f();
- var_dump($v);
+ 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');
+ 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_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'));
@@ -72,61 +72,83 @@ check_params(new ReflectionFunction('test'));
check_params(new ReflectionMethod('test::method'));
?>
-===DONE===
-<?php exit(0); ?>
---EXPECT--
+--EXPECTF--
#####test()#####
===0===
getName: string(3) "nix"
isPassedByReference: bool(false)
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
getClass: NULL
getDeclaringClass: NULL
-isArray: bool(false)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(false)
allowsNull: bool(true)
isOptional: bool(false)
isDefaultValueAvailable: bool(false)
===1===
getName: string(2) "ar"
isPassedByReference: bool(false)
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
getClass: NULL
getDeclaringClass: NULL
-isArray: bool(true)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(true)
allowsNull: bool(false)
isOptional: bool(false)
isDefaultValueAvailable: bool(false)
===2===
getName: string(3) "ref"
isPassedByReference: bool(true)
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
getClass: NULL
getDeclaringClass: NULL
-isArray: bool(false)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(false)
allowsNull: bool(true)
isOptional: bool(false)
isDefaultValueAvailable: bool(false)
===3===
getName: string(3) "std"
isPassedByReference: bool(false)
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
getClass: stdClass
getDeclaringClass: NULL
-isArray: bool(false)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(false)
allowsNull: bool(false)
isOptional: bool(false)
isDefaultValueAvailable: bool(false)
===4===
getName: string(2) "na"
isPassedByReference: bool(false)
-Class NonExistingClass does not exist
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
+Class "NonExistingClass" does not exist
getDeclaringClass: NULL
-isArray: bool(false)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(false)
allowsNull: bool(false)
isOptional: bool(false)
isDefaultValueAvailable: bool(false)
===5===
getName: string(3) "opt"
isPassedByReference: bool(true)
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
getClass: stdClass
getDeclaringClass: NULL
-isArray: bool(false)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(false)
allowsNull: bool(true)
isOptional: bool(true)
isDefaultValueAvailable: bool(true)
@@ -134,9 +156,13 @@ getDefaultValue: NULL
===6===
getName: string(3) "def"
isPassedByReference: bool(false)
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
getClass: NULL
getDeclaringClass: NULL
-isArray: bool(false)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(false)
allowsNull: bool(true)
isOptional: bool(true)
isDefaultValueAvailable: bool(true)
@@ -145,54 +171,78 @@ getDefaultValue: string(6) "FooBar"
===0===
getName: string(3) "nix"
isPassedByReference: bool(false)
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
getClass: NULL
getDeclaringClass: test
-isArray: bool(false)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(false)
allowsNull: bool(true)
isOptional: bool(false)
isDefaultValueAvailable: bool(false)
===1===
getName: string(2) "ar"
isPassedByReference: bool(false)
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
getClass: NULL
getDeclaringClass: test
-isArray: bool(true)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(true)
allowsNull: bool(false)
isOptional: bool(false)
isDefaultValueAvailable: bool(false)
===2===
getName: string(3) "ref"
isPassedByReference: bool(true)
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
getClass: NULL
getDeclaringClass: test
-isArray: bool(false)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(false)
allowsNull: bool(true)
isOptional: bool(false)
isDefaultValueAvailable: bool(false)
===3===
getName: string(3) "std"
isPassedByReference: bool(false)
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
getClass: stdClass
getDeclaringClass: test
-isArray: bool(false)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(false)
allowsNull: bool(false)
isOptional: bool(false)
isDefaultValueAvailable: bool(false)
===4===
getName: string(2) "na"
isPassedByReference: bool(false)
-Class NonExistingClass does not exist
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
+Class "NonExistingClass" does not exist
getDeclaringClass: test
-isArray: bool(false)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(false)
allowsNull: bool(false)
isOptional: bool(false)
isDefaultValueAvailable: bool(false)
===5===
getName: string(3) "opt"
isPassedByReference: bool(false)
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
getClass: stdClass
getDeclaringClass: test
-isArray: bool(false)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+bool(false)
allowsNull: bool(true)
isOptional: bool(true)
isDefaultValueAvailable: bool(true)
@@ -200,11 +250,14 @@ getDefaultValue: NULL
===6===
getName: string(3) "def"
isPassedByReference: bool(false)
+
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
getClass: NULL
getDeclaringClass: test
-isArray: bool(false)
+isArray:
+Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
+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
index d7ecefb775..3af7bc4ce6 100644
--- a/ext/reflection/tests/property_exists.phpt
+++ b/ext/reflection/tests/property_exists.phpt
@@ -5,54 +5,54 @@ Reflection and property_exists()
class A
{
- public $a = 1;
- protected $b = 2;
- private $c = 3;
+ public $a = 1;
+ protected $b = 2;
+ private $c = 3;
- public $empty;
- public $init = 1;
+ public $empty;
+ public $init = 1;
- function __toString()
- {
- return 'obj(' . get_class($this) . ')';
- }
+ 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));
- }
- }
+ 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;
+ 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));
- }
- }
+ 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;
+ 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));
- }
- }
+ 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;
@@ -64,22 +64,30 @@ $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));
- }
+ 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'));
+try {
+ var_dump(property_exists(NULL, 'empty'));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump(property_exists(25,'empty'));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
var_dump(property_exists('',''));
var_dump(property_exists('A',''));
var_dump(property_exists('A','123'));
@@ -90,9 +98,7 @@ 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--
+--EXPECT--
===A===
obj(A)::$a
bool(true)
@@ -204,12 +210,8 @@ 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
+property_exists(): Argument #1 ($object_or_class) must be of type object|string, null given
+property_exists(): Argument #1 ($object_or_class) must be of type object|string, int given
bool(false)
bool(false)
bool(false)
@@ -219,4 +221,3 @@ bool(false)
bool(false)
bool(true)
bool(true)
-===DONE===
diff --git a/ext/reflection/tests/request38992.phpt b/ext/reflection/tests/request38992.phpt
index 8c0052fd85..547b2d2523 100644
--- a/ext/reflection/tests/request38992.phpt
+++ b/ext/reflection/tests/request38992.phpt
@@ -11,12 +11,17 @@ class MyClass
}
$r = new ReflectionMethod('MyClass', 'doSomething');
-$r->invoke('WTF?');
-$r->invokeArgs('WTF?', array());
+try {
+ $r->invoke('WTF?');
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ $r->invokeArgs('WTF?', array());
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
?>
-===DONE===
---EXPECTF--
-Warning: ReflectionMethod::invoke() expects parameter 1 to be object, string given in %s%erequest38992.php on line %d
-
-Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, string given in %s%erequest38992.php on line %d
-===DONE===
+--EXPECT--
+ReflectionMethod::invoke(): Argument #1 ($object) must be of type ?object, string given
+ReflectionMethod::invokeArgs(): Argument #1 ($object) must be of type ?object, string given
diff --git a/ext/reflection/tests/static_properties_002.phpt b/ext/reflection/tests/static_properties_002.phpt
index 0e3baa9530..126aa784a0 100644
--- a/ext/reflection/tests/static_properties_002.phpt
+++ b/ext/reflection/tests/static_properties_002.phpt
@@ -4,29 +4,29 @@ Reflection and inheriting static properties
<?php
class base {
- static protected $prop = 2;
+ static protected $prop = 2;
- static function show() {
- echo __METHOD__ . '(' . self::$prop . ")\n";
- }
+ static function show() {
+ echo __METHOD__ . '(' . self::$prop . ")\n";
+ }
- static function inc() {
- base::$prop++;
- echo __METHOD__ . "()\n";
- }
+ static function inc() {
+ base::$prop++;
+ echo __METHOD__ . "()\n";
+ }
}
class derived extends base {
- static public $prop = 2;
+ static public $prop = 2;
- static function show() {
- echo __METHOD__ . '(' . self::$prop . ")\n";
- }
+ static function show() {
+ echo __METHOD__ . '(' . self::$prop . ")\n";
+ }
- static function inc() {
- derived::$prop++;
- echo __METHOD__ . "()\n";
- }
+ static function inc() {
+ derived::$prop++;
+ echo __METHOD__ . "()\n";
+ }
}
base::show();
diff --git a/ext/reflection/tests/static_type.phpt b/ext/reflection/tests/static_type.phpt
new file mode 100644
index 0000000000..b541008f79
--- /dev/null
+++ b/ext/reflection/tests/static_type.phpt
@@ -0,0 +1,22 @@
+--TEST--
+ReflectionType for static types
+--FILE--
+<?php
+
+class A {
+ public function test(): static {
+ return new static;
+ }
+}
+
+$rm = new ReflectionMethod(A::class, 'test');
+$rt = $rm->getReturnType();
+var_dump($rt->isBuiltin());
+var_dump($rt->getName());
+var_dump((string) $rt);
+
+?>
+--EXPECT--
+bool(false)
+string(6) "static"
+string(6) "static"
diff --git a/ext/reflection/tests/traits001.phpt b/ext/reflection/tests/traits001.phpt
index 4e36ceeaf0..b9870ceb8d 100644
--- a/ext/reflection/tests/traits001.phpt
+++ b/ext/reflection/tests/traits001.phpt
@@ -19,6 +19,7 @@ var_dump($rFoo->isTrait());
var_dump($rBar->isTrait());
echo $rFoo;
echo $rBar;
+?>
--EXPECTF--
bool(true)
bool(false)
diff --git a/ext/reflection/tests/traits004.phpt b/ext/reflection/tests/traits004.phpt
index d975a52726..0feed127d9 100644
--- a/ext/reflection/tests/traits004.phpt
+++ b/ext/reflection/tests/traits004.phpt
@@ -16,6 +16,7 @@ for ($c = "C1"; $c <= "C3"; $c++) {
var_dump($r->getTraits());
echo "\n";
}
+?>
--EXPECT--
class C1:
array(0) {
diff --git a/ext/reflection/tests/union_types.phpt b/ext/reflection/tests/union_types.phpt
new file mode 100644
index 0000000000..042ba0759d
--- /dev/null
+++ b/ext/reflection/tests/union_types.phpt
@@ -0,0 +1,112 @@
+--TEST--
+Union types in reflection
+--INI--
+error_reporting=E_ALL&~E_DEPRECATED
+--FILE--
+<?php
+
+function dumpType(ReflectionUnionType $rt) {
+ echo "Type $rt:\n";
+ echo "Allows null: " . ($rt->allowsNull() ? "true" : "false") . "\n";
+ foreach ($rt->getTypes() as $type) {
+ echo " Name: " . $type->getName() . "\n";
+ echo " String: " . (string) $type . "\n";
+ echo " Allows Null: " . ($type->allowsNull() ? "true" : "false") . "\n";
+ }
+}
+
+function test1(): X|Y|int|float|false|null { }
+function test2(): X|iterable|bool { }
+
+class Test {
+ public X|Y|int $prop;
+}
+
+dumpType((new ReflectionFunction('test1'))->getReturnType());
+dumpType((new ReflectionFunction('test2'))->getReturnType());
+
+$rc = new ReflectionClass(Test::class);
+$rp = $rc->getProperty('prop');
+dumpType($rp->getType());
+
+/* Force CE resolution of the property type */
+
+class x {}
+$test = new Test;
+$test->prop = new x;
+
+$rp = $rc->getProperty('prop');
+dumpType($rp->getType());
+
+class y {}
+$test->prop = new y;
+
+$rp = $rc->getProperty('prop');
+dumpType($rp->getType());
+
+?>
+--EXPECT--
+Type X|Y|int|float|false|null:
+Allows null: true
+ Name: X
+ String: X
+ Allows Null: false
+ Name: Y
+ String: Y
+ Allows Null: false
+ Name: int
+ String: int
+ Allows Null: false
+ Name: float
+ String: float
+ Allows Null: false
+ Name: false
+ String: false
+ Allows Null: false
+ Name: null
+ String: null
+ Allows Null: true
+Type X|iterable|bool:
+Allows null: false
+ Name: X
+ String: X
+ Allows Null: false
+ Name: iterable
+ String: iterable
+ Allows Null: false
+ Name: bool
+ String: bool
+ Allows Null: false
+Type X|Y|int:
+Allows null: false
+ Name: X
+ String: X
+ Allows Null: false
+ Name: Y
+ String: Y
+ Allows Null: false
+ Name: int
+ String: int
+ Allows Null: false
+Type x|Y|int:
+Allows null: false
+ Name: x
+ String: x
+ Allows Null: false
+ Name: Y
+ String: Y
+ Allows Null: false
+ Name: int
+ String: int
+ Allows Null: false
+Type x|y|int:
+Allows null: false
+ Name: x
+ String: x
+ Allows Null: false
+ Name: y
+ String: y
+ Allows Null: false
+ Name: int
+ String: int
+ Allows Null: false