Skip to content

Commit 5ed837c

Browse files
committed
Make the $modifiers parameter of ReflectionClass::get*Constants() nullable
1 parent 3dfbd22 commit 5ed837c

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

ext/reflection/php_reflection.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,7 +4190,7 @@ ZEND_METHOD(ReflectionClass, getMethods)
41904190
reflection_object *intern;
41914191
zend_class_entry *ce;
41924192
zend_function *mptr;
4193-
zend_long filter = 0;
4193+
zend_long filter;
41944194
zend_bool filter_is_null = 1;
41954195

41964196
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) {
@@ -4366,7 +4366,7 @@ ZEND_METHOD(ReflectionClass, getProperties)
43664366
zend_class_entry *ce;
43674367
zend_string *key;
43684368
zend_property_info *prop_info;
4369-
zend_long filter = 0;
4369+
zend_long filter;
43704370
zend_bool filter_is_null = 1;
43714371

43724372
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) {
@@ -4422,12 +4422,17 @@ ZEND_METHOD(ReflectionClass, getConstants)
44224422
zend_string *key;
44234423
zend_class_constant *constant;
44244424
zval val;
4425-
zend_long filter = ZEND_ACC_PPP_MASK;
4425+
zend_long filter;
4426+
zend_bool filter_is_null = 1;
44264427

4427-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &filter) == FAILURE) {
4428+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) {
44284429
RETURN_THROWS();
44294430
}
44304431

4432+
if (filter_is_null) {
4433+
filter = ZEND_ACC_PPP_MASK;
4434+
}
4435+
44314436
GET_REFLECTION_OBJECT_PTR(ce);
44324437

44334438
array_init(return_value);
@@ -4452,12 +4457,17 @@ ZEND_METHOD(ReflectionClass, getReflectionConstants)
44524457
zend_class_entry *ce;
44534458
zend_string *name;
44544459
zend_class_constant *constant;
4455-
zend_long filter = ZEND_ACC_PPP_MASK;
4460+
zend_long filter;
4461+
zend_bool filter_is_null = 1;
44564462

4457-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &filter) == FAILURE) {
4463+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) {
44584464
RETURN_THROWS();
44594465
}
44604466

4467+
if (filter_is_null) {
4468+
filter = ZEND_ACC_PPP_MASK;
4469+
}
4470+
44614471
GET_REFLECTION_OBJECT_PTR(ce);
44624472

44634473
array_init(return_value);

ext/reflection/php_reflection.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,10 @@ public function getProperties(?int $modifiers = null) {}
260260
public function hasConstant(string $name) {}
261261

262262
/** @return array|null */
263-
public function getConstants(int $modifiers = ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE) {}
263+
public function getConstants(?int $modifiers = null) {}
264264

265265
/** @return ReflectionClassConstant[] */
266-
public function getReflectionConstants(int $modifiers = ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE) {}
266+
public function getReflectionConstants(?int $modifiers = null) {}
267267

268268
/** @return mixed */
269269
public function getConstant(string $name) {}

ext/reflection/php_reflection_arginfo.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 7a05b86697bef8c44f537ff37f47764c0fa6be3f */
2+
* Stub hash: 68c31a330622d4ea865e4e78dce04a8a27242ade */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0)
@@ -197,11 +197,9 @@ ZEND_END_ARG_INFO()
197197

198198
#define arginfo_class_ReflectionClass_hasConstant arginfo_class_ReflectionClass_hasMethod
199199

200-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ReflectionClass_getConstants, 0, 0, 0)
201-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, modifiers, IS_LONG, 0, "ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE")
202-
ZEND_END_ARG_INFO()
200+
#define arginfo_class_ReflectionClass_getConstants arginfo_class_ReflectionClass_getProperties
203201

204-
#define arginfo_class_ReflectionClass_getReflectionConstants arginfo_class_ReflectionClass_getConstants
202+
#define arginfo_class_ReflectionClass_getReflectionConstants arginfo_class_ReflectionClass_getProperties
205203

206204
#define arginfo_class_ReflectionClass_getConstant arginfo_class_ReflectionClass_hasMethod
207205

ext/reflection/tests/ReflectionClass_toString_001.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector, String
166166
Method [ <internal:Reflection> public method getConstants ] {
167167

168168
- Parameters [1] {
169-
Parameter #0 [ <optional> int $modifiers = ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE ]
169+
Parameter #0 [ <optional> ?int $modifiers = null ]
170170
}
171171
}
172172

173173
Method [ <internal:Reflection> public method getReflectionConstants ] {
174174

175175
- Parameters [1] {
176-
Parameter #0 [ <optional> int $modifiers = ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE ]
176+
Parameter #0 [ <optional> ?int $modifiers = null ]
177177
}
178178
}
179179

0 commit comments

Comments
 (0)