From: Máté Kocsis Date: Tue, 29 Sep 2020 07:19:45 +0000 (+0200) Subject: Make the $filter parameter of ReflectionClass::get*Constants() nullable X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=351776eae583d3dc352a4b3e8f4e4a639f8c59ec;p=php Make the $filter parameter of ReflectionClass::get*Constants() nullable --- diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index d4f89be69f..7b9c37d1eb 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -4190,7 +4190,7 @@ 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) { @@ -4366,7 +4366,7 @@ ZEND_METHOD(ReflectionClass, getProperties) 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) { @@ -4422,12 +4422,17 @@ ZEND_METHOD(ReflectionClass, getConstants) zend_string *key; zend_class_constant *constant; zval val; - zend_long filter = ZEND_ACC_PPP_MASK; + zend_long filter; + zend_bool filter_is_null = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &filter) == FAILURE) { + 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); @@ -4452,12 +4457,17 @@ ZEND_METHOD(ReflectionClass, getReflectionConstants) zend_class_entry *ce; zend_string *name; zend_class_constant *constant; - zend_long filter = ZEND_ACC_PPP_MASK; + zend_long filter; + zend_bool filter_is_null = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &filter) == FAILURE) { + 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); diff --git a/ext/reflection/php_reflection.stub.php b/ext/reflection/php_reflection.stub.php index bd0a6fe0a1..cf6613c3a3 100644 --- a/ext/reflection/php_reflection.stub.php +++ b/ext/reflection/php_reflection.stub.php @@ -260,10 +260,10 @@ class ReflectionClass implements Reflector public function hasConstant(string $name) {} /** @return array|null */ - public function getConstants(int $filter = ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE) {} + public function getConstants(?int $filter = null) {} /** @return ReflectionClassConstant[] */ - public function getReflectionConstants(int $filter = ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE) {} + public function getReflectionConstants(?int $filter = null) {} /** @return mixed */ public function getConstant(string $name) {} diff --git a/ext/reflection/php_reflection_arginfo.h b/ext/reflection/php_reflection_arginfo.h index bd90c8cb68..6044f7f243 100644 --- a/ext/reflection/php_reflection_arginfo.h +++ b/ext/reflection/php_reflection_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f5f4cfeab0e81c2b51bf11dde7b7d40fc87d9cbc */ + * Stub hash: 4429ea0f96f81c3dbfb2a7e6e00ce49aea4bfeb1 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0) @@ -195,11 +195,9 @@ ZEND_END_ARG_INFO() #define arginfo_class_ReflectionClass_hasConstant arginfo_class_ReflectionClass_hasMethod -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClass_getConstants, 0, 0, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, filter, IS_LONG, 0, "ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE") -ZEND_END_ARG_INFO() +#define arginfo_class_ReflectionClass_getConstants arginfo_class_ReflectionClass_getMethods -#define arginfo_class_ReflectionClass_getReflectionConstants arginfo_class_ReflectionClass_getConstants +#define arginfo_class_ReflectionClass_getReflectionConstants arginfo_class_ReflectionClass_getMethods #define arginfo_class_ReflectionClass_getConstant arginfo_class_ReflectionClass_hasMethod diff --git a/ext/reflection/tests/ReflectionClass_toString_001.phpt b/ext/reflection/tests/ReflectionClass_toString_001.phpt index 00e41bfcc9..13b6130a40 100644 --- a/ext/reflection/tests/ReflectionClass_toString_001.phpt +++ b/ext/reflection/tests/ReflectionClass_toString_001.phpt @@ -166,14 +166,14 @@ Class [ class ReflectionClass implements Reflector, String Method [ public method getConstants ] { - Parameters [1] { - Parameter #0 [ int $filter = ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE ] + Parameter #0 [ ?int $filter = null ] } } Method [ public method getReflectionConstants ] { - Parameters [1] { - Parameter #0 [ int $filter = ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE ] + Parameter #0 [ ?int $filter = null ] } }