From bf362c47902840033883829063ca8fe7bba81bb2 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Thu, 4 Sep 2025 11:51:25 +0300 Subject: [PATCH] GH-19691: Add asymmetric visibility to `Reflection::getModifierNames()` --- NEWS | 4 ++++ ext/reflection/php_reflection.c | 9 +++++++++ .../tests/Reflection_getModifierNames_001.phpt | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/NEWS b/NEWS index 045f6b8d94ace..6ee8819b671e4 100644 --- a/NEWS +++ b/NEWS @@ -33,6 +33,10 @@ PHP NEWS - PDO: . Driver specific methods in the PDO class are now deprecated. (Arnaud) +- Reflection: + . Fix GH-19691 (getModifierNames() not reporting asymmetric visibility). + (DanielEScherzer) + - Session: . Fix RC violation of session SID constant deprecation attribute. (ilutov) diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 3a93e61c6d6ac..3d025c7eefd7c 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1713,6 +1713,15 @@ ZEND_METHOD(Reflection, getModifierNames) add_next_index_stringl(return_value, "protected", sizeof("protected")-1); break; } + /* These are also mutually exclusive */ + switch (modifiers & ZEND_ACC_PPP_SET_MASK) { + case ZEND_ACC_PROTECTED_SET: + add_next_index_stringl(return_value, "protected(set)", sizeof("protected(set)")-1); + break; + case ZEND_ACC_PRIVATE_SET: + add_next_index_stringl(return_value, "private(set)", sizeof("private(set)")-1); + break; + } if (modifiers & ZEND_ACC_STATIC) { add_next_index_str(return_value, ZSTR_KNOWN(ZEND_STR_STATIC)); diff --git a/ext/reflection/tests/Reflection_getModifierNames_001.phpt b/ext/reflection/tests/Reflection_getModifierNames_001.phpt index 918ef2f28000a..78ba327df6f54 100644 --- a/ext/reflection/tests/Reflection_getModifierNames_001.phpt +++ b/ext/reflection/tests/Reflection_getModifierNames_001.phpt @@ -15,6 +15,8 @@ printModifiers(ReflectionMethod::IS_ABSTRACT | ReflectionMethod::IS_FINAL); printModifiers(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_STATIC | ReflectionProperty::IS_READONLY); printModifiers(ReflectionClass::IS_READONLY); printModifiers(ReflectionProperty::IS_VIRTUAL); +printModifiers(ReflectionProperty::IS_PROTECTED_SET); +printModifiers(ReflectionProperty::IS_PRIVATE_SET); ?> --EXPECT-- private @@ -25,3 +27,5 @@ abstract,final public,static,readonly readonly virtual +protected(set) +private(set)