]> granicus.if.org Git - php/commitdiff
Make the $filter parameter of ReflectionClass::get*Constants() nullable
authorMáté Kocsis <kocsismate@woohoolabs.com>
Tue, 29 Sep 2020 07:19:45 +0000 (09:19 +0200)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Tue, 29 Sep 2020 09:04:10 +0000 (11:04 +0200)
ext/reflection/php_reflection.c
ext/reflection/php_reflection.stub.php
ext/reflection/php_reflection_arginfo.h
ext/reflection/tests/ReflectionClass_toString_001.phpt

index d4f89be69f52421f07e2f06763eda594a88a002c..7b9c37d1eb51e2547a945eb150b959070c5236e0 100644 (file)
@@ -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);
index bd0a6fe0a17796ed0976b563ff44b635f8c4250e..cf6613c3a32edcd844f09843efebda84dbb243a1 100644 (file)
@@ -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) {}
index bd90c8cb68806446d6f58ecaa2add94860f2a525..6044f7f2434cd2fe30061b2f1f92222c456eba78 100644 (file)
@@ -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
 
index 00e41bfcc9f68c3b8255d6b6820c7db1df3ca5ca..13b6130a407e299cc5ebdb19e8c3bdd9e2a89bbc 100644 (file)
@@ -166,14 +166,14 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector, String
     Method [ <internal:Reflection> public method getConstants ] {
 
       - Parameters [1] {
-        Parameter #0 [ <optional> int $filter = ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE ]
+        Parameter #0 [ <optional> ?int $filter = null ]
       }
     }
 
     Method [ <internal:Reflection> public method getReflectionConstants ] {
 
       - Parameters [1] {
-        Parameter #0 [ <optional> int $filter = ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE ]
+        Parameter #0 [ <optional> ?int $filter = null ]
       }
     }